Browse Source

UT2K4server: Added support for 64-bit binary

* Script detects if OS is 64-bit and and uses ucc-bin-linux-amd64 binary
instead
* 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
02460b745f
  1. 121
      UnrealTournament2004/ut2k4server

121
UnrealTournament2004/ut2k4server

@ -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="ut2k4-server"
gamename="Unreal Tournament 2004"
engine="unreal2"
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,39 @@ while true; do
* ) echo "Please answer yes or no.";;
esac
done
mkdir ${compressedmapsdir}
mkdir ${compressedmapsdir} > /dev/null 2>&1
rm -rfv ${filesdir}/Maps/*.uz2
cd ${systemdir}
./ucc-bin compress ../Maps/* --nohomedir
for map in `ls ${filesdir}/Maps`; do
if [ `getconf LONG_BIT` = "64" ]
then
./ucc-bin-linux-amd64 compress ../Maps/${map} --nohomedir
else
./ucc-bin compress ../Maps/${map} --nohomedir
fi
done
mv -fv ${filesdir}/Maps/*.uz2 ${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,14 +152,19 @@ 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}
./ucc-bin ${parms}
if [ `getconf LONG_BIT` = "64" ]
then
./ucc-bin-linux-amd64 ${parms}
else
./ucc-bin ${parms}
fi
}
fn_console(){
@ -175,7 +191,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 +241,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 +316,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 +373,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 +381,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 +392,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 +418,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 +433,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 +454,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,22 +472,27 @@ 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
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`
if [ `getconf LONG_BIT` = "64" ]
then
tmux new-session -d -s ${servicename} "./ucc-bin-linux-amd64 ${parms} |tee -a ${consolelog}"
else
tmux new-session -d -s ${servicename} "./ucc-bin ${parms} |tee -a ${consolelog}"
fi
sleep 1
tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep ${servicename}|wc -l)
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"
@ -496,7 +517,6 @@ fn_filesdl(){
echo ""
echo "Downloading Server Files"
echo "============================"
cd ${rootdir}
mkdir ${filesdir}
cd ${filesdir}
@ -508,7 +528,7 @@ fi
echo "Running MD5 checksum to verify the file"
sleep 1
echo "MD5 checksum: d3f28c5245c4c02802d48e4f0ffd3e34"
md5check=`md5sum dedicatedserver3339-bonuspack.zip| awk '{print $1;}'`
md5check=$(md5sum dedicatedserver3339-bonuspack.zip| awk '{print $1;}')
echo "File returned: ${md5check}"
if [ "${md5check}" != "d3f28c5245c4c02802d48e4f0ffd3e34" ];then
echo "MD5 checksum: FAILED!"
@ -529,7 +549,7 @@ fi
echo "Running MD5 checksum to verify the file"
sleep 1
echo "MD5 checksum: 0fa447e05fe5a38e0e32adf171be405e"
md5check=`md5sum ut2004-lnxpatch3369-2.tar.bz2| awk '{print $1;}'`
md5check=$(md5sum ut2004-lnxpatch3369-2.tar.bz2| awk '{print $1;}')
echo "File returned: ${md5check}"
if [ "${md5check}" != "0fa447e05fe5a38e0e32adf171be405e" ];then
echo "MD5 checksum: FAILED!"
@ -581,7 +601,7 @@ while true; do
[Yy]* ) break;;
[Nn]* ) echo Exiting; return 1 ;;
* ) echo "Please answer yes or no.";;
esac
esac
done
fn_header
fn_filesdl
@ -590,7 +610,7 @@ echo ""
echo "Installing ${gamename} Server"
echo "================================="
sleep 1
mkdir -v ${filesdir}
mkdir -v ${filesdir}
cd ${filesdir}
echo "Extracting dedicatedserver3339-bonuspack.zip"
sleep 1
@ -598,8 +618,6 @@ echo "================================="
echo "ut2004-lnxpatch3369-2.tar.bz2"
sleep 1
tar -xvjf ut2004-lnxpatch3369-2.tar.bz2 UT2004-Patch/ --strip-components=1
cd ${systemdir}
chmod +x ucc-bin
while true; do
read -p "Was the install successful? [y/N]" yn
case $yn in
@ -608,7 +626,6 @@ echo "================================="
* ) echo "Please answer yes or no.";;
esac
done
cd ${filesdir}
while true; do
read -p "Remove ut2004-lnxpatch3369-2.tar.bz2? [y/N]" yn
case $yn in
@ -715,4 +732,4 @@ case "$1" in
echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}"
exit 1;;
esac
exit
exit
Loading…
Cancel
Save