Started work on the Legacy mode

SSH port changed to 4242.
Added Nginx PPA.
Added Redis PPA.
Added Nextcloud dependencies.
Added Fail2Ban configs.
Added MSG function
Fixed errors on lines 93 & 98, extra brackets were missing.
Fixed memcached installation
Remove echo "" placeholders
This commit is contained in:
b.waal
2019-11-26 15:05:00 +01:00
parent 7b40cdd3eb
commit 543c30c0eb

View File

@@ -1,4 +1,35 @@
#!/bin/bash #!/bin/bash
##--------------------##
# Legacy/Main Menu #
##--------------------##
sed -i -e 's/magenta/blue/g' /etc/newt/palette
if [ "$1" != "-l" ]; then
echo "Normal mode"
PKGM="debconf-apt-progress -- apt"
OUTPUT='/dev/null'
IMODE=n
fi
if [ "$1" = "-l" ]; then
echo "Legacy mode";
PKGM="apt"
OUTPUT='/dev/tty'
IMODE=l
fi
##---------------##
# Functions #
##---------------##
msg () {
if [ $IMODE = n ]; then
TERM=ansi whiptail --title "Info" --infobox "$1" 8 52
fi
if [ $IMODE = l ]; then
echo "$1"
fi
}
##---------------## ##---------------##
# Static-Vars # # Static-Vars #
@@ -13,7 +44,6 @@ sqlver=8.0
cockpit=1 cockpit=1
PHPMyadmin=1 PHPMyadmin=1
#PackageManager-config #PackageManager-config
PKGM="debconf-apt-progress -- apt"
PKGA="add-apt-repository" PKGA="add-apt-repository"
PKGI="${PKGM} install -y" PKGI="${PKGM} install -y"
OUTPUT='/dev/null' OUTPUT='/dev/null'
@@ -23,8 +53,7 @@ OUTPUT='/dev/null'
# Installer-Requirements # # Installer-Requirements #
##--------------------------## ##--------------------------##
sed -i -e 's/magenta/blue/g' /etc/newt/palette msg "Starting installer." 8 78
TERM=ansi whiptail --title "Config" --infobox "Starting installer." 8 78
$PKGM update > $OUTPUT 2>&1 $PKGM update > $OUTPUT 2>&1
$PKGI curl > $OUTPUT 2>&1 $PKGI curl > $OUTPUT 2>&1
@@ -32,17 +61,28 @@ $PKGI curl > $OUTPUT 2>&1
##--------## ##--------##
# Menu # # Menu #
##--------## ##--------##
if [ $IMODE = n ]; 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)
password=$(whiptail --nocancel --passwordbox "Please enter your password (should contain at least 2 digits and 6 characters)" 11 82 --title "Config" 3>&1 1>&2 2>&3) password=$(whiptail --nocancel --passwordbox "Please enter your password (should contain at least 2 digits and 6 characters)" 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) email=$(whiptail --nocancel --inputbox " Enter the administrator e-mail" 11 82 --title "Config" 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) 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)
fi
if [ $IMODE = l ]; then
echo "" >/dev/null
echo "Enter the domain without WWW:"
read domain
echo "Please enter your password (should contain at least 2 digits and 6 characters:"
read password
echo "Administrator E-mail:"
read email
fi
if [[ $webserv == "Nginx:" ]]; then if [[ $webserv == "Nginx:" ]]; then
echo "nginx php${phpver}-fpm php${phpver}-imagick php${phpver}-mysql php${phpver}-cgi php${phpver}-common php${phpver}-pear php${phpver}-mbstring php${phpver}-curl php${phpver}-gd php${phpver}-intl php${phpver}-soap php${phpver}-xml php${phpver}-xmlrpc php${phpver}-zip" >> /tmp/install.txt echo "nginx php-imagick php-pear php${phpver}-fpm php${phpver}-mysql php${phpver}-cgi php${phpver}-common php${phpver}-mbstring php${phpver}-curl php${phpver}-gd php${phpver}-intl php${phpver}-soap php${phpver}-xml php${phpver}-xmlrpc php${phpver}-zip" >> /tmp/install.txt
fi fi
if [[ $webserv == "Apache:" ]]; then if [[ $webserv == "Apache:" ]]; then
echo "apache2 libapache2-mod-php php${phpver}-mysql php${phpver}-cgi php${phpver}-common php${phpver}-pear php${phpver}-mbstring php${phpver}-curl php${phpver}-gd php${phpver}-intl php${phpver}-soap php${phpver}-xml php${phpver}-xmlrpc php${phpver}-zip" >> /tmp/install.txt echo "apache2 php-pear libapache2-mod-php php${phpver}-mysql php${phpver}-cgi php${phpver}-common php${phpver}-mbstring php${phpver}-curl php${phpver}-gd php${phpver}-intl php${phpver}-soap php${phpver}-xml php${phpver}-xmlrpc php${phpver}-zip" >> /tmp/install.txt
fi fi
@@ -50,12 +90,12 @@ fi
# Addons # # Addons #
##----------## ##----------##
if [ $webserv = "Nginx:" ]; then if [[ $webserv = "Nginx:" ]]; then
#NGINX Addon menu #NGINX Addon menu
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 "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 fi
if [ $webserv = "Apache:" ]; then if [[ $webserv = "Apache:" ]]; then
#Apache Addon menu #Apache Addon menu
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) 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 fi
@@ -63,15 +103,15 @@ fi
if [[ $option == *"Memcached:"* ]]; then if [[ $option == *"Memcached:"* ]]; then
#curl -s "$repo"/raw/branch/"$branch"/modules/MODNAME/"$webserv"-aptlist >> /tmp/install.txt #curl -s "$repo"/raw/branch/"$branch"/modules/MODNAME/"$webserv"-aptlist >> /tmp/install.txt
echo "Memcached" >> /tmp/install.txt echo "php-memcached" >> /tmp/install.txt
fi fi
if [[ $option == *"Redis"* ]]; then if [[ $option == *"Redis"* ]]; then
echo "Redis" >> /tmp/install.txt echo "redis-server" >> /tmp/install.txt
fi fi
if [[ $option == *"Brotli:"* ]]; then if [[ $option == *"Brotli:"* ]]; then
echo "Brotli" >> /tmp/install.txt echo "" >> /tmp/install.txt
fi fi
@@ -81,28 +121,30 @@ fi
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 "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)
if [[ $CMS == "Nextcloud:" ]]; then if [[ $CMS == "Nextcloud:" ]]; then
echo "Nextcloud" >> /tmp/install.txt echo "libxml2 openssl zlib1g libpng-dev redis-server" >> /tmp/install.txt
fi fi
if [[ $CMS == "Wordpress:" ]]; then if [[ $CMS == "Wordpress:" ]]; then
echo "Wordpress" >> /tmp/install.txt echo "" >> /tmp/install.txt
fi fi
if [[ $CMS == "None:" ]]; then if [[ $CMS == "None:" ]]; then
echo "None" >> /tmp/install.txt echo "" >> /tmp/install.txt
fi fi
##--------------------## ##--------------------##
# Pre-Requirements # # Pre-Requirements #
##--------------------## ##--------------------##
sed -i '/Port 22/c\Port 4242' /etc/ssh/sshd_config
TERM=ansi whiptail --title "Config" --infobox "Preconfiguring." 8 78 msg "Preconfiguring."
$PKGI software-properties-common > $OUTPUT 2>&1 $PKGI software-properties-common > $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
$PKGA ppa:certbot/certbot -y > $OUTPUT 2>&1 $PKGA ppa:certbot/certbot -y > $OUTPUT 2>&1
$PKGA ppa:nginx/stable -y > $OUTPUT 2>&1 $PKGA ppa:nginx/stable -y > $OUTPUT 2>&1
$PKGA ppa:chris-lea/redis-server -y > $OUTPUT 2>&1
$PKGM update $PKGM update
$PKGM upgrade -y $PKGM upgrade -y
@@ -150,4 +192,10 @@ ufw default allow outgoing > $OUTPUT 2>&1
ufw allow 80/tcp > $OUTPUT 2>&1 ufw allow 80/tcp > $OUTPUT 2>&1
ufw allow 443/tcp > $OUTPUT 2>&1 ufw allow 443/tcp > $OUTPUT 2>&1
ufw limit 4242/tcp > $OUTPUT 2>&1 ufw limit 4242/tcp > $OUTPUT 2>&1
echo "y" | ufw enable > $OUTPUT 2>&1 echo "y" | ufw enable > $OUTPUT 2>&1
##------------##
# Services #
##------------##
systemctl restart sshd