Implemented TestVar

Moved static-vars up, set TestMode to 1 (enabled) or 0 (disabled).

TestMode skips basic questions for easier script testing.
This commit is contained in:
b.waal
2020-03-11 12:35:41 +01:00
parent 788580b8aa
commit 8b46b3c28b

View File

@@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
##--------------------## ##--------------------##
# Legacy/Main Menu # # Legacy/Main Menu #
##--------------------## ##--------------------##
@@ -18,9 +19,44 @@ if [ "$1" = "-l" ]; then
fi fi
##---------------##
# Static-Vars #
##---------------##
#Git-repo
repo=https://git.ictmaatwerk.com/bprieshof/UBU-Web-V2
branch=master
#Installer-config
phpver=7.4
sqlver=8.0
cockpit=1
PHPMyadmin=1
TestMode=0
#PackageManager-config
PKGA="add-apt-repository"
PKGI="${PKGM} install -y"
OUTPUT='/dev/null'
##-------------##
# Test-Vars #
##-------------##
if [ $TestMode = 1 ]; then
domain=ict-dagbesteding.nl
email=b.prieshof@ictmaatwerk.com
password=MeiFerrieSekureTESTp@ssw0rd4213
hostname=vdh001.nxdi.nl
sslenable=0
domainwww=0
fi
##---------------## ##---------------##
# Functions # # Functions #
##---------------## ##---------------##
msg () { msg () {
if [ $IMODE = n ]; then if [ $IMODE = n ]; then
TERM=ansi whiptail --title "Info" --infobox "$1" 8 52 TERM=ansi whiptail --title "Info" --infobox "$1" 8 52
@@ -70,24 +106,6 @@ password="$passdiatwo"
} }
##---------------##
# Static-Vars #
##---------------##
#Git-repo
repo=https://git.ictmaatwerk.com/bprieshof/UBU-Web-V2
branch=master
#Installer-config
phpver=7.4
sqlver=8.0
cockpit=1
PHPMyadmin=1
#PackageManager-config
PKGA="add-apt-repository"
PKGI="${PKGM} install -y"
OUTPUT='/dev/null'
##--------------------------## ##--------------------------##
# Installer-Requirements # # Installer-Requirements #
##--------------------------## ##--------------------------##
@@ -100,7 +118,9 @@ $PKGI curl > $OUTPUT 2>&1
##--------## ##--------##
# Menu # # Menu #
##--------## ##--------##
if [ $IMODE = n ]; then 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) 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=1; fi if (whiptail --title "Config" --yesno "Does www.${domain} exist in DNS" 8 78); then domainwww=1; else domainwww=1; fi
if (whiptail --title "Config" --yesno "Hostname with nxdi.nl" 11 82); then if (whiptail --title "Config" --yesno "Hostname with nxdi.nl" 11 82); then
@@ -115,7 +135,8 @@ 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 82 --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) 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;
@@ -123,6 +144,7 @@ fi
if [ $IMODE = l ]; then if [ $IMODE = l ]; then
echo "" >/dev/null echo "" >/dev/null
if [ $TestMode = 0 ]; then
echo "Enter the domain without WWW:" echo "Enter the domain without WWW:"
read domain read domain
while true; do while true; do
@@ -163,6 +185,7 @@ done
LegacyPasswordQuest LegacyPasswordQuest
echo "Administrator E-mail:" echo "Administrator E-mail:"
read email read email
fi
echo "Select Webserver:" echo "Select Webserver:"
PS3='Selected:' PS3='Selected:'