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
|
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 #
|
# Functions #
|
||||||
##---------------##
|
##---------------##
|
||||||
@@ -139,7 +183,7 @@ fi
|
|||||||
PasswordQuest
|
PasswordQuest
|
||||||
email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 78 --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 "${webservers[@]}" 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
|
||||||
@@ -190,27 +234,30 @@ read email
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Select Webserver:"
|
echo "Select Webserver:"
|
||||||
PS3='Selected:'
|
select webserv in "${webservers[@]}"; do
|
||||||
options=("Nginx" "Apache" "Quit")
|
case $webserv in
|
||||||
select opt in "${options[@]}"
|
"Quit") exit ;;
|
||||||
do
|
"") echo 'Invalid choice' >&2 ;;
|
||||||
case $opt in
|
*) break
|
||||||
"Nginx")
|
esac
|
||||||
webserv=Nginx:
|
|
||||||
break;;
|
|
||||||
"Apache")
|
|
||||||
webserv=Apache:
|
|
||||||
break;;
|
|
||||||
"Quit")
|
|
||||||
exit;;
|
|
||||||
*) echo "$REPLY is not a valid option!";;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
webserv="${webserv//:}" && webserv="${webserv,,}"
|
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"
|
echo "Generating apt list for Generic"
|
||||||
curl --silent --show-error "$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
|
||||||
@@ -224,10 +271,8 @@ printf " " >>/tmp/apt.list
|
|||||||
# Addons #
|
# Addons #
|
||||||
##----------##
|
##----------##
|
||||||
|
|
||||||
if [[ $webserv = "nginx" ]]; then
|
|
||||||
#NGINX Addon menu
|
|
||||||
if [ $IMODE = n ]; then
|
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
|
fi
|
||||||
if [ $IMODE = l ]; then
|
if [ $IMODE = l ]; then
|
||||||
choice () {
|
choice () {
|
||||||
@@ -235,81 +280,38 @@ local choice=$1
|
|||||||
if [[ ${opts[choice]} ]] # toggle
|
if [[ ${opts[choice]} ]] # toggle
|
||||||
then
|
then
|
||||||
opts[choice]=
|
opts[choice]=
|
||||||
|
topt=${opt//+/}
|
||||||
|
option=${option//"$topt"/}
|
||||||
|
unset $topt
|
||||||
else
|
else
|
||||||
opts[choice]=+
|
opts[choice]=+
|
||||||
|
option="$option $opt"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
echo "The first slection will always return invalid option, please enter the first option twice"
|
||||||
PS3='Which Nginx addons should be installed?'
|
PS3='Which addons should be installed?'
|
||||||
while :
|
while :
|
||||||
do
|
do
|
||||||
echo ""
|
echo ""
|
||||||
options=("Memcached ${opts[1]}" "Redis Cache ${opts[2]}" "Done")
|
unset options2
|
||||||
select opt in "${options[@]}"
|
unset OPTcounter
|
||||||
do
|
for E in "${options[@]}"; do
|
||||||
case $opt in
|
((OPTcounter++))
|
||||||
"Memcached ${opts[1]}")
|
options2+=("${E} ${opts["$OPTcounter"]}")
|
||||||
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
|
|
||||||
done
|
done
|
||||||
done
|
options2+=("Done")
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ $webserv = "apache" ]]; then
|
select opt in "${options2[@]}"
|
||||||
#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 :
|
|
||||||
do
|
do
|
||||||
clear
|
case $opt in
|
||||||
options=("Memcached ${opts[1]}" "Redis Cache ${opts[2]}" "Done")
|
"Done") break 2;;
|
||||||
select opt in "${options[@]}"
|
"") printf '%s\n' 'invalid option';;
|
||||||
do
|
*) choice $REPLY
|
||||||
case $opt in
|
break
|
||||||
"Memcached ${opts[1]}")
|
;;
|
||||||
choice 1
|
esac
|
||||||
option="$option Memcache:"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
"Redis Cache ${opts[2]}")
|
|
||||||
choice 2
|
|
||||||
option="$option Redis Cache:"
|
|
||||||
break
|
|
||||||
;;
|
|
||||||
"Done")
|
|
||||||
break 2
|
|
||||||
;;
|
|
||||||
*) printf '%s\n' 'invalid option';;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Cleaning options from menu
|
#Cleaning options from menu
|
||||||
@@ -355,7 +357,7 @@ done
|
|||||||
|
|
||||||
if [ $IMODE = n ]; then
|
if [ $IMODE = n ]; then
|
||||||
function CMSM {
|
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
|
if [ -z $CMS ]; then CMSM; fi
|
||||||
}
|
}
|
||||||
CMSM
|
CMSM
|
||||||
@@ -363,22 +365,12 @@ fi
|
|||||||
|
|
||||||
if [ $IMODE = l ]; then
|
if [ $IMODE = l ]; then
|
||||||
echo "What CMS should be installed?"
|
echo "What CMS should be installed?"
|
||||||
PS3='Selected:'
|
#CMSPromt
|
||||||
options=("Nextcloud" "Wordpress" "None")
|
select CMS in "${CMSL[@]}"; do
|
||||||
select opt in "${options[@]}"
|
case CMS in
|
||||||
do
|
"") echo 'Invalid choice' >&2 ;;
|
||||||
case $opt in
|
*) break
|
||||||
"Nextcloud")
|
esac
|
||||||
CMS=Nextcloud:
|
|
||||||
break;;
|
|
||||||
"Wordpress")
|
|
||||||
CMS=Wordpress:
|
|
||||||
break;;
|
|
||||||
"None")
|
|
||||||
CMS=None:
|
|
||||||
break;;
|
|
||||||
*) echo "$REPLY is not a valid option!";;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -528,4 +520,4 @@ fi
|
|||||||
# Services #
|
# Services #
|
||||||
##------------##
|
##------------##
|
||||||
|
|
||||||
systemctl restart sshd
|
systemctl restart sshd
|
||||||
|
|||||||
Reference in New Issue
Block a user