@ -3,7 +3,7 @@
# Server Management Script
# Author: Daniel Gibbs
# Website: http://danielgibbs.co.uk
# Version: 0110 13
# Version: 1 01113
#### Variables ####
@ -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"
@ -73,6 +73,7 @@ if [ ${tmuxwc} -eq 1 ];then
exit
fi
}
fn_compressmaps(){
fn_rootcheck
clear
@ -94,14 +95,24 @@ 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"
@ -110,8 +121,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}
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 {} \;
@ -148,7 +159,12 @@ echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: Started ${servername} debug
sleep 0.5
echo -en "\n"
cd ${systemdir}
if [ `getconf LONG_BIT` = "64" ]
then
./ucc-bin-linux-amd64 ${parms}
else
./ucc-bin ${parms}
fi
}
fn_console(){
@ -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
@ -379,7 +395,7 @@ if [ -f serverquery.py ];then
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`
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}"
@ -404,7 +420,7 @@ fn_logmanager
echo -en "[ .... ] Monitor is checking ${servicename}: ${servername}"
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"
@ -463,9 +479,14 @@ fn_logmanager
mv ${scriptlog} ${scriptlogdate}
mv ${consolelog} ${consolelogdate}
cd ${systemdir}
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}"
tmuxwc=`tmux list-sessions 2>&1|awk '{print $1}'|grep ${servicename}|wc -l`
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}
@ -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!"
@ -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