#!/bin/bash
# Pruefen ob der Benutzer root ist
if ! [ $( id -u ) = 0 ]; then
    echo -e -n "${HELLROT}Bitte fuehren Sie dieses Script als root im root-Verzeichniss aus! ${NC}" 1>&2
    echo
    exit 1
fi
apt install dialog -y
# Farbdefinitionen zur Ausgabe #
ROT='\033[0;31m' 
HELLROT='\033[1;31m'
GRUEN='\033[0;32m'
HELLGRUEN='\033[1;32m'
GELB='\033[1;33m'
BLAU='\033[0;34m'
HELLBLAU='\033[1;34m'
LILA='\033[0;35m'
HELLLILA='\033[1;35m'
DUNKELESTUERKIS='\033[0;36m'
TUERKIS='\033[1;36m'
HELLGRAU='\033[0;37m'
WEISS='\033[1;37m'
NC='\033[0m' # No Color
#
HEIGHT=10
WIDTH=85
CHOICE_HEIGHT=5
BACKTITLE="Installation des SVWS-Serves und des WebNotenManager"
TITLE="SVWS-Server und WebNotenManager mit der Kurzbezeichnung wenom"
MENU="Bitte eine Auswahl treffen:"

OPTIONS=(1 "SVWS-Serves Compilieren und WebNotenManager (WENOM) Installieren."
         2 "SVWS-Server Release und WebNotenManager (WENOM) Installieren.")

CHOICE=$(dialog --clear \
                --backtitle "$BACKTITLE" \
                --title "$TITLE" \
                --menu "$MENU" \
                $HEIGHT $WIDTH $CHOICE_HEIGHT \
                "${OPTIONS[@]}" \
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
            echo -e -n "${HELLBLAU}Vorbereitung der Installation. ${NC}"
            echo
            echo
            sleep 1
            apt update && apt upgrade -y && apt install -y curl zip unzip dnsutils nmap net-tools nano mc git ssh ca-certificates gnupg2 php lsb-release apt-transport-https sqlite3
            dpkg-reconfigure locales
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/svws-wenom-install/install_wenom_mit_compilieren_des_svws-servers.sh
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/bash/.bashrc
            cp .bashrc.1 .bashrc
            clear
            echo
            echo -e -n "${TUERKIS}OpenSSH wird fuer die root Benutzung konfiguriert. ${NC}"
            echo
            sleep 3
            #
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/zip/ssh.zip
            unzip ssh.zip
            mv sshd_config /etc/ssh
            systemctl restart ssh
            systemctl status ssh --no-pager
            #
            echo
            echo -e -n "${HELLGRUEN}OK ${NC}"
            echo
            sleep 3
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo
            echo -e -n "${HELLROT}################${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}######${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}################${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}######${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS ${NC}"
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo
            echo -e -n "${WEISS}################   ${HELLGRUEN}Nach Anpassung der Datei ${GELB}install_wenom_mit_compilieren_des_svws-servers.sh${HELLGRUEN} ${WEISS}########################################### ${NC}"
            echo
            echo -e -n "${WEISS}################   ${HELLGRUEN}Installation mit ${GELB}bash install_wenom_mit_compilieren_des_svws-servers.sh ${HELLGRUEN}starten. ${WEISS}############################## ${NC}"
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo
            ;;
        2)
            echo -e -n "${HELLBLAU}Vorbereitung der Installation. ${NC}"
            echo
            echo
            sleep 1
            apt update && apt upgrade -y && apt install -y curl zip unzip dnsutils nmap net-tools nano mc git ssh ca-certificates gnupg2 apache2 lsb-release apt-transport-https sqlite3
            dpkg-reconfigure locales
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/svws-wenom-install/install_wenom_svws-server-release.sh
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/bash/.bashrc
            cp .bashrc.1 .bashrc
            clear
            echo
            echo -e -n "${TUERKIS}OpenSSH wird fuer die root Benutzung konfiguriert. ${NC}"
            echo
            sleep 3
            #
            wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/zip/ssh.zip
            unzip ssh.zip
            mv sshd_config /etc/ssh
            systemctl restart ssh
            systemctl status ssh --no-pager
            #
            echo
            echo -e -n "${HELLGRUEN}OK ${NC}"
            echo
            sleep 3
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo
            echo -e -n "${HELLROT}################${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}######${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}################${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS${HELLROT}######${GELB}HINWEIS${HELLROT}########${GELB}HINWEIS ${NC}"
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo
            echo -e -n "${WEISS}################   ${HELLGRUEN}Nach Anpassung der Datei ${GELB}install_wenom_svws-server-release ${WEISS}#####################################################${NC}"
            echo
            echo -e -n "${WEISS}################   ${HELLGRUEN}Installation mit ${GELB}bash iinstall_wenom_svws-server-release ${HELLGRUEN}starten. ${WEISS}#########################${NC}"
            echo
            echo -e -n "${WEISS}############################################################################################################################################### ${NC}"
            echo

esac
