Browse Source

UT99server: Fixed map compressor

*Fixed map compressor
* Stopped error on first run stating that ${constolelog} is missing.
*Minor code tidy up
pull/30/head
Daniel Gibbs 12 years ago
parent
commit
a79ad15f6a
  1. 34
      UnrealTournament99/ut99server

34
UnrealTournament99/ut99server

@ -3,7 +3,7 @@
# Server Management Script # Server Management Script
# Author: Daniel Gibbs # Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk # Website: http://danielgibbs.co.uk
# Version: 011013 # Version: 101113
#### Variables #### #### Variables ####
@ -25,7 +25,7 @@ servicename="ut99-server"
gamename="Unreal Tournament 99" gamename="Unreal Tournament 99"
engine="unreal" engine="unreal"
ini="${servicename}.ini" ini="${servicename}.ini"
servername=`grep -s ServerName= ${systemdir}/${ini} | sed 's/ServerName=//g'` servername=$(grep -s ServerName= ${systemdir}/${ini} | sed 's/ServerName=//g')
# Logging # Logging
logdays="7" logdays="7"
@ -73,6 +73,7 @@ if [ ${tmuxwc} -eq 1 ];then
exit exit
fi fi
} }
fn_compressmaps(){ fn_compressmaps(){
fn_rootcheck fn_rootcheck
clear clear
@ -94,14 +95,19 @@ while true; do
* ) echo "Please answer yes or no.";; * ) echo "Please answer yes or no.";;
esac esac
done done
mkdir ${compressedmapsdir} mkdir ${compressedmapsdir} > /dev/null 2>&1
rm -rfv ${filesdir}/Maps/*.uz2 rm -rfv ${filesdir}/Maps/*.unr.uz
cd ${systemdir} cd ${systemdir}
./ucc-bin compress ../Maps/* --nohomedir for map in `ls ${filesdir}/Maps`; do
mv -fv ${filesdir}/Maps/*.uz2 ${compressedmapsdir} ./ucc-bin compress ../Maps/${map} --nohomedir
done
mv -fv ${filesdir}/Maps/*.unr.uz ${compressedmapsdir}
} }
fn_logmanager(){ fn_logmanager(){
if [ ! -e ${consolelog} ];then
touch ${consolelog}
fi
# log manager will active if finds logs older than ${logdays} # log manager will active if finds logs older than ${logdays}
if [ `find ${scriptlogdir}/* -mtime +${logdays} |wc -l` -ne "0" ];then if [ `find ${scriptlogdir}/* -mtime +${logdays} |wc -l` -ne "0" ];then
echo -e "[\e[0;32m OK \e[0;39m] Starting log cleaner" echo -e "[\e[0;32m OK \e[0;39m] Starting log cleaner"
@ -110,8 +116,8 @@ if [ `find ${scriptlogdir}/* -mtime +${logdays} |wc -l` -ne "0" ];then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Removing logs older than ${logdays} days" >> ${scriptlog} echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Removing logs older than ${logdays} days" >> ${scriptlog}
find ${scriptlogdir}/* -mtime +${logdays} |tee >> ${scriptlog} find ${scriptlogdir}/* -mtime +${logdays} |tee >> ${scriptlog}
find ${consolelogdir}/* -mtime +${logdays} |tee >> ${scriptlog} find ${consolelogdir}/* -mtime +${logdays} |tee >> ${scriptlog}
scriptcount=`find ${scriptlogdir}/* -mtime +${logdays}|wc -l` scriptcount=$(find ${scriptlogdir}/* -mtime +${logdays}|wc -l)
consolecount=`find ${consolelogdir}/* -mtime +${logdays}|wc -l` consolecount=$(find ${consolelogdir}/* -mtime +${logdays}|wc -l)
count=$((${scriptcount} + ${consolecount})) count=$((${scriptcount} + ${consolecount}))
find ${scriptlogdir}/* -mtime +${logdays} -exec rm {} \; find ${scriptlogdir}/* -mtime +${logdays} -exec rm {} \;
find ${consolelogdir}/* -mtime +${logdays} -exec rm {} \; find ${consolelogdir}/* -mtime +${logdays} -exec rm {} \;
@ -300,7 +306,7 @@ if [ -f /etc/lsb-release ]; then
elif [ -f /etc/debian_version ]; then elif [ -f /etc/debian_version ]; then
os="Debian $(cat /etc/debian_version)" os="Debian $(cat /etc/debian_version)"
elif [ -f /etc/redhat-release ]; then elif [ -f /etc/redhat-release ]; then
os=`cat /etc/redhat-release` os=$(cat /etc/redhat-release)
else else
os="$(uname -s) $(uname -r)" os="$(uname -s) $(uname -r)"
fi fi
@ -379,7 +385,7 @@ if [ -f serverquery.py ];then
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: serverquery.py detected" >> ${scriptlog} echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: serverquery.py detected" >> ${scriptlog}
echo -e "[\e[0;32m OK \e[0;39m] Querying ${servicename}: ${servername}: QUERYING" echo -e "[\e[0;32m OK \e[0;39m] Querying ${servicename}: ${servername}: QUERYING"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: QUERYING" >> ${scriptlog} echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: QUERYING" >> ${scriptlog}
serverquery=`./serverquery.py 127.0.0.1 ${port} 2>&1` serverquery=$(./serverquery.py 127.0.0.1 ${port} 2>&1)
sleep 1 sleep 1
if [ "${serverquery}" = "ERROR 1" ]||[ "${serverquery}" = "ERROR 2" ]||[ "${serverquery}" = "ERROR 3" ];then if [ "${serverquery}" = "ERROR 1" ]||[ "${serverquery}" = "ERROR 2" ]||[ "${serverquery}" = "ERROR 3" ];then
echo -e "[\e[0;31m FAIL \e[0;39m] Querying ${servicename}: ${servername}: ${serverquery}" echo -e "[\e[0;31m FAIL \e[0;39m] Querying ${servicename}: ${servername}: ${serverquery}"
@ -404,7 +410,7 @@ fn_logmanager
echo -en "[ .... ] Monitor is checking ${servicename}: ${servername}" echo -en "[ .... ] Monitor is checking ${servicename}: ${servername}"
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor is checking ${servername}" >> ${scriptlog} echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor is checking ${servername}" >> ${scriptlog}
sleep 0.5 sleep 0.5
updatecheck=`ps -ef|grep "${selfname} update"|grep -v grep|wc -l` updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l)
if [ "${updatecheck}" = "0" ];then if [ "${updatecheck}" = "0" ];then
fn_runcheck fn_runcheck
echo -en "\r[\e[1;33m WARN \e[0;39m] ${servicename}: Monitor detected ${servername} had stopped!\n" echo -en "\r[\e[1;33m WARN \e[0;39m] ${servicename}: Monitor detected ${servername} had stopped!\n"
@ -464,7 +470,7 @@ mv ${scriptlog} ${scriptlogdate}
mv ${consolelog} ${consolelogdate} mv ${consolelog} ${consolelogdate}
cd ${systemdir} cd ${systemdir}
tmux new-session -d -s ${servicename} "./ucc-bin ${parms} |tee -a ${consolelog}" tmux new-session -d -s ${servicename} "./ucc-bin ${parms} |tee -a ${consolelog}"
tmuxwc=`tmux list-sessions 2>&1|awk '{print $1}'|grep ${servicename}|wc -l` tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep ${servicename}|wc -l)
sleep 1 sleep 1
if [ ${tmuxwc} -eq 0 ];then if [ ${tmuxwc} -eq 0 ];then
echo -en "\r[\e[0;31m FAIL \e[0;39m] Starting ${servicename}: Failed to start ${servername}" echo -en "\r[\e[0;31m FAIL \e[0;39m] Starting ${servicename}: Failed to start ${servername}"
@ -507,7 +513,7 @@ fi
echo "Running MD5 checksum to verify ut-server-436.tar.gz" echo "Running MD5 checksum to verify ut-server-436.tar.gz"
sleep 1 sleep 1
echo "MD5 checksum: 10cd7353aa9d758a075c600a6dd193fd" echo "MD5 checksum: 10cd7353aa9d758a075c600a6dd193fd"
md5check=`md5sum ut-server-436.tar.gz| awk '{print $1;}'` md5check=$(md5sum ut-server-436.tar.gz| awk '{print $1;}')
echo "File returned: ${md5check}" echo "File returned: ${md5check}"
if [ "${md5check}" != "10cd7353aa9d758a075c600a6dd193fd" ];then if [ "${md5check}" != "10cd7353aa9d758a075c600a6dd193fd" ];then
echo "MD5 checksum: FAILED!" echo "MD5 checksum: FAILED!"
@ -528,7 +534,7 @@ fi
echo "Running MD5 checksum to verify UTPGPatch451.tar.bz2" echo "Running MD5 checksum to verify UTPGPatch451.tar.bz2"
sleep 1 sleep 1
echo "MD5 checksum: 77a735a78b1eb819042338859900b83b" echo "MD5 checksum: 77a735a78b1eb819042338859900b83b"
md5check=`md5sum UTPGPatch451.tar.bz2| awk '{print $1;}'` md5check=$(md5sum UTPGPatch451.tar.bz2| awk '{print $1;}')
echo "File returned: ${md5check}" echo "File returned: ${md5check}"
if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ];then if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ];then
echo "MD5 checksum: FAILED!" echo "MD5 checksum: FAILED!"

Loading…
Cancel
Save