-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy path0_install_host_tooling.sh
executable file
·53 lines (45 loc) · 1.98 KB
/
0_install_host_tooling.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/bash
set -euo pipefail
# Detect the package manager (apt or yum/dnf)
if command -v apt &> /dev/null; then
PM="apt"
elif command -v yum &> /dev/null || command -v dnf &> /dev/null; then
PM=$(command -v dnf || echo yum) # Use dnf if available, fallback to yum
else
echo "Unsupported package manager. Only apt, yum, and dnf are supported."
exit 1
fi
echo "--- Running setup for Linux ---"
# Run package manager-specific commands
#if [[ $PM == "apt" ]]; then
# sudo apt update
# sudo apt install -y python3-venv net-tools snmp curl ca-certificates
#else
# sudo $PM install -y python3-venv net-tools snmp curl ca-certificates
#fi
# Install Docker
echo "--- Installing Docker ---"
if [[ $PM == "apt" ]]; then
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /usr/share/keyrings/docker-archive-keyring.gpg > /dev/null
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
else
sudo $PM install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo $PM install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
fi
# Start Docker
sudo systemctl enable docker
sudo systemctl start docker
# Install ContainerLab
echo "--- Installing ContainerLab ---"
curl -sL https://containerlab.dev/setup | sudo -E bash -s "install-containerlab"
# Creating new user and adding to the correct groups, and set the permissions on the cloned repo
USERNAME="quickstart"
sudo useradd -m -d "$(pwd)" -s /bin/bash ${USERNAME}
sudo passwd -d ${USERNAME}
sudo usermod -aG sudo ${USERNAME}
sudo usermod -aG docker ${USERNAME}
sudo chown -R ${USERNAME}:${USERNAME} .
echo "--- Setup Complete ---"