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. 98
      UnrealTournament99/ut99server

98
UnrealTournament99/ut99server

@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 011013
# Version: 101113
#### Variables ####
@ -13,7 +13,7 @@ emailnotification="off"
email="[email protected]"
# Directorys
rootdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
selfname="$0"
filesdir="${rootdir}/serverfiles"
systemdir="${filesdir}/System"
@ -25,7 +25,7 @@ servicename="ut99-server"
gamename="Unreal Tournament 99"
engine="unreal"
ini="${servicename}.ini"
servername=`grep -s ServerName= ${systemdir}/${ini} | sed 's/ServerName=//g'`
servername=$(grep -s ServerName= ${systemdir}/${ini} | sed 's/ServerName=//g')
# Logging
logdays="7"
@ -67,12 +67,13 @@ tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep ${servicen
if [ ${tmuxwc} -eq 1 ];then
fn_serverquery
echo -en "\r[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} is already running"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already running" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already running" >> ${scriptlog}
sleep 0.5
echo -en "\n"
exit
fi
}
fn_compressmaps(){
fn_rootcheck
clear
@ -94,29 +95,34 @@ while true; do
* ) echo "Please answer yes or no.";;
esac
done
mkdir ${compressedmapsdir}
rm -rfv ${filesdir}/Maps/*.uz2
mkdir ${compressedmapsdir} > /dev/null 2>&1
rm -rfv ${filesdir}/Maps/*.unr.uz
cd ${systemdir}
./ucc-bin compress ../Maps/* --nohomedir
mv -fv ${filesdir}/Maps/*.uz2 ${compressedmapsdir}
for map in `ls ${filesdir}/Maps`; do
./ucc-bin compress ../Maps/${map} --nohomedir
done
mv -fv ${filesdir}/Maps/*.unr.uz ${compressedmapsdir}
}
fn_logmanager(){
if [ ! -e ${consolelog} ];then
touch ${consolelog}
fi
# log manager will active if finds logs older than ${logdays}
if [ `find ${scriptlogdir}/* -mtime +${logdays} |wc -l` -ne "0" ];then
echo -e "[\e[0;32m OK \e[0;39m] Starting log cleaner"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting log cleaner" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting log cleaner" >> ${scriptlog}
echo -e "[\e[0;36m INFO \e[0;39m] Removing logs older than ${logdays} days"
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 ${consolelogdir}/* -mtime +${logdays} |tee >> ${scriptlog}
scriptcount=`find ${scriptlogdir}/* -mtime +${logdays}|wc -l`
consolecount=`find ${consolelogdir}/* -mtime +${logdays}|wc -l`
scriptcount=$(find ${scriptlogdir}/* -mtime +${logdays}|wc -l)
consolecount=$(find ${consolelogdir}/* -mtime +${logdays}|wc -l)
count=$((${scriptcount} + ${consolecount}))
find ${scriptlogdir}/* -mtime +${logdays} -exec rm {} \;
find ${consolelogdir}/* -mtime +${logdays} -exec rm {} \;
echo -e "[\e[0;36m INFO \e[0;39m] Log cleaner removed ${count} log files"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Log cleaner removed ${count} log files" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Log cleaner removed ${count} log files" >> ${scriptlog}
fi
}
@ -141,10 +147,10 @@ esac
done
fn_stopserver
echo -en "[ .... ] Starting ${servicename}: ${servername} debug mode"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} debug mode" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} debug mode" >> ${scriptlog}
sleep 0.5
echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} debug mode" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} debug mode" >> ${scriptlog}
sleep 0.5
echo -en "\n"
cd ${systemdir}
@ -175,7 +181,7 @@ sleep 0.5
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep ${servicename}|wc -l)
if [ ${tmuxwc} -eq 1 ];then
echo -e "\r[\e[0;32m OK \e[0;39m] Starting ${servicename} console"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} console accessed" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} console accessed" >> ${scriptlog}
sleep 1
tmux attach-session -t ${servicename}
else
@ -225,17 +231,17 @@ if [ ${tmuxwc} -eq 1 ];then
done
fi
echo -en "[ .... ] Starting ${servicename}: ${servername} backup"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} backup" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername} backup" >> ${scriptlog}
sleep 0.5
echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername} backup"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} backup" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} backup" >> ${scriptlog}
sleep 1
echo -en "\n"
cd ${rootdir}
mkdir ${backupdir} > /dev/null 2>&1
tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude '${backupdir}' ${rootdir}
tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude '${backupdir}' ${rootdir}
echo -en "\r${servicename} backup complete"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: backup complete" >> ${scriptlog}
}
fn_details(){
@ -300,7 +306,7 @@ if [ -f /etc/lsb-release ]; then
elif [ -f /etc/debian_version ]; then
os="Debian $(cat /etc/debian_version)"
elif [ -f /etc/redhat-release ]; then
os=`cat /etc/redhat-release`
os=$(cat /etc/redhat-release)
else
os="$(uname -s) $(uname -r)"
fi
@ -357,7 +363,7 @@ echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Sent email notification to ${
fn_emailtest(){
fn_rootcheck
fn_syscheck
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Emailing test notification" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Emailing test notification" >> ${scriptlog}
if [ "${emailnotification}" = "on" ];then
subject="${servicename} Email Test Notification - Testing ${servername}"
failurereason="Testing ${servicename} email notification"
@ -365,7 +371,7 @@ if [ "${emailnotification}" = "on" ];then
fn_emailnotification
else
echo -e "[\e[0;31m FAIL \e[0;39m] Email notification not enabled"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Email notification not enabled" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Email notification not enabled" >> ${scriptlog}
fi
sleep 0.5
echo -en "\n"
@ -376,22 +382,22 @@ fn_serverquery(){
# detects if the server locks up
if [ -f serverquery.py ];then
echo -e "[\e[0;36m INFO \e[0;39m] serverquery.py detected"
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 "$( date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: QUERYING" >> ${scriptlog}
serverquery=`./serverquery.py 127.0.0.1 ${port} 2>&1`
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: QUERYING" >> ${scriptlog}
serverquery=$(./serverquery.py 127.0.0.1 ${port} 2>&1)
sleep 1
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 "$( date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: ${serverquery}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: ${serverquery}" >> ${scriptlog}
sleep 1
echo -e "[\e[1;33m WARN \e[0;39m] ${servicename}: Monitor detected ${servername} has locked up!"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} has locked up!" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} has locked up!" >> ${scriptlog}
sleep 1
fn_restartserver
else
echo -e "[\e[0;32m OK \e[0;39m] Querying ${servicename}: ${servername}: ${serverquery}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: ${serverquery}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying ${servername}: ${serverquery}" >> ${scriptlog}
sleep 1
fi
fi
@ -402,13 +408,13 @@ fn_rootcheck
fn_syscheck
fn_logmanager
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
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
fn_runcheck
echo -en "\r[\e[1;33m WARN \e[0;39m] ${servicename}: Monitor detected ${servername} had stopped!\n"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} had stopped!" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} had stopped!" >> ${scriptlog}
if [ "${emailnotification}" = "on" ];then
subject="${servicename} Monitor - Starting ${servername}"
failurereason="${servicename} process was not running"
@ -417,18 +423,18 @@ if [ "${updatecheck}" = "0" ];then
fi
sleep 0.5
echo -en "\n"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Monitor is starting ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor is starting ${servername}" >> ${scriptlog}
fn_startserver
else
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: Monitor detected ${servername} is currently checking for updates!"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} is currently checking for updates!" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor detected ${servername} is currently checking for updates!" >> ${scriptlog}
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} will start when updating is complete"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} will start when updating is complete" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} will start when updating is complete" >> ${scriptlog}
fi
}
fn_restartserver(){
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Restarting ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Restarting ${servername}" >> ${scriptlog}
fn_stopserver
fn_startserver
}
@ -438,15 +444,15 @@ fn_rootcheck
fn_syscheck
pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep ${servicename}|wc -l)
echo -en "[ .... ] Stopping ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Stopping ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Stopping ${servername}" >> ${scriptlog}
sleep 0.5
if [ "${pid}" == "0" ];then
echo -en "\r[\e[0;31m FAIL \e[0;39m] Stopping ${servicename}: ${servername} is already stopped"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already stopped" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already stopped" >> ${scriptlog}
else
tmux kill-session -t ${servicename}
echo -en "\r[\e[0;32m OK \e[0;39m] Stopping ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Stopped ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Stopped ${servername}" >> ${scriptlog}
fi
sleep 0.5
echo -en "\n"
@ -456,7 +462,7 @@ fn_startserver(){
fn_rootcheck
fn_syscheck
echo -en "[ .... ] Starting ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername}" >> ${scriptlog}
sleep 0.5
fn_runcheck
fn_logmanager
@ -464,14 +470,14 @@ mv ${scriptlog} ${scriptlogdate}
mv ${consolelog} ${consolelogdate}
cd ${systemdir}
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
if [ ${tmuxwc} -eq 0 ];then
echo -en "\r[\e[0;31m FAIL \e[0;39m] Starting ${servicename}: Failed to start ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: failed to start ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: failed to start ${servername}" >> ${scriptlog}
else
echo -en "\r[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}"
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Started ${servername}" >> ${scriptlog}
echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername}" >> ${scriptlog}
fi
sleep 0.5
echo -en "\n"
@ -507,7 +513,7 @@ fi
echo "Running MD5 checksum to verify ut-server-436.tar.gz"
sleep 1
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}"
if [ "${md5check}" != "10cd7353aa9d758a075c600a6dd193fd" ];then
echo "MD5 checksum: FAILED!"
@ -528,7 +534,7 @@ fi
echo "Running MD5 checksum to verify UTPGPatch451.tar.bz2"
sleep 1
echo "MD5 checksum: 77a735a78b1eb819042338859900b83b"
md5check=`md5sum UTPGPatch451.tar.bz2| awk '{print $1;}'`
md5check=$(md5sum UTPGPatch451.tar.bz2| awk '{print $1;}')
echo "File returned: ${md5check}"
if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ];then
echo "MD5 checksum: FAILED!"
@ -580,7 +586,7 @@ while true; do
[Yy]* ) break;;
[Nn]* ) echo Exiting; return 1 ;;
* ) echo "Please answer yes or no.";;
esac
esac
done
fn_header
fn_filesdl

Loading…
Cancel
Save