Skip to content

Commit 1b86e80

Browse files
authored
NET-1180: fix install issue for latest debian and centos distributions (#2921)
* fix install issue for Ubunut Fedora Centos Debian latest version * fix install issue for rocky alma amazon suse latest version * fix install issue for redhat latest version and misc dpkg command issues * remove suse and add supported OS message * change wireguard-tools package name and remove FreeBSD etc in the list * add yum repo pacakge for centos8&7 * add sleep for nm-quick.sh to avoid failure
1 parent 86fac41 commit 1b86e80

File tree

1 file changed

+116
-15
lines changed

1 file changed

+116
-15
lines changed

scripts/nm-quick.sh

Lines changed: 116 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,11 @@ set_buildinfo() {
9191

9292
# install_yq - install yq if not present
9393
install_yq() {
94-
if ! command -v yq &>/dev/null; then
95-
wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.31.1/yq_linux_$(dpkg --print-architecture)
96-
chmod +x /usr/bin/yq
94+
if [ -f /etc/debian_version ]; then
95+
if ! command -v yq &>/dev/null; then
96+
wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.31.1/yq_linux_$(dpkg --print-architecture)
97+
chmod +x /usr/bin/yq
98+
fi
9799
fi
98100
set +e
99101
if ! command -v yq &>/dev/null; then
@@ -122,6 +124,7 @@ setup_netclient() {
122124
chmod +x netclient
123125
./netclient install
124126
echo "Register token: $TOKEN"
127+
sleep 2
125128
netclient register -t $TOKEN
126129

127130
echo "waiting for netclient to become available"
@@ -143,7 +146,7 @@ setup_netclient() {
143146

144147
# configure_netclient - configures server's netclient as a default host and an ingress gateway
145148
configure_netclient() {
146-
149+
sleep 2
147150
NODE_ID=$(sudo cat /etc/netclient/nodes.yml | yq -r .netmaker.commonnode.id)
148151
if [ "$NODE_ID" = "" ] || [ "$NODE_ID" = "null" ]; then
149152
echo "Error obtaining NODE_ID for the new network"
@@ -298,24 +301,28 @@ install_dependencies() {
298301

299302
OS=$(uname)
300303
if [ -f /etc/debian_version ]; then
301-
dependencies="git wireguard wireguard-tools dnsutils jq docker.io docker-compose grep gawk"
304+
dependencies="git wireguard-tools dnsutils jq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin grep gawk"
302305
update_cmd='apt update'
303306
install_cmd='apt-get install -y'
304307
elif [ -f /etc/alpine-release ]; then
305308
dependencies="git wireguard jq docker.io docker-compose grep gawk"
306309
update_cmd='apk update'
307310
install_cmd='apk --update add'
308311
elif [ -f /etc/centos-release ]; then
309-
dependencies="git wireguard jq bind-utils docker.io docker-compose grep gawk"
310-
update_cmd='yum update'
312+
dependencies="wget git wireguard-tools jq bind-utils docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin grep gawk"
313+
update_cmd='yum updateinfo'
314+
install_cmd='yum install -y'
315+
elif [ -f /etc/amazon-linux-release ]; then
316+
dependencies="git wireguard-tools bind-utils jq docker grep gawk"
317+
update_cmd='yum updateinfo'
311318
install_cmd='yum install -y'
312319
elif [ -f /etc/fedora-release ]; then
313-
dependencies="git wireguard bind-utils jq docker.io docker-compose grep gawk"
314-
update_cmd='dnf update'
320+
dependencies="wget git wireguard-tools bind-utils jq docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin grep gawk"
321+
update_cmd='dnf updateinfo'
315322
install_cmd='dnf install -y'
316323
elif [ -f /etc/redhat-release ]; then
317-
dependencies="git wireguard jq docker.io bind-utils docker-compose grep gawk"
318-
update_cmd='yum update'
324+
dependencies="wget git wireguard-tools jq bind-utils docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin grep gawk"
325+
update_cmd='yum updateinfo'
319326
install_cmd='yum install -y'
320327
elif [ -f /etc/arch-release ]; then
321328
dependencies="git wireguard-tools dnsutils jq docker.io docker-compose grep gawk"
@@ -326,7 +333,20 @@ install_dependencies() {
326333
update_cmd='pkg update'
327334
install_cmd='pkg install -y'
328335
else
329-
install_cmd=''
336+
echo "-----------------------nm-quick.sh----------------------------------------------"
337+
echo "OS supported and tested include:"
338+
echo " Debian"
339+
echo " Ubuntu"
340+
echo " Fedora"
341+
echo " Centos"
342+
echo " Redhat"
343+
echo " Amazon Linux"
344+
echo " Rocky Linux"
345+
echo " AlmaLinux"
346+
347+
echo "Your OS system is not in the support list, please chanage to an OS in the list"
348+
echo "--------------------------------------------------------------------------------"
349+
exit 1
330350
fi
331351

332352
if [ -z "${install_cmd}" ]; then
@@ -345,6 +365,50 @@ install_dependencies() {
345365
echo "Unsupported architechure"
346366
# exit 1
347367
fi
368+
369+
# setup docker repository
370+
if [ "$(cat /etc/*-release |grep ubuntu |wc -l)" -gt 0 ]; then
371+
apt update
372+
apt install -y ca-certificates curl
373+
install -m 0755 -d /etc/apt/keyrings
374+
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
375+
chmod a+r /etc/apt/keyrings/docker.asc
376+
echo \
377+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
378+
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
379+
tee /etc/apt/sources.list.d/docker.list > /dev/null
380+
apt update
381+
elif [ "$(cat /etc/*-release |grep debian |wc -l)" -gt 0 ]; then
382+
apt update
383+
apt install -y ca-certificates curl
384+
install -m 0755 -d /etc/apt/keyrings
385+
curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
386+
chmod a+r /etc/apt/keyrings/docker.asc
387+
echo \
388+
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
389+
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
390+
tee /etc/apt/sources.list.d/docker.list > /dev/null
391+
apt update
392+
elif [ -f /etc/fedora-release ]; then
393+
dnf -y install dnf-plugins-core
394+
dnf config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo
395+
elif [ -f /etc/centos-release ]; then
396+
yum install -y yum-utils
397+
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
398+
if [ "$(cat /etc/*-release |grep 'release 8' |wc -l)" -gt 0 ]; then
399+
yum install -y elrepo-release epel-release
400+
elif [ "$(cat /etc/*-release |grep 'release 7' |wc -l)" -gt 0 ]; then
401+
yum install -y elrepo-release epel-release
402+
yum install -y yum-plugin-elrepo
403+
fi
404+
elif [ -f /etc/redhat-release ]; then
405+
yum install -y yum-utils
406+
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
407+
if [ "$(cat /etc/*-release |grep 'release 8' |wc -l)" -gt 0 ]; then
408+
yum install -y elrepo-release epel-release
409+
fi
410+
fi
411+
348412
set -- $dependencies
349413

350414
${update_cmd}
@@ -371,8 +435,10 @@ install_dependencies() {
371435
else
372436
if [ "${OS}" = "OpenWRT" ] || [ "${OS}" = "TurrisOS" ]; then
373437
is_installed=$(opkg list-installed $1 | grep $1)
374-
else
438+
elif [ -f /etc/debian_version ]; then
375439
is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed")
440+
else
441+
is_installed=$(yum list installed | grep $1)
376442
fi
377443
if [ "${is_installed}" != "" ]; then
378444
echo " " $1 is installed
@@ -382,8 +448,10 @@ install_dependencies() {
382448
sleep 5
383449
if [ "${OS}" = "OpenWRT" ] || [ "${OS}" = "TurrisOS" ]; then
384450
is_installed=$(opkg list-installed $1 | grep $1)
385-
else
451+
elif [ -f /etc/debian_version ]; then
386452
is_installed=$(dpkg-query -W --showformat='${Status}\n' $1 | grep "install ok installed")
453+
else
454+
is_installed=$(yum list installed | grep $1)
387455
fi
388456
if [ "${is_installed}" != "" ]; then
389457
echo " " $1 is installed
@@ -398,6 +466,27 @@ install_dependencies() {
398466
shift
399467
done
400468

469+
# Startup docker daemon for OS which does not start it automatically
470+
if [ -f /etc/fedora-release ]; then
471+
systemctl start docker
472+
systemctl enable docker
473+
elif [ -f /etc/amazon-linux-release ]; then
474+
systemctl start docker
475+
systemctl enable docker
476+
usermod -a -G docker ec2-user
477+
mkdir -p /usr/local/lib/docker/cli-plugins
478+
curl -sL https://github.com/docker/compose/releases/latest/download/docker-compose-linux-$(uname -m) \
479+
-o /usr/local/lib/docker/cli-plugins/docker-compose
480+
chown root:root /usr/local/lib/docker/cli-plugins/docker-compose
481+
chmod +x /usr/local/lib/docker/cli-plugins/docker-compose
482+
elif [ -f /etc/centos-release ]; then
483+
systemctl start docker
484+
systemctl enable docker
485+
elif [ -f /etc/redhat-release ]; then
486+
systemctl start docker
487+
systemctl enable docker
488+
fi
489+
401490
echo "-----------------------------------------------------"
402491
echo "dependency check complete"
403492
echo "-----------------------------------------------------"
@@ -582,7 +671,19 @@ install_netmaker() {
582671

583672
# start docker and rebuild containers / networks
584673
cd "${SCRIPT_DIR}"
585-
docker-compose up -d --force-recreate
674+
if [ -f /etc/debian_version ]; then
675+
docker compose up -d --force-recreate
676+
elif [ -f /etc/fedora-release ]; then
677+
docker compose up -d --force-recreate
678+
elif [ -f /etc/amazon-linux-release ]; then
679+
docker compose up -d --force-recreate
680+
elif [ -f /etc/centos-release ]; then
681+
docker compose up -d --force-recreate
682+
elif [ -f /etc/redhat-release ]; then
683+
docker compose up -d --force-recreate
684+
else
685+
docker-compose up -d --force-recreate
686+
fi
586687
cd -
587688
wait_seconds 2
588689

0 commit comments

Comments
 (0)