#!/bin/bash
STARTCMD="php -d memory_limit=256M -f /home/s1231073/GSManager/gsm.php -- -game GAME -apiport 12000 -apiuser admin -apipw ******* -logdir /home/s1231073/GSManager/log/ -cfgdir /home/s1231073/GSManager/config/ -apiinit 1 -apiip 85.114.152.70 "
cd ~/GSManager
rm -rf ~/.konsole.log 2>/dev/null
rm -rf ~/screenlog.0 2>/dev/null
touch ~/.konsole.log
unset http_proxy https_proxy
sed -i 's/\r//g' /home/s1231073/GSManager/.config.sh
GAME="`grep 'game ' /home/s1231073/GSManager/.config.sh | awk '{ print $2 }'`"
GSIP="`grep 'ip ' /home/s1231073/GSManager/.config.sh | awk '{ print $2 }'`"
RCONPORT="`grep 'port ' /home/s1231073/GSManager/.config.sh | awk '{ print $2 }'`"
RCONPW="`grep 'password ' /home/s1231073/GSManager/.config.sh | awk '{ print $2 }'`"
STARTCMD=`echo "$STARTCMD" | sed 's/GAME/'$GAME'/'`
curl -u gamed:GhkSxyD4yxEBBTFE "https://interface.gsmanager.de/create?host=85.114.152.70&apiport=12000&game=$GAME"  -o /dev/null
curl -u gamed:GhkSxyD4yxEBBTFE "https://interface.gsmanager.de/update?host=85.114.152.70&apiport=12000&game=$GAME"  -o /dev/null
while true; do
$STARTCMD | tee -a ~/.konsole.log
sleep 30
done
$STARTCMD | tee -a ~/.konsole.log