From 519b2c760f8ebe0f1dd5ac77d8a46c2958761ada Mon Sep 17 00:00:00 2001 From: "b.waal" Date: Tue, 17 Mar 2020 12:29:19 +0100 Subject: [PATCH] Whiptail & MSG alignment, curl flags, debconf-selection Aligned text for Whiptail and MSG, changed the sizing of some Whiptail windows, added --Silent --Show-Error flags for CURL, removed some unnecessary spaces after lines, added DebConf selection for libssl1.1. --- installer.sh | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/installer.sh b/installer.sh index 3941a45..b65f3c5 100644 --- a/installer.sh +++ b/installer.sh @@ -36,6 +36,7 @@ TestMode=0 PKGA="add-apt-repository" PKGI="${PKGM} install -y" OUTPUT='/dev/null' +debconf-set-selections <<< 'libssl1.1:amd64 libraries/restart-without-asking boolean true' ##-------------## @@ -72,32 +73,32 @@ if [ -z $passdiaone ]; then PasswordQuest; fi if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then PasswordCheck else - whiptail --ok-button Done --msgbox "Password is invalid!" 10 30 && PasswordQuest + whiptail --ok-button Done --msgbox " Password is invalid!" 10 30 && PasswordQuest fi } function PasswordCheck { #Checking password -passdiatwo=$(whiptail --nocancel --passwordbox "Please re-enter your password" 11 82 --title "Config" 3>&1 1>&2 2>&3) +passdiatwo=$(whiptail --nocancel --passwordbox " Please re-enter your password" 11 82 --title "Config" 3>&1 1>&2 2>&3) if [ -z $passdiatwo ]; then PasswordCheck; else -if [ $passdiaone != $passdiatwo ]; then whiptail --ok-button Done --msgbox "Password does not match!" 10 30 && PasswordQuest;else password="$passdiaone"; unset passdiaone passdiatwo; fi +if [ $passdiaone != $passdiatwo ]; then whiptail --ok-button Done --msgbox " Password does not match!" 10 30 && PasswordQuest;else password="$passdiaone"; unset passdiaone passdiatwo; fi fi password="$passdiatwo" } function LegacyPasswordQuest { -echo "Enter password (Requires: 8 chars, 1 capital and 1 num)" +echo "Enter password (Requires: 8 chars, 1 capital and 1 num)" read -s passdiaone if [ -z $passdiaone ]; then PasswordQuest; fi if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then LegacyPasswordCheck else - echo "Password is invalid!" 10 30 && LegacyPasswordQuest + echo " Password is invalid!" 10 30 && LegacyPasswordQuest fi } function LegacyPasswordCheck { #Checking password -echo "Please re-enter your password" +echo "Please re-enter your password" read -s passdiatwo if [ -z $passdiatwo ]; then LegacyPasswordCheck; else if [ $passdiaone != $passdiatwo ]; then echo "Password does not match!" && LegacyPasswordQuest; password="$passdiaone"; unset passdiaone passdiatwo; fi @@ -110,7 +111,7 @@ password="$passdiatwo" # Installer-Requirements # ##--------------------------## -msg "Starting installer." 8 78 +msg " Starting installer" 8 78 $PKGM update > $OUTPUT 2>&1 $PKGI curl > $OUTPUT 2>&1 @@ -122,24 +123,24 @@ $PKGI curl > $OUTPUT 2>&1 if [ $IMODE = n ]; then if [ $TestMode = 0 ]; then domain=$(whiptail --nocancel --inputbox " Enter the domain without WWW " 11 82 --title "Config" 3>&1 1>&2 2>&3) -if (whiptail --title "Config" --yesno "Does www.${domain} exist in DNS" 8 78); then domainwww=1; else domainwww=0; fi -if (whiptail --title "Config" --yesno "Hostname with nxdi.nl" 11 82); then +if (whiptail --title "Config" --yesno " Does www.${domain} exist in DNS" 8 78); then domainwww=1; else domainwww=0; fi +if (whiptail --title "Config" --yesno " Hostname with nxdi.nl" 11 78); then hostname=$(whiptail --nocancel --inputbox " SystemID (eg: VCH001) without ".nxdi.nl" " 11 82 --title "Config" 3>&1 1>&2 2>&3) hostname=$hostname".nxdi.nl" else - hostname=$(whiptail --nocancel --inputbox " Hostname " 11 82 --title "Config" 3>&1 1>&2 2>&3) + hostname=$(whiptail --nocancel --inputbox " Hostname" 11 78 --title "Config" 3>&1 1>&2 2>&3) fi -if (whiptail --title "Config" --yesno "Enable SSL on installation?" 11 82); then +if (whiptail --title "Config" --yesno " Enable SSL on installation?" 11 78); then sslenable=1 else sslenable=0 fi PasswordQuest -email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 82 --title "Config" 3>&1 1>&2 2>&3) +email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 78 --title "Config" 3>&1 1>&2 2>&3) fi webserv=$(whiptail --title "Select Webserver" --radiolist "WebServer" 11 53 5 "Nginx:" "Will install NGINX Webserver." ON "Apache:" "Will install Apache Webserver." OFF 3>&1 1>&2 2>&3) esws=$? -[[ "$esws" = 1 ]] && msg "Quiting installer." 8 78 && exit; +[[ "$esws" = 1 ]] && msg " Quiting installer" 8 78 && exit; fi if [ $IMODE = l ]; then @@ -210,11 +211,11 @@ fi webserv="${webserv//:}" && webserv="${webserv,,}" echo "Generating apt list for Generic" -curl "$repo"/raw/branch/"$branch"/CoreModules/generic/apt.list >>/tmp/apt.list +curl --silent --show-error "$repo"/raw/branch/"$branch"/CoreModules/generic/apt.list >>/tmp/apt.list printf " " >>/tmp/apt.list echo "Generating apt list for Webserver" -curl "$repo"/raw/branch/"$branch"/CoreModules/"$webserv"/apt.list >>/tmp/apt.list +curl --silent --show-error "$repo"/raw/branch/"$branch"/CoreModules/"$webserv"/apt.list >>/tmp/apt.list printf " " >>/tmp/apt.list @@ -310,12 +311,12 @@ done fi fi -#Cleaning options from menu +#Cleaning options from menu option="${option,,}" && option="${option// /}" #Always on option modules option="$option /MySQL/" option="$option /Unattended-Security-Updates/" -#Cleaning all options +#Cleaning all options option="${option/:/ }" && option="${option//:}" && option="${option//'"'}" echo "Generating apt list for Options" @@ -323,7 +324,7 @@ for val1 in ${option[*]}; do echo "$val1" #TMP modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1") #Checking - if test -z "$modListed" + if test -z "$modListed" then #Fetching from local repo if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/SubModules/"$val1"/apt.list; then @@ -375,14 +376,12 @@ break;; "None") CMS=None: break;; - *) echo "$REPLY is not a valid option!";; esac done fi CMS="${CMS//:}" && CMS="${CMS,,}" - echo "Generating Apt List for CMS" if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/CMS/"$CMS"/apt.list >>/tmp/apt.list; then @@ -401,9 +400,8 @@ fi # Pre-Requirements # ##--------------------## +msg " Preconfiguring" sed -i '/Port 22/c\Port 4242' /etc/ssh/sshd_config - -msg "Preconfiguring." $PKGI software-properties-common gnupg > $OUTPUT 2>&1 $PKGA universe -y > $OUTPUT 2>&1 $PKGA ppa:ondrej/php -y > $OUTPUT 2>&1 @@ -430,7 +428,7 @@ for val1 in ${option[*]}; do echo "$val1" #TMP modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1") #Checking - if test -z "$modListed" + if test -z "$modListed" then #Fetching from local repo if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/SubModules/"$val1"/preconf.sh; then @@ -450,6 +448,7 @@ for val1 in ${option[*]}; do fi done + echo "Running preconf for CMS" if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/CMS/"$CMS"/preconf.sh; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/CMS/"$CMS"/preconf.sh) @@ -506,13 +505,14 @@ for val1 in ${option[*]}; do fi done + echo "Setting up SSL" if [ $sslenable = 1 ]; then if [ $domainwww = 1 ]; then certbot --"$webserv" -n -d "$domain" -d "www.$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos elif [ $domainwww = 0 ]; then certbot --"$webserv" -n -d "$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos -fi +fi certbot --"$webserv" -n -d "$hostname" -m "$email" --hsts --redirect --no-eff-email --agree-tos fi @@ -522,13 +522,10 @@ sed -i -e 's/DOMAINname/'$domain'/' -e 's/CONFname/'$domain'/' -e 's/DomainWWW/' wget -q -t7 "$repo"/raw/branch/"$branch"/Scripts/EnableSSL.sh -O ~/activateSSL-Backend.sh sed -i -e 's/DOMAINname/'$hostname'/' -e 's/CONFname/'Backend'/' -e 's/DomainWWW/'0'/' -e 's/Email/'$email'/' -e 's/WebServer/'$webserv'/' ~/activateSSL-Backend.sh - echo "Running conf for CMS" - if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/CMS/"$CMS"/conf.sh; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/CMS/"$CMS"/conf.sh) fi - if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh; then source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh) fi