Updated menu structure to be more dynamic
This commit is contained in:
194
installer.sh
194
installer.sh
@@ -53,6 +53,50 @@ domainwww=0
|
||||
fi
|
||||
|
||||
|
||||
##----------------##
|
||||
# Menu Entries #
|
||||
##----------------##
|
||||
|
||||
if [ $IMODE = n ]; then
|
||||
#WebServers
|
||||
webservers=("Nginx:" "Will install NGINX Webserver." ON)
|
||||
webservers+=("Apache:" "Will install Apache Webserver." OFF)
|
||||
|
||||
##Nginx
|
||||
#CMSList
|
||||
NginxCMSL=("None:" "A plain webserver will be setup." OFF)
|
||||
NginxCMSL+=("Wordpress:" "WordPress is a content management system based on PHP." OFF)
|
||||
NginxCMSL+=("Nextcloud:" "Nextcloud is a suite of client-server software for creating and using file hosting services." OFF)
|
||||
#Options
|
||||
NginxOptions=("Option 1:" "Option 1 Desription" OFF)
|
||||
NginxOptions+=("Option 2: " "Option 2 Desription" OFF)
|
||||
NginxOptions+=("Option 3: " "Option 3 Desription" OFF)
|
||||
|
||||
##Apache
|
||||
#CMSList
|
||||
ApacheCMSL=("None:" "A plain webserver will be setup." OFF)
|
||||
ApacheCMSL+=("Wordpress:" "WordPress is a content management system based on PHP." OFF)
|
||||
#Options
|
||||
ApacheOptions=("Option 1:" "Option 1 Desription" OFF)
|
||||
ApacheOptions+=("Option 2: " "Option 2 Desription" OFF)
|
||||
fi
|
||||
if [ $IMODE = l ]; then
|
||||
#WebServers
|
||||
webservers=("Nginx" "Apache" "Quit")
|
||||
##Nginx
|
||||
#CMSList
|
||||
NginxCMSL=("Wordpress" "Nextcloud" "None")
|
||||
#Options
|
||||
NginxOptions=("Option 1" "Ngx Option 2")
|
||||
|
||||
##Apache
|
||||
#CMSList
|
||||
ApacheCMSL=("Wordpress" "Nextcloud" "None")
|
||||
#Options
|
||||
ApacheOptions=("Option 1" "Apa Option 2")
|
||||
fi
|
||||
|
||||
|
||||
##---------------##
|
||||
# Functions #
|
||||
##---------------##
|
||||
@@ -139,7 +183,7 @@ fi
|
||||
PasswordQuest
|
||||
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)
|
||||
webserv=$(whiptail --title "Select Webserver" --radiolist "WebServer" 11 53 5 "${webservers[@]}" 3>&1 1>&2 2>&3)
|
||||
esws=$?
|
||||
[[ "$esws" = 1 ]] && msg " Quiting installer" 8 78 && exit;
|
||||
fi
|
||||
@@ -190,27 +234,30 @@ read email
|
||||
fi
|
||||
|
||||
echo "Select Webserver:"
|
||||
PS3='Selected:'
|
||||
options=("Nginx" "Apache" "Quit")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Nginx")
|
||||
webserv=Nginx:
|
||||
break;;
|
||||
"Apache")
|
||||
webserv=Apache:
|
||||
break;;
|
||||
"Quit")
|
||||
exit;;
|
||||
*) echo "$REPLY is not a valid option!";;
|
||||
esac
|
||||
select webserv in "${webservers[@]}"; do
|
||||
case $webserv in
|
||||
"Quit") exit ;;
|
||||
"") echo 'Invalid choice' >&2 ;;
|
||||
*) break
|
||||
esac
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
webserv="${webserv//:}" && webserv="${webserv,,}"
|
||||
|
||||
#Setting Menulist to webserver
|
||||
if [[ $webserv = "apache" ]]; then
|
||||
#Apache Menulist
|
||||
CMSL=("${ApacheCMSL[@]}")
|
||||
options=("${ApacheOptions[@]}")
|
||||
fi
|
||||
if [[ $webserv = "nginx" ]]; then
|
||||
#nginx Menulist
|
||||
CMSL=("${NginxCMSL[@]}")
|
||||
options=("${NginxOptions[@]}")
|
||||
fi
|
||||
|
||||
echo "Generating apt list for Generic"
|
||||
curl --silent --show-error "$repo"/raw/branch/"$branch"/CoreModules/generic/apt.list >>/tmp/apt.list
|
||||
printf " " >>/tmp/apt.list
|
||||
@@ -224,10 +271,8 @@ printf " " >>/tmp/apt.list
|
||||
# Addons #
|
||||
##----------##
|
||||
|
||||
if [[ $webserv = "nginx" ]]; then
|
||||
#NGINX Addon menu
|
||||
if [ $IMODE = n ]; then
|
||||
option=$(whiptail --nocancel --title "Which Nginx addons should be installed?" --checklist "Features" 11 110 5 "Memcached:" "Memcached is an open source, high-performance, distributed memory caching system." OFF "Redis Cache:" "Redis is an open source BSD licensed, in-memory data structure store." OFF 3>&1 1>&2 2>&3)
|
||||
option=$(whiptail --nocancel --title "Title" --checklist "Features" 11 110 5 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
fi
|
||||
if [ $IMODE = l ]; then
|
||||
choice () {
|
||||
@@ -235,81 +280,38 @@ local choice=$1
|
||||
if [[ ${opts[choice]} ]] # toggle
|
||||
then
|
||||
opts[choice]=
|
||||
topt=${opt//+/}
|
||||
option=${option//"$topt"/}
|
||||
unset $topt
|
||||
else
|
||||
opts[choice]=+
|
||||
option="$option $opt"
|
||||
fi
|
||||
}
|
||||
|
||||
PS3='Which Nginx addons should be installed?'
|
||||
echo "The first slection will always return invalid option, please enter the first option twice"
|
||||
PS3='Which addons should be installed?'
|
||||
while :
|
||||
do
|
||||
echo ""
|
||||
options=("Memcached ${opts[1]}" "Redis Cache ${opts[2]}" "Done")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Memcached ${opts[1]}")
|
||||
choice 1
|
||||
option="$option Memcache:"
|
||||
break
|
||||
;;
|
||||
"Redis Cache ${opts[2]}")
|
||||
choice 2
|
||||
option="$option Redis Cache:"
|
||||
break
|
||||
;;
|
||||
"Done")
|
||||
break 2
|
||||
;;
|
||||
*) printf '%s\n' 'invalid option';;
|
||||
esac
|
||||
unset options2
|
||||
unset OPTcounter
|
||||
for E in "${options[@]}"; do
|
||||
((OPTcounter++))
|
||||
options2+=("${E} ${opts["$OPTcounter"]}")
|
||||
done
|
||||
done
|
||||
fi
|
||||
fi
|
||||
options2+=("Done")
|
||||
|
||||
if [[ $webserv = "apache" ]]; then
|
||||
#Apache Addon menu
|
||||
if [ $IMODE = n ]; then
|
||||
option=$(whiptail --nocancel --title "Which Apache addons should be installed?" --checklist "Features" 11 110 5 "Memcached:" "Memcached is an open source, high-performance, distributed memory caching system." OFF "Redis Cache:" "Redis is an open source BSD licensed, in-memory data structure store." OFF 3>&1 1>&2 2>&3)
|
||||
fi
|
||||
if [ $IMODE = l ]; then
|
||||
choice () {
|
||||
local choice=$1
|
||||
if [[ ${opts[choice]} ]] # toggle
|
||||
then
|
||||
opts[choice]=
|
||||
else
|
||||
opts[choice]=+
|
||||
fi
|
||||
}
|
||||
|
||||
PS3='Which Apache addons should be installed?'
|
||||
while :
|
||||
select opt in "${options2[@]}"
|
||||
do
|
||||
clear
|
||||
options=("Memcached ${opts[1]}" "Redis Cache ${opts[2]}" "Done")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Memcached ${opts[1]}")
|
||||
choice 1
|
||||
option="$option Memcache:"
|
||||
break
|
||||
;;
|
||||
"Redis Cache ${opts[2]}")
|
||||
choice 2
|
||||
option="$option Redis Cache:"
|
||||
break
|
||||
;;
|
||||
"Done")
|
||||
break 2
|
||||
;;
|
||||
*) printf '%s\n' 'invalid option';;
|
||||
esac
|
||||
case $opt in
|
||||
"Done") break 2;;
|
||||
"") printf '%s\n' 'invalid option';;
|
||||
*) choice $REPLY
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
done
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
#Cleaning options from menu
|
||||
@@ -355,7 +357,7 @@ done
|
||||
|
||||
if [ $IMODE = n ]; then
|
||||
function CMSM {
|
||||
CMS=$(whiptail --nocancel --title "What CMS should be installed?" --radiolist "Features" 11 118 5 "Nextcloud:" "Nextcloud is a suite of client-server software for creating and using file hosting services." OFF "Wordpress:" "WordPress is a content management system based on PHP." OFF "None:" "A plain webserver will be setup." OFF 3>&1 1>&2 2>&3)
|
||||
CMS=$(whiptail --nocancel --title "What CMS should be installed?" --radiolist "Features" 11 118 5 "${CMSL[@]}" 3>&1 1>&2 2>&3)
|
||||
if [ -z $CMS ]; then CMSM; fi
|
||||
}
|
||||
CMSM
|
||||
@@ -363,22 +365,12 @@ fi
|
||||
|
||||
if [ $IMODE = l ]; then
|
||||
echo "What CMS should be installed?"
|
||||
PS3='Selected:'
|
||||
options=("Nextcloud" "Wordpress" "None")
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
case $opt in
|
||||
"Nextcloud")
|
||||
CMS=Nextcloud:
|
||||
break;;
|
||||
"Wordpress")
|
||||
CMS=Wordpress:
|
||||
break;;
|
||||
"None")
|
||||
CMS=None:
|
||||
break;;
|
||||
*) echo "$REPLY is not a valid option!";;
|
||||
esac
|
||||
#CMSPromt
|
||||
select CMS in "${CMSL[@]}"; do
|
||||
case CMS in
|
||||
"") echo 'Invalid choice' >&2 ;;
|
||||
*) break
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
@@ -528,4 +520,4 @@ fi
|
||||
# Services #
|
||||
##------------##
|
||||
|
||||
systemctl restart sshd
|
||||
systemctl restart sshd
|
||||
|
||||
Reference in New Issue
Block a user