#/!/bin/bash
##################################
# Installation mit Apache2 php   #
# Shellinabox und Samba          #
# und Samba mit Schematas        #
# Erstellt am 24.05.2025 von TR  #
##################################
### Farbdefinitionen ####
#   TEXT in Weiss       #
#   DATEIEN in Gelb     #
#   ORDNER in HellBlau  #
#########################
# 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
# Variabelen Festlegen
Pfad="root"
BezReg=""
# Pruefen on der Benutzer root oder sudo 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
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/bash/.bashrc
cp .bashrc.1 .bashrc
#
echo
echo -e -n "${TUERKIS}Update und Upgrade des Debian ${NC}"
echo
sleep 1
apt-get update && apt upgrade -y && apt install net-tools ssh gnupg2 curl git unzip mc zip samba shellinabox apache2 -y
a2ensite default-ssl.conf
a2enmod ssl
systemctl restart apache2
systemctl status apache2 --no-pager
echo
echo -e -n "${TUERKIS}Autoremove der nicht mehr genutzten Dateien ${NC}"
echo
sleep 1
apt-get autoremove -y
echo
echo -e -n "${TUERKIS}Einstellen der Zeitzone Europa/Berlin und des Deutschen Tastaurlayout. ${NC}"
echo
sleep 1
##############################
###apt install task-german -y#
##############################
dpkg-reconfigure tzdata
dpkg-reconfigure locales
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
#
# DockerWebseiten
cd /var/www/html
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/zip/DockerWebseiten.zip
rm index.html
unzip DockerWebseiten.zip
cd /root
###############################################################
### Die Stadt der Bezirksregierung bedtimmen   ################
###############################################################
echo
echo -e -n "${HELLBLAU}Die Stadt des BezReg in der ${ROT}FORM $GELBArnsberg ${HELLBLAU}oder $GELBDetmold ${HELLBLAU}oder $GELBDuesseldorf ${HELLBLAU}oder $GELBKoeln ${HELLBLAU}oder $GELBMuenster ${HELLBLAU}eintragen. ${NC}"
echo
read -p  "Arnsberg oder Detmold oder Duesseldorf oder Koeln oder Muenster eintragen: " BezReg
echo
#
# Samba einrichten
echo
echo -e -n "${TUERKIS}Installation des SAMBA-SERVERS erstellen ${NC}"
echo
sleep 2
mkdir /netzlaufwerk/
###mkdir /netzlaufwerk/Programme
##git clone https://github.com/SVWS-NRW/SVWS-TestMDBs /netzlaufwerk/SVWS-TestMDBs
cd /netzlaufwerk
mkdir OfficelleTestDBS
cd OfficelleTestDBS
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/zip/SchulungsSchematas/BezReg.zip
unip $BezReg.zip
#
cd /$Pfad
#
tee -a /etc/samba/smb.conf <<EOF

[netzlaufwerk]
path = /netzlaufwerk
public = yes
writable = yes
comment = SVWS Freigabe
printable = no
guest ok = yes
EOF
#
systemctl restart smbd.service
echo
echo -e -n "${TUERKIS} Ausgabe des Samba-Server Status  ${NC}"
echo
systemctl status smbd.service --no-pager
chmod -R 777 /netzlaufwerk/
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/docker-container-schulungen.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/docker-container-svws-update.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/docker-schemata.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gesamtschule.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Grundschule.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_2HJ.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_FaecherSek2.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_LaufbahnenJG10.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_LaufbahnenJGEF.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_LaufbahnenJGEFMitBlockung.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/Gymnasium_LaufbahnenJGEFvollst.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/S1-Schulung.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/S2-Schulung.sh
wget -q --show-progress http://web.webolch.de/bauanleitung/downloads/linux/SH-Scripte/docker-container-svws-1.0.4/schema_menu.sh
#
echo
echo -e -n "${TUERKIS}Installation von DOCKER ${NC}"
echo
sleep 1
curl -fsSL https://get.docker.com -o get-docker.sh
bash get-docker.sh
systemctl status docker --no-pager
#
echo
echo -e -n "${TUERKIS}Installation der Docker-STACKs ${NC}"
echo
sleep 2
bash docker-container-schulungen.sh
#
echo
echo -e -n "${TUERKIS}Installation des DOCKER Portainer ${NC}"
echo
sleep 1
docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name=portainer -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data --restart=always portainer/portainer-ce
