#!/bin/sh
echo " " ;
echo "-  Install Counter-Strike Server... ... ....Please Wait." ;
echo " " ;
sleep 2 ;
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" ;
echo " " ;
sleep 1 ;
echo "- Sending Server TERM-Signals... ... ...." ;
echo " " ;
sleep 1 ;
killall -vwq hltv ;
echo " " ;
sleep 1 ;
killall -vwq hlds_run;
echo " " ;
sleep 1 ;
killall -vwq hlds_linux ;
sleep 1 ;
rm -rf /home/$USER/servers/hlds/startup.pid ;
sleep 1 ;
rm -rf /home/$USER/servers/hlds/hltv.pid ;
echo " " ;
sleep 1 ;
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" ;
echo " " ;
sleep 2 ;
echo "- Backup Old Server files... ... ....." ;
echo " " ;
sleep 2 ;
rm -rf /home/$USER/servers/backup/servers1/hlds  
echo " " ;
sleep 2 ;
rm -rf /home/$USER/servers/backup/servers/hltv  
echo " " ;
sleep 2 ;
mv -v /home/$USER/servers/backup/servers0/hlds /home/$USER/servers/backup/servers1/hlds
echo " " ;
sleep 2 ;
mv -v /home/$USER/servers/backup/servers/hlds /home/$USER/servers/backup/servers0/hlds
echo " " ;
sleep 2 ;
mv -v /home/$USER/servers/hlds/ /home/$USER/servers/backup/servers
echo " " ;
sleep 2 ;
mv -v /home/$USER/servers/hltv/ /home/$USER/servers/backup/servers
echo " " ;
sleep 2 ;
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
echo " " ;
sleep 2 ;
echo "- Installing Server from Template... ... ....." ;
echo " " ;
sleep 2 ;
nice cp -avr /home/default/servers/hlds/ /home/$USER/servers > /dev/null 2>&1
echo " " ;
sleep 2 ;
nice cp -avr /home/default/servers/hltv/ /home/$USER/servers > /dev/null 2>&1
echo " " ;
sleep 2 ;
echo "- Installing Startup Command... ... ....." ;
echo " " ;
sleep 2 ;
nice cp -avrf /home/$USER/run_cs.sh /home/$USER/servers/hlds
echo " " ;
sleep 2 ;
echo "- Installing Configuration Templates... ... ....." ;
echo " " ;
sleep 2 ;
nice tar -xzvf def_hlds.tar.gz --overwrite
echo " " ;
sleep 2 ;
echo "- Set File Permissions... ... ....." ;
echo " " ;
sleep 2 ;
chmod -R 775 /home/$USER/servers/
echo " " ;
sleep 2 ;
echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" ;
echo " " ;
sleep 2 ;
echo "     -  Your Server is Ready ! ! !" ;
echo " " ;