From 4f9c175355c6137a07b04d1434dfb97e54e69466 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Thu, 11 Aug 2022 17:42:28 +0100 Subject: [PATCH 01/12] A few suggestions that might help improve/extend OS detection/support install more of the dependencies - curl and wget were missing --- install.sh | 97 ++++++++++++++++++++++++++++++++++++------- linuxclientinstall.sh | 65 ++++++++++++++++++++++++----- update.sh | 60 ++++++++++++++++++++++---- 3 files changed, 188 insertions(+), 34 deletions(-) diff --git a/install.sh b/install.sh index 35c04e0..9be99f8 100644 --- a/install.sh +++ b/install.sh @@ -17,26 +17,95 @@ break "DNS/Domain") echo -ne "Enter your preferred domain/dns address ${NC}: " read wanip +#check wanip is valid domain +if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then + echo -e "${RED}Invalid domain/dns address${NC}" + exit 1 +fi break ;; *) echo "invalid option $REPLY";; esac done -# Setup prereqs for server -if [[ $(which yum) ]]; then - sudo yum install unzip -y - sudo yum install bind-utils -y - sudo yum install tar -y -elif [[ $(which apt) ]]; then - sudo apt-get update - sudo apt-get install unzip -y - sudo apt-get install dnsutils -y - sudo apt-get install tar -y +# identify OS +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID + IDLIKE=$ID_LIKE +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE +elif [ -f /etc/debian_version ]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) +elif [ -f /etc/SuSe-release ]; then + # Older SuSE/etc. + OS=SuSE + VER=$(cat /etc/SuSe-release) +elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + OS=RedHat + VER=$(cat /etc/redhat-release) else - echo "Unknown Platform, the install might fail" + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) fi +# Setup prereqs for server +# common named prereqs +prereq="curl wget unzip tar" +echo "Installing prerequisites" +if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ]; then + prereq+=" dnsutils" + apt-get update + apt-get install -y "${prereq}" # git +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then + prereq+=" bind-utils" + yum update -y + yum install -y "${prereq}" # git +else + echo "Unsupported OS" + # here you could ask the user for permission to try and install anyway + # if they say yes, then do the install + # if they say no, exit the script + exit 1 +fi + +# #/* +# Alternatively since case is faster than if then else +# case ${IDLIKE} in +# ubuntu|debian) +# # Debian/Ubuntu/etc. +# sudo apt-get update +# sudo apt-get install -y curl wget unzip dnsutils tar # git +# ;; +# centos|fedora|redhat) #|amazon) +# # CentOS/RedHat/Fedora/Amazon/etc. +# sudo yum update -y +# sudo yum install -y curl wget unzip bind-utils tar # git +# ;; +# *) +# echo "Unsupported OS" +# echo "Unknown Platform, the install might fail" +# # here you could ask the user for permission to try and install anyway +# # if they say yes, then do the install +# # if they say no, exit the script +# exit 1 +# ;; +# esac +# */ + # Make Folder /opt/rustdesk/ if [ ! -d "/opt/rustdesk" ]; then echo "Creating /opt/rustdesk" @@ -116,14 +185,14 @@ done pubname=$(find /opt/rustdesk -name *.pub) key=$(cat "${pubname}") -sudo rm rustdesk-server-linux-x64.zip +rm rustdesk-server-linux-x64.zip -# Create windows install script +# Create windows install script wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/WindowsAgentAIOInstall.ps1 sudo sed -i "s|wanipreg|${wanip}|g" WindowsAgentAIOInstall.ps1 sudo sed -i "s|keyreg|${key}|g" WindowsAgentAIOInstall.ps1 -# Create linux install script +# Create linux install script wget https://raw.githubusercontent.com/dinger1986/rustdeskinstall/master/linuxclientinstall.sh sudo sed -i "s|wanipreg|${wanip}|g" linuxclientinstall.sh sudo sed -i "s|keyreg|${key}|g" linuxclientinstall.sh diff --git a/linuxclientinstall.sh b/linuxclientinstall.sh index 386d1e3..a0f2d0d 100644 --- a/linuxclientinstall.sh +++ b/linuxclientinstall.sh @@ -3,17 +3,60 @@ uname=$(whoami) admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c8) -# Install Rustdesk -if [[ $(which yum) ]]; then - wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.rpm - sudo yum localinstall ./rustdesk-1.1.9.rpm -elif [[ $(which apt) ]]; then - wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.deb - sudo apt install -fy ./rustdesk-1.1.9.deb + +# identify OS +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID + IDLIKE=$ID_LIKE +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE +elif [ -f /etc/debian_version ]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) +elif [ -f /etc/SuSe-release ]; then + # Older SuSE/etc. + OS=SuSE + VER=$(cat /etc/SuSe-release) +elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + OS=RedHat + VER=$(cat /etc/redhat-release) else - echo "Unknown Platform, the install will fail" - exit -fi + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) + +# Install Rustdesk +case ${OS,,} in + # or case ${IDLIKE,,} in .. to support derivatives + ubuntu|debian) + # Debian/Ubuntu/etc. + wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.deb + sudo apt install -fy ./rustdesk-1.1.9.deb + ;; + fedora|centos|redhat|amazon) + # Red Hat, CentOS, etc. + + wget https://github.com/rustdesk/rustdesk/releases/download/1.1.9/rustdesk-1.1.9.rpm + sudo yum localinstall ./rustdesk-1.1.9.rpm + # sudo dnf install -y ./rustdesk-1.1.9.rpm + ;; + *) + echo "Unsupported OS" + exit 1 + ;; +esac rustdesk --password ${admintoken} pkill -f "rustdesk" @@ -50,7 +93,7 @@ EOF )" echo "${rustdesktoml2b}" | sudo tee /root/.config/rustdesk/RustDesk2.toml > /dev/null -chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml +chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml systemctl restart rustdesk diff --git a/update.sh b/update.sh index cdccefb..88f1f22 100644 --- a/update.sh +++ b/update.sh @@ -8,16 +8,58 @@ sudo systemctl stop rustdesksignal.service sudo systemctl stop rustdeskrelay.service -# Setup prereqs for server -if [[ $(which yum) ]]; then - sudo yum install unzip -y - sudo yum install bind-utils -y -elif [[ $(which apt) ]]; then - sudo apt-get update - sudo apt-get install unzip -y - sudo apt-get install dnsutils -y +# identify OS +if [ -f /etc/os-release ]; then + # freedesktop.org and systemd + . /etc/os-release + OS=$NAME + VER=$VERSION_ID + IDLIKE=$ID_LIKE +elif type lsb_release >/dev/null 2>&1; then + # linuxbase.org + OS=$(lsb_release -si) + VER=$(lsb_release -sr) +elif [ -f /etc/lsb-release ]; then + # For some versions of Debian/Ubuntu without lsb_release command + . /etc/lsb-release + OS=$DISTRIB_ID + VER=$DISTRIB_RELEASE +elif [ -f /etc/debian_version ]; then + # Older Debian/Ubuntu/etc. + OS=Debian + VER=$(cat /etc/debian_version) +elif [ -f /etc/SuSe-release ]; then + # Older SuSE/etc. + OS=SuSE + VER=$(cat /etc/SuSe-release) +elif [ -f /etc/redhat-release ]; then + # Older Red Hat, CentOS, etc. + OS=RedHat + VER=$(cat /etc/redhat-release) else - echo "Unknown Platform, the install might fail" + # Fall back to uname, e.g. "Linux ", also works for BSD, etc. + OS=$(uname -s) + VER=$(uname -r) +fi + +# Setup prereqs for server +# common named prereqs +prereq="curl wget unzip tar" +echo "Installing prerequisites" +if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ]; then + prereq+=" dnsutils" + apt-get update + apt-get install -y "${prereq}" # git +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then + prereq+=" bind-utils" + yum update -y + yum install -y "${prereq}" # git +else + echo "Unsupported OS" + # here you could ask the user for permission to try and install anyway + # if they say yes, then do the install + # if they say no, exit the script + exit 1 fi cd /opt/rustdesk/ From cf592f34c3317b1294676250d25cc6423be26131 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Thu, 11 Aug 2022 18:28:00 +0100 Subject: [PATCH 02/12] some typos and sudos removed --- install.sh | 8 ++++---- linuxclientinstall.sh | 3 ++- update.sh | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 9be99f8..49dbce7 100644 --- a/install.sh +++ b/install.sh @@ -112,11 +112,11 @@ if [ ! -d "/opt/rustdesk" ]; then sudo mkdir -p /opt/rustdesk/ fi sudo chown "${uname}" -R /opt/rustdesk -cd /opt/rustdesk/ +cd /opt/rustdesk/ || exit 1 #Download latest version of Rustdesk RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') -sudo wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip" +wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip" unzip rustdesk-server-linux-x64.zip # Make Folder /var/log/rustdesk/ @@ -207,7 +207,7 @@ fi sudo chown "${uname}" -R /opt/gohttp cd /opt/gohttp GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') -sudo wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" +wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz # Copy Rustdesk install scripts to folder @@ -221,7 +221,7 @@ if [ ! -d "/var/log/gohttp" ]; then fi sudo chown "${uname}" -R /var/log/gohttp/ -sudo rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz +rm gohttpserver_"${GOHTTPLATEST}"_linux_amd64.tar.gz # Setup Systemd to launch Go HTTP Server gohttpserver="$(cat << EOF diff --git a/linuxclientinstall.sh b/linuxclientinstall.sh index a0f2d0d..23ca03a 100644 --- a/linuxclientinstall.sh +++ b/linuxclientinstall.sh @@ -36,6 +36,7 @@ else # Fall back to uname, e.g. "Linux ", also works for BSD, etc. OS=$(uname -s) VER=$(uname -r) +fi # Install Rustdesk case ${OS,,} in @@ -98,7 +99,7 @@ chown ${uname}:${uname} /home/${uname}/.config/rustdesk/RustDesk2.toml systemctl restart rustdesk -echo "ID & Password for Rustdesk $(uname} are:" +echo "ID & Password for Rustdesk ${uname} are:" grep -w id /home/${uname}/.config/rustdesk/RustDesk.toml grep -w password /home/${uname}/.config/rustdesk/RustDesk.toml diff --git a/update.sh b/update.sh index 88f1f22..83fe47b 100644 --- a/update.sh +++ b/update.sh @@ -1,7 +1,7 @@ #!/bin/bash # Get Username -uname=$(whoami) +uname=$(whoami) # not used btw .. yet sudo systemctl stop gohttpserver.service sudo systemctl stop rustdesksignal.service @@ -68,7 +68,7 @@ cd /opt/rustdesk/ rm hbbs rm hbbs RDLATEST=$(curl https://api.github.com/repos/rustdesk/rustdesk-server/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') -sudo wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip" +wget "https://github.com/rustdesk/rustdesk-server/releases/download/${RDLATEST}/rustdesk-server-linux-x64.zip" unzip rustdesk-server-linux-x64.zip sudo systemctl start rustdesksignal.service @@ -80,14 +80,14 @@ while ! [[ $CHECK_RUSTDESK_READY ]]; do sleep 3 done -sudo rm rustdesk-server-linux-x64.zip +rm rustdesk-server-linux-x64.zip cd /opt/gohttp GOHTTPLATEST=$(curl https://api.github.com/repos/codeskyblue/gohttpserver/releases/latest -s | grep "tag_name"| awk '{print substr($2, 2, length($2)-3) }') -sudo wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" +wget "https://github.com/codeskyblue/gohttpserver/releases/download/${GOHTTPLATEST}/gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz" tar -xf gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz -sudo rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz +rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz sudo systemctl start gohttpserver.service From 303c19668a70a9ed16717c8460ba8ebdab57d29d Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Fri, 12 Aug 2022 00:55:04 +0100 Subject: [PATCH 03/12] Some tweaks tested and working on ZorinOS and Pop! --- install.sh | 31 ++++++++++++++++++++++++------- update.sh | 27 +++++++++++++++++++++------ 2 files changed, 45 insertions(+), 13 deletions(-) diff --git a/install.sh b/install.sh index 49dbce7..3f7e060 100644 --- a/install.sh +++ b/install.sh @@ -34,7 +34,15 @@ if [ -f /etc/os-release ]; then . /etc/os-release OS=$NAME VER=$VERSION_ID - IDLIKE=$ID_LIKE + + UPSTREAM_ID=${ID_LIKE,,} + + # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' + if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then + UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" + fi + + elif type lsb_release >/dev/null 2>&1; then # linuxbase.org OS=$(lsb_release -si) @@ -62,18 +70,27 @@ else VER=$(uname -r) fi + +# output ebugging info if $DEBUG set +if [ "$DEBUG" = "true" ]; then + echo "OS: $OS" + echo "VER: $VER" + echo "UPSTREAM_ID: $UPSTREAM_ID" + exit 0 +fi + # Setup prereqs for server # common named prereqs prereq="curl wget unzip tar" echo "Installing prerequisites" -if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ]; then +if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then prereq+=" dnsutils" - apt-get update - apt-get install -y "${prereq}" # git + sudo apt-get update + sudo apt-get install -y "${prereq}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then prereq+=" bind-utils" - yum update -y - yum install -y "${prereq}" # git + sudo yum update -y + sudo yum install -y "${prereq}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway @@ -182,7 +199,7 @@ while ! [[ $CHECK_RUSTDESK_READY ]]; do sleep 3 done -pubname=$(find /opt/rustdesk -name *.pub) +pubname=$(find /opt/rustdesk -name "*.pub") key=$(cat "${pubname}") rm rustdesk-server-linux-x64.zip diff --git a/update.sh b/update.sh index 83fe47b..b64136d 100644 --- a/update.sh +++ b/update.sh @@ -14,7 +14,12 @@ if [ -f /etc/os-release ]; then . /etc/os-release OS=$NAME VER=$VERSION_ID - IDLIKE=$ID_LIKE + UPSTREAM_ID=${ID_LIKE,,} + # Fallback to ID_LIKE if ID was not 'ubuntu' or 'debian' + if [ "${UPSTREAM_ID}" != "debian" ] && [ "${UPSTREAM_ID}" != "ubuntu" ]; then + UPSTREAM_ID="$(echo ${ID_LIKE,,} | sed s/\"//g | cut -d' ' -f1)" + fi + elif type lsb_release >/dev/null 2>&1; then # linuxbase.org OS=$(lsb_release -si) @@ -42,18 +47,28 @@ else VER=$(uname -r) fi + +# output ebugging info if $DEBUG set +if [ "$DEBUG" = "true" ]; then + echo "OS: $OS" + echo "VER: $VER" + echo "UPSTREAM_ID: $UPSTREAM_ID" + exit 0 +fi + + # Setup prereqs for server # common named prereqs prereq="curl wget unzip tar" echo "Installing prerequisites" -if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ]; then +if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then prereq+=" dnsutils" - apt-get update - apt-get install -y "${prereq}" # git + sudo apt-get update + sudo apt-get install -y "${prereq}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then prereq+=" bind-utils" - yum update -y - yum install -y "${prereq}" # git + sudo yum update -y + sudo yum install -y "${prereq}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway From 91584fed551d5e0cd8c139d973f1de80557eacdc Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Fri, 12 Aug 2022 03:10:00 +0100 Subject: [PATCH 04/12] Now working on Debian too --- install.sh | 7 +++++-- update.sh | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index 3f7e060..c802226 100644 --- a/install.sh +++ b/install.sh @@ -83,11 +83,14 @@ fi # common named prereqs prereq="curl wget unzip tar" echo "Installing prerequisites" -if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then +if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then prereq+=" dnsutils" sudo apt-get update sudo apt-get install -y "${prereq}" # git -elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "redhat" ] ; then +# opensuse 15.4 fails to run the relay service and hangs waiting for it +# needs more work before it can be enabled +# || [ "${UPSTREAM_ID}" = "suse" ] prereq+=" bind-utils" sudo yum update -y sudo yum install -y "${prereq}" # git diff --git a/update.sh b/update.sh index b64136d..4827d65 100644 --- a/update.sh +++ b/update.sh @@ -61,7 +61,7 @@ fi # common named prereqs prereq="curl wget unzip tar" echo "Installing prerequisites" -if [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then +if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then prereq+=" dnsutils" sudo apt-get update sudo apt-get install -y "${prereq}" # git From f511867dc8d23692a005e481e6d7ca90cb9e67b6 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Fri, 12 Aug 2022 03:51:16 +0100 Subject: [PATCH 05/12] And working on centos-stream 9.0 --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index c802226..8bfcf6d 100644 --- a/install.sh +++ b/install.sh @@ -87,7 +87,7 @@ if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ prereq+=" dnsutils" sudo apt-get update sudo apt-get install -y "${prereq}" # git -elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "redhat" ] ; then +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then # opensuse 15.4 fails to run the relay service and hangs waiting for it # needs more work before it can be enabled # || [ "${UPSTREAM_ID}" = "suse" ] From 54944d2014ce23f68fb7ae41ae10cc1c16b2ebc1 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Fri, 12 Aug 2022 12:48:48 +0100 Subject: [PATCH 06/12] aligned to install for rhel derivatives --- update.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 4827d65..fcf75cb 100644 --- a/update.sh +++ b/update.sh @@ -65,7 +65,7 @@ if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ prereq+=" dnsutils" sudo apt-get update sudo apt-get install -y "${prereq}" # git -elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ]; then +elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ]; then prereq+=" bind-utils" sudo yum update -y sudo yum install -y "${prereq}" # git @@ -107,4 +107,3 @@ rm gohttpserver_${GOHTTPLATEST}_linux_amd64.tar.gz sudo systemctl start gohttpserver.service echo -e "Updates are complete" - From fc9a935121a5e4fb3def1764ff816688983ff7c2 Mon Sep 17 00:00:00 2001 From: Phil Clifford Date: Fri, 12 Aug 2022 12:55:47 +0100 Subject: [PATCH 07/12] conform case --- install.sh | 10 +++++----- update.sh | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/install.sh b/install.sh index 8bfcf6d..7ab4ca3 100644 --- a/install.sh +++ b/install.sh @@ -81,19 +81,19 @@ fi # Setup prereqs for server # common named prereqs -prereq="curl wget unzip tar" +PREREQ="curl wget unzip tar" echo "Installing prerequisites" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then - prereq+=" dnsutils" + PREREQ+=" dnsutils" sudo apt-get update - sudo apt-get install -y "${prereq}" # git + sudo apt-get install -y "${PREREQ}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then # opensuse 15.4 fails to run the relay service and hangs waiting for it # needs more work before it can be enabled # || [ "${UPSTREAM_ID}" = "suse" ] - prereq+=" bind-utils" + PREREQ+=" bind-utils" sudo yum update -y - sudo yum install -y "${prereq}" # git + sudo yum install -y "${PREREQ}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway diff --git a/update.sh b/update.sh index fcf75cb..a1b5ba7 100644 --- a/update.sh +++ b/update.sh @@ -59,16 +59,16 @@ fi # Setup prereqs for server # common named prereqs -prereq="curl wget unzip tar" +PREREQ="curl wget unzip tar" echo "Installing prerequisites" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then - prereq+=" dnsutils" + PREREQ+=" dnsutils" sudo apt-get update - sudo apt-get install -y "${prereq}" # git + sudo apt-get install -y "${PREREQ}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ]; then - prereq+=" bind-utils" + PREREQ+=" bind-utils" sudo yum update -y - sudo yum install -y "${prereq}" # git + sudo yum install -y "${PREREQ}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway From 4977bd764c219af52a358dae0330419f436fe141 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 12 Aug 2022 15:11:26 +0100 Subject: [PATCH 08/12] Update install.sh --- install.sh | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index 7ab4ca3..8152238 100644 --- a/install.sh +++ b/install.sh @@ -4,30 +4,6 @@ uname=$(whoami) admintoken=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c16) -# Choice for DNS or IP -PS3='Choose your preferred option, IP or DNS/Domain:' -WAN=("IP" "DNS/Domain") -select WANOPT in "${WAN[@]}"; do -case $WANOPT in -"IP") -wanip=$(dig @resolver4.opendns.com myip.opendns.com +short) -break -;; - -"DNS/Domain") -echo -ne "Enter your preferred domain/dns address ${NC}: " -read wanip -#check wanip is valid domain -if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then - echo -e "${RED}Invalid domain/dns address${NC}" - exit 1 -fi -break -;; -*) echo "invalid option $REPLY";; -esac -done - # identify OS if [ -f /etc/os-release ]; then # freedesktop.org and systemd @@ -102,6 +78,32 @@ else exit 1 fi +# Choice for DNS or IP +PS3='Choose your preferred option, IP or DNS/Domain:' +WAN=("IP" "DNS/Domain") +select WANOPT in "${WAN[@]}"; do +case $WANOPT in +"IP") +wanip=$(dig @resolver4.opendns.com myip.opendns.com +short) +break +;; + +"DNS/Domain") +echo -ne "Enter your preferred domain/dns address ${NC}: " +read wanip +#check wanip is valid domain +if ! [[ $wanip =~ ^[a-zA-Z0-9]+([a-zA-Z0-9.-]*[a-zA-Z0-9]+)?$ ]]; then + echo -e "${RED}Invalid domain/dns address${NC}" + exit 1 +fi +break +;; +*) echo "invalid option $REPLY";; +esac +done + + + # #/* # Alternatively since case is faster than if then else # case ${IDLIKE} in From 706bf581c55be3359d001a9773532d632bfed922 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 12 Aug 2022 15:17:47 +0100 Subject: [PATCH 09/12] Update install.sh --- install.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 8152238..7fa1947 100644 --- a/install.sh +++ b/install.sh @@ -57,12 +57,16 @@ fi # Setup prereqs for server # common named prereqs -PREREQ="curl wget unzip tar" +PREREQ1="curl" +PREREQ2="wget" +PREREQ3="unzip" +PREREQ4="tar" + echo "Installing prerequisites" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then PREREQ+=" dnsutils" sudo apt-get update - sudo apt-get install -y "${PREREQ}" # git + sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then # opensuse 15.4 fails to run the relay service and hangs waiting for it # needs more work before it can be enabled From dbd903976de64f6800c93d948ca555c312b3fae5 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 12 Aug 2022 15:20:17 +0100 Subject: [PATCH 10/12] Update install.sh --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index 7fa1947..e4dd067 100644 --- a/install.sh +++ b/install.sh @@ -61,19 +61,19 @@ PREREQ1="curl" PREREQ2="wget" PREREQ3="unzip" PREREQ4="tar" +PREREQDEB="dnsutils" +PREREQRPM="bind-utils" echo "Installing prerequisites" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then - PREREQ+=" dnsutils" sudo apt-get update - sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" # git + sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQDEB}" # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then # opensuse 15.4 fails to run the relay service and hangs waiting for it # needs more work before it can be enabled # || [ "${UPSTREAM_ID}" = "suse" ] - PREREQ+=" bind-utils" sudo yum update -y - sudo yum install -y "${PREREQ}" # git + sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQRPM}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway From 98e070f9ae534a9dbc94d38f6c7f29e9fe2677f3 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 12 Aug 2022 15:27:00 +0100 Subject: [PATCH 11/12] Update install.sh --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index e4dd067..60358ce 100644 --- a/install.sh +++ b/install.sh @@ -73,7 +73,7 @@ elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhe # needs more work before it can be enabled # || [ "${UPSTREAM_ID}" = "suse" ] sudo yum update -y - sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQRPM}" # git + sudo yum install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQRPM}" # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway From a0ab2f16f9362ad3e6c2fe293a05c346f22d4ca1 Mon Sep 17 00:00:00 2001 From: dinger1986 Date: Fri, 12 Aug 2022 15:29:22 +0100 Subject: [PATCH 12/12] Update install.sh --- install.sh | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 60358ce..d3c8e51 100644 --- a/install.sh +++ b/install.sh @@ -57,23 +57,20 @@ fi # Setup prereqs for server # common named prereqs -PREREQ1="curl" -PREREQ2="wget" -PREREQ3="unzip" -PREREQ4="tar" +PREREQ="curl wget unzip tar" PREREQDEB="dnsutils" PREREQRPM="bind-utils" echo "Installing prerequisites" if [ "${ID}" = "debian" ] || [ "$OS" = "Ubuntu" ] || [ "$OS" = "Debian" ] || [ "${UPSTREAM_ID}" = "ubuntu" ] || [ "${UPSTREAM_ID}" = "debian" ]; then sudo apt-get update - sudo apt-get install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQDEB}" # git + sudo apt-get install -y ${PREREQ} ${PREREQDEB} # git elif [ "$OS" = "CentOS" ] || [ "$OS" = "RedHat" ] || [ "${UPSTREAM_ID}" = "rhel" ] ; then # opensuse 15.4 fails to run the relay service and hangs waiting for it # needs more work before it can be enabled # || [ "${UPSTREAM_ID}" = "suse" ] sudo yum update -y - sudo yum install -y "${PREREQ1}" "${PREREQ2}" "${PREREQ3}" "${PREREQ4}" "${PREREQRPM}" # git + sudo yum install -y ${PREREQ} ${PREREQRPM} # git else echo "Unsupported OS" # here you could ask the user for permission to try and install anyway