#!/bin/bash
##################### DATEN - INSTALLATION ######################################
INSTALLPATH=/var/www/html
#################################################################################
apt update && apt upgrade -y && apt autoremove -y

rm -rf /var/www/html
mkdir /var/www/html

###### optional #####
cd ~/SVWS-Server
git reset --hard
git pull
#
./gradlew build
#
cp -a /root/SVWS-Server/. /app/SVWS-Server/
cp ~/SVWS-Server/svws-webclient/enmserver/build/*.zip $INSTALLPATH/enmserver.zip
cd $INSTALLPATH
#
####### nächste Zeile auskommentieren, wenn optional gewählt wurde ein build erwünscht #######
###wget https://wenom.svws-nrw.de/enmserver.zip
#
unzip enmserver.zip
#
chmod -R 777 $INSTALLPATH
chown -R www-data:www-data $INSTALLPATH
#
curl --request GET --url http://localhost/api/setup  --header "Content-Type: application/x-www-form-urlencoded" 
#
# NUR fuer Testzwecke geeignet:
cat $INSTALLPATH/db/client.sec > $INSTALLPATH/public/secret.html

