Skip to content

Commit

Permalink
checking prerequisites based on distro
Browse files Browse the repository at this point in the history
Signed-off-by: Gaurav Gahlot <gaurav.gahlot19@gmail.com>
  • Loading branch information
gauravgahlot committed Apr 23, 2020
1 parent 24de465 commit 0105667
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 31 deletions.
49 changes: 48 additions & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,51 @@ $ curl https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh | bash
- All the environment variables are kept in the `envrc` file, which is generated from the setup itself.
- It is advised that you keep all the environment variables in the same file.
- It is important to note that if you execute the setup the again, a new `envrc` will be generated. However, the existing environment configuration be saved as `envrc.bak`.
- The setup removes all the `.tar.gz` files downloaded in process.
- The setup removes all the `.tar.gz` files downloaded in process.

# Setup the Provisioner

### Prerequisites
- The setup must be executed as a privileged or root user.
- The setup downloads about 1.5GB of assets, therefore, it is advised to have a minimum of 10GB disk space available before you begin.

### Interactive Mode
Execute the following commands to bring up the Tinkerbell stack with an interactive setup:
```shell
$ wget https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh && chmod +x setup.sh
$ ./setup.sh
```

### Declarative Mode
You can also execute the setup in declarative mode. In order to do so, define the following environment variables (examples here):
```shell
export TB_INTERFACE=network-interface # enp1s0f1
export TB_NETWORK=network-with-cidr # 192.168.1.0/29
export TB_IPADDR=provisioner-ip-address # 192.168.1.1
export TB_REGUSER=registry-username # admin
```

Now, you can execute the setup with the following command:
```shell
$ curl https://raw.githubusercontent.com/tinkerbell/tink/master/setup.sh | bash
```

### Good to know
- All the environment variables are kept in the `envrc` file, which is generated from the setup itself.
- It is advised that you keep all the environment variables in the same file.
- It is important to note that if you execute the setup the again, a new `envrc` will be generated. However, the existing environment configuration be saved as `envrc.bak`.
- The setup removes all the `.tar.gz` files downloaded in process.

### For Packet Environment

The script was tested with:
- Server class: `c3.small.x86`
- Operating System: Ubuntu 18.04 and CentOS 7
- Region: Amsterdam, NL (AMS1)
- ENV variables:
```shell
export TB_INTERFACE=enp1s0f1
export TB_NETWORK=192.168.1.0/29
export TB_IPADDR=192.168.1.1
export TB_REGUSER=admin
```
73 changes: 43 additions & 30 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -367,37 +367,38 @@ start_components() {

check_prerequisites() {
echo "$INFO verifying prerequisites"
if command_exists git; then
echo "$BLANK- git already installed, found $(git --version)"
else
echo "$BLANK- installing git"
apt-get update >> /dev/null && apt-get install -y --no-install-recommends git >> /dev/null
echo "$BLANK- $(git --version) installed successfully"
fi

if command_exists ifdown; then
echo "$BLANK- ifupdown already installed"
else
echo "$BLANK- installing ifupdown"
apt-get install -y ifupdown >> /dev/null && echo "$BLANK- ifupdown installed successfully"
fi

# TODO: verify if all required ports are available
}

do_setup() {
check_prerequisites
echo "$INFO starting tinkerbell stack setup"

# perform some very rudimentary platform detection
lsb_dist=$( get_distribution )
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"

# setup the prerequisites
generate_envrc
source $ENV_FILE
case "$1" in
ubuntu)
if command_exists git; then
echo "$BLANK- git already installed, found $(git --version)"
else
echo "$BLANK- updating packages"
apt-get update >> /dev/null
echo "$BLANK- installing git"
apt-get install -y --no-install-recommends git >> /dev/null
echo "$BLANK- $(git --version) installed successfully"
fi
if command_exists ifdown; then
echo "$BLANK- ifupdown already installed"
else
echo "$BLANK- installing ifupdown"
apt-get install -y ifupdown >> /dev/null && echo "$BLANK- ifupdown installed successfully"
fi
;;
centos)
if command_exists git; then
echo "$BLANK- git already installed, found $(git --version)"
else
echo "$BLANK- updating packages"
yum update -y >> /dev/null
echo "$BLANK- installing git"
yum install -y git >> /dev/null
echo "$BLANK- $(git --version) installed successfully"
fi
;;
esac

setup_docker

# get resources
echo "$INFO getting https://github.com/tinkerbell/tink for latest artifacts"
if [ -d tink ]; then
Expand All @@ -407,6 +408,18 @@ do_setup() {
git clone --single-branch -b master https://github.com/tinkerbell/tink
cd tink
fi
# TODO: verify if all required ports are available
}

do_setup() {
# perform some very rudimentary platform detection
lsb_dist=$( get_distribution )
lsb_dist="$(echo "$lsb_dist" | tr '[:upper:]' '[:lower:]')"

echo "$INFO starting tinkerbell stack setup"
check_prerequisites "$lsb_dist"
generate_envrc
source $ENV_FILE

# Run setup for each distro accordingly
case "$lsb_dist" in
Expand Down

0 comments on commit 0105667

Please sign in to comment.