From e7c9f3bfcbd489e6bca557b46790be91046b6005 Mon Sep 17 00:00:00 2001 From: bprieshof Date: Thu, 28 Nov 2019 14:16:35 +0100 Subject: [PATCH] Added legacy menu and apt.list generator for options --- installer.sh | 131 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 117 insertions(+), 14 deletions(-) diff --git a/installer.sh b/installer.sh index 6b35874..8d00300 100644 --- a/installer.sh +++ b/installer.sh @@ -76,6 +76,25 @@ echo "Please enter your password (should contain at least 2 digits and 6 charact read password echo "Administrator E-mail:" read email + +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 +done + fi webserv="${webserv//:}" && webserv="${webserv,,}" @@ -97,7 +116,41 @@ 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) fi if [ $IMODE = l ]; then -#L mode selector option +choice () { +local choice=$1 +if [[ ${opts[choice]} ]] # toggle +then +opts[choice]= +else +opts[choice]=+ +fi +} + +PS3='Which Nginx addons should be installed?' +while : +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 +done +done fi fi @@ -107,24 +160,53 @@ 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 -#L mode selector option +choice () { +local choice=$1 +if [[ ${opts[choice]} ]] # toggle +then +opts[choice]= +else +opts[choice]=+ +fi +} + +PS3='Which Apache addons should be installed?' +while : +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 +done +done fi fi option="${option// /}" && option="${option/:/ }" && option="${option//:}" && option="${option,,}" && option="${option//'"'}" -if [[ $option == *"Memcached:"* ]]; then -#curl -s "$repo"/raw/branch/"$branch"/modules/MODNAME/"$webserv"-aptlist >> /tmp/install.txt -echo "php-memcached" >> /tmp/install.txt -fi +echo "Generating Apt List for options" +for val1 in ${option[*]}; do + echo $val1 #TMP + curl "$repo"/raw/branch/"$branch"/SubModules/"$val1"/"$webserv"/apt.list >>/tmp/apt.list + curl "$repo"/raw/branch/"$branch"/SubModules/"$val1"/common/apt.list >>/tmp/apt.list -if [[ $option == *"Redis"* ]]; then -echo "redis-server" >> /tmp/install.txt -fi - -if [[ $option == *"Brotli:"* ]]; then -echo "" >> /tmp/install.txt -fi +done ##-------## @@ -135,8 +217,29 @@ CMS=$(whiptail --nocancel --title "What CMS should be installed?" --radiolist "F fi if [ $IMODE = l ]; then -#L mode selector for CMS +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 +done fi +curl "$repo"/raw/branch/"$branch"/CMS/"$CMS"/$webserv/apt.list >>/tmp/apt.list + +curl "$repo"/raw/branch/"$branch"/CMS/"$CMS"/apt.list >>/tmp/apt.list if [[ $CMS == "Nextcloud:" ]]; then echo "libxml2 openssl zlib1g libpng-dev redis-server" >> /tmp/install.txt