-
Notifications
You must be signed in to change notification settings - Fork 276
/
Copy pathpostinstall.sh
executable file
·40 lines (31 loc) · 1.18 KB
/
postinstall.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
#!/bin/sh
# this post install script is used for setting up the clab_admins group and to count the number of installations of containerlab
# when the installation is done via apt or yum package manager
# exit if sh shell is not found
if [ ! -e /bin/sh ]; then
exit 0
fi
# exit if no /etc/apt/sources.list.d/netdevops.list or /etc/yum.repos.d/yum.fury.io_netdevops_.repo is found
if [ ! -e /etc/apt/sources.list.d/netdevops.list ] && [ ! -e /etc/yum.repos.d/yum.fury.io_netdevops_.repo ]; then
exit 0
fi
# run `containerlab version` and parse the version from the output
version=$(containerlab version | awk '/version:/{print $2}')
if [ -z "$version" ]; then
exit 0
fi
# prefixed with v
rel_version=v${version}
REPO_URL="https://github.com/srl-labs/containerlab/releases/download/${rel_version}/checksums.txt"
if type "curl" > /dev/null 2>&1; then
curl --max-time 2 -sL -o /dev/null "$REPO_URL" || true
exit 0
elif type "wget" > /dev/null 2>&1; then
wget -T 2 -q -O /dev/null "$REPO_URL" || true
exit 0
fi
if [ ! -f /etc/containerlab/suid_setup_done ]; then
groupadd -r clab_admins
usermod -aG clab_admins "$SUDO_USER"
touch /etc/containerlab/suid_setup_done
fi