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.
This commit is contained in:
b.waal
2020-03-17 12:29:19 +01:00
parent d41a093233
commit 519b2c760f

View File

@@ -36,6 +36,7 @@ TestMode=0
PKGA="add-apt-repository" PKGA="add-apt-repository"
PKGI="${PKGM} install -y" PKGI="${PKGM} install -y"
OUTPUT='/dev/null' 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 if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
PasswordCheck PasswordCheck
else else
whiptail --ok-button Done --msgbox "Password is invalid!" 10 30 && PasswordQuest whiptail --ok-button Done --msgbox " Password is invalid!" 10 30 && PasswordQuest
fi fi
} }
function PasswordCheck { function PasswordCheck {
#Checking password #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 [ -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 fi
password="$passdiatwo" password="$passdiatwo"
} }
function LegacyPasswordQuest { 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 read -s passdiaone
if [ -z $passdiaone ]; then PasswordQuest; fi if [ -z $passdiaone ]; then PasswordQuest; fi
if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then if [[ ${#passdiaone} -ge 8 && "$passdiaone" == *[[:lower:]]* && "$passdiaone" == *[[:upper:]]* && "$passdiaone" == *[0-9]* && "$passdiaone" == *['!'@#%^\&*()_+]* ]]; then
LegacyPasswordCheck LegacyPasswordCheck
else else
echo "Password is invalid!" 10 30 && LegacyPasswordQuest echo " Password is invalid!" 10 30 && LegacyPasswordQuest
fi fi
} }
function LegacyPasswordCheck { function LegacyPasswordCheck {
#Checking password #Checking password
echo "Please re-enter your password" echo "Please re-enter your password"
read -s passdiatwo read -s passdiatwo
if [ -z $passdiatwo ]; then LegacyPasswordCheck; else if [ -z $passdiatwo ]; then LegacyPasswordCheck; else
if [ $passdiaone != $passdiatwo ]; then echo "Password does not match!" && LegacyPasswordQuest; password="$passdiaone"; unset passdiaone passdiatwo; fi if [ $passdiaone != $passdiatwo ]; then echo "Password does not match!" && LegacyPasswordQuest; password="$passdiaone"; unset passdiaone passdiatwo; fi
@@ -110,7 +111,7 @@ password="$passdiatwo"
# Installer-Requirements # # Installer-Requirements #
##--------------------------## ##--------------------------##
msg "Starting installer." 8 78 msg " Starting installer" 8 78
$PKGM update > $OUTPUT 2>&1 $PKGM update > $OUTPUT 2>&1
$PKGI curl > $OUTPUT 2>&1 $PKGI curl > $OUTPUT 2>&1
@@ -122,24 +123,24 @@ $PKGI curl > $OUTPUT 2>&1
if [ $IMODE = n ]; then if [ $IMODE = n ]; then
if [ $TestMode = 0 ]; then if [ $TestMode = 0 ]; then
domain=$(whiptail --nocancel --inputbox " Enter the domain without WWW " 11 82 --title "Config" 3>&1 1>&2 2>&3) 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 " 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 " 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=$(whiptail --nocancel --inputbox " SystemID (eg: VCH001) without ".nxdi.nl" " 11 82 --title "Config" 3>&1 1>&2 2>&3)
hostname=$hostname".nxdi.nl" hostname=$hostname".nxdi.nl"
else 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 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 sslenable=1
else else
sslenable=0 sslenable=0
fi fi
PasswordQuest 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 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) 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=$?
[[ "$esws" = 1 ]] && msg "Quiting installer." 8 78 && exit; [[ "$esws" = 1 ]] && msg " Quiting installer" 8 78 && exit;
fi fi
if [ $IMODE = l ]; then if [ $IMODE = l ]; then
@@ -210,11 +211,11 @@ fi
webserv="${webserv//:}" && webserv="${webserv,,}" webserv="${webserv//:}" && webserv="${webserv,,}"
echo "Generating apt list for Generic" 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 printf " " >>/tmp/apt.list
echo "Generating apt list for Webserver" 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 printf " " >>/tmp/apt.list
@@ -310,12 +311,12 @@ done
fi fi
fi fi
#Cleaning options from menu #Cleaning options from menu
option="${option,,}" && option="${option// /}" option="${option,,}" && option="${option// /}"
#Always on option modules #Always on option modules
option="$option /MySQL/" option="$option /MySQL/"
option="$option /Unattended-Security-Updates/" option="$option /Unattended-Security-Updates/"
#Cleaning all options #Cleaning all options
option="${option/:/ }" && option="${option//:}" && option="${option//'"'}" option="${option/:/ }" && option="${option//:}" && option="${option//'"'}"
echo "Generating apt list for Options" echo "Generating apt list for Options"
@@ -323,7 +324,7 @@ for val1 in ${option[*]}; do
echo "$val1" #TMP echo "$val1" #TMP
modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1") modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1")
#Checking #Checking
if test -z "$modListed" if test -z "$modListed"
then then
#Fetching from local repo #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 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") "None")
CMS=None: CMS=None:
break;; break;;
*) echo "$REPLY is not a valid option!";; *) echo "$REPLY is not a valid option!";;
esac esac
done done
fi fi
CMS="${CMS//:}" && CMS="${CMS,,}" CMS="${CMS//:}" && CMS="${CMS,,}"
echo "Generating Apt List for 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 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 # # Pre-Requirements #
##--------------------## ##--------------------##
msg " Preconfiguring"
sed -i '/Port 22/c\Port 4242' /etc/ssh/sshd_config sed -i '/Port 22/c\Port 4242' /etc/ssh/sshd_config
msg "Preconfiguring."
$PKGI software-properties-common gnupg > $OUTPUT 2>&1 $PKGI software-properties-common gnupg > $OUTPUT 2>&1
$PKGA universe -y > $OUTPUT 2>&1 $PKGA universe -y > $OUTPUT 2>&1
$PKGA ppa:ondrej/php -y > $OUTPUT 2>&1 $PKGA ppa:ondrej/php -y > $OUTPUT 2>&1
@@ -430,7 +428,7 @@ for val1 in ${option[*]}; do
echo "$val1" #TMP echo "$val1" #TMP
modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1") modListed=$(wget -t7 -qO - "$repo"/raw/branch/master/extModules.txt|grep "$val1")
#Checking #Checking
if test -z "$modListed" if test -z "$modListed"
then then
#Fetching from local repo #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 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 fi
done done
echo "Running preconf for CMS" 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 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) 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 fi
done done
echo "Setting up SSL" echo "Setting up SSL"
if [ $sslenable = 1 ]; then if [ $sslenable = 1 ]; then
if [ $domainwww = 1 ]; then if [ $domainwww = 1 ]; then
certbot --"$webserv" -n -d "$domain" -d "www.$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos certbot --"$webserv" -n -d "$domain" -d "www.$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos
elif [ $domainwww = 0 ]; then elif [ $domainwww = 0 ]; then
certbot --"$webserv" -n -d "$domain" -m "$email" --hsts --redirect --no-eff-email --agree-tos 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 certbot --"$webserv" -n -d "$hostname" -m "$email" --hsts --redirect --no-eff-email --agree-tos
fi 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 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 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" 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 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) source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/CMS/"$CMS"/conf.sh)
fi fi
if curl --retry 2 --retry-delay 1 --output /dev/null --silent --head --fail "$repo"/raw/branch/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh; then 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) source <(curl --retry 7 --retry-delay 5 -s "$repo"/raw/branch/"$branch"/CMS/"$CMS"/"$webserv"-conf.sh)
fi fi