@ -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: 11 0813
# Version: 18 0813
#### Variables ####
#### Variables ####
@ -48,16 +48,43 @@ fi
}
}
fn_syscheck(){
fn_syscheck(){
if [ ! -e ${files dir} ];then
if [ ! -e ${system dir} ];then
echo -e "[\e[0;31m FAIL \e[0;39m] Cannot access ${files dir}: No such directory"
echo -e "[\e[0;31m FAIL \e[0;39m] Cannot access ${system dir}: No such directory"
exit
exit
fi
fi
}
}
fn_serverquery(){
# uses serverquery.py to directly query the server
# 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" >> ${logfile}
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" >> ${logfile}
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}" >> ${logfile}
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!" >> ${logfile}
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}" >> ${logfile}
sleep 1
fi
fi
}
fn_runcheck(){
fn_runcheck(){
# already running check
# already running check
pidwc=`screen -ls |grep ${servicename} |awk -F . '{print $1}'|awk '{print $1}'|wc -l`
pidwc=`screen -ls |grep ${servicename} |awk -F . '{print $1}'|awk '{print $1}'|wc -l`
if [ ${pidwc} -eq 1 ];then
if [ ${pidwc} -eq 1 ];then
fn_serverquery
echo -e "[\e[0;36m INFO \e[0;39m] ${servicename}: ${servername} is already running"
echo -e "[\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" >> ${logfile}
echo -e "$( date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already running" >> ${logfile}
exit
exit
@ -335,7 +362,7 @@ done
fn_install(){
fn_install(){
fn_rootcheck
fn_rootcheck
fn_header
fn_header
if [ -d ${files dir} ];then
if [ -d ${system dir} ];then
echo "${gamename} Server is already installed here:"
echo "${gamename} Server is already installed here:"
pwd
pwd
echo ""
echo ""
@ -389,36 +416,35 @@ echo "================================="
echo ""
echo ""
echo "Configuring ${gamename} Server"
echo "Configuring ${gamename} Server"
echo "================================="
echo "================================="
sleep 1
echo "Copying ${systemdir}/ut2004.ini to ${systemdir}/${ini}"
echo "Copying ${systemdir}/ut2004.ini to ${systemdir}/${ini}"
cp ${systemdir}/UT2004.ini ${systemdir}/${ini}
cp ${systemdir}/UT2004.ini ${systemdir}/${ini}
sleep 1
sleep 1
echo ""
echo ""
echo "Applying WebAdmin CharSet fix! "
echo "Creating log directory "
echo "http://forums.tripwireinteractive.com/showpost.php?p=442340&postcount=1"
mkdir -v ${logdir}
sleep 1
sleep 1
echo ""
echo ""
echo "Applying WebAdmin ut2003.css fix!"
echo "Applying WebAdmin ut2003.css fix!"
echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"
echo "http://forums.tripwireinteractive.com/showpost.php?p=585435&postcount=13"
sleep 1
sed -i 's/none}/none;/g' ${filesdir}/Web/ServerAdmin/ut2003.css
echo ""
sed -i 's/underline}/underline;/g' ${filesdir}/Web/ServerAdmin/ut2003.css
echo "Setting WebAdmin port to 8077"
sleep 1
sleep 1
echo ""
echo ""
echo "Setting WebAdmin username and password"
echo "Setting WebAdmin username and password"
sleep 1
echo ""
echo "Enabling Web Interface"
sleep 2
sed -i 's/CharSet="iso-8859-1"/CharSet="utf-8"/g' ${systemdir}/UWeb.int
sed -i 's/none}/none;/g' ${filesdir}/Web/ServerAdmin/ut2003.css
sed -i 's/underline}/underline;/g' ${filesdir}/Web/ServerAdmin/ut2003.css
sed -i 's/AdminName=/AdminName=admin/g' ${systemdir}/${ini}
sed -i 's/AdminName=/AdminName=admin/g' ${systemdir}/${ini}
sed -i 's/AdminPassword=/AdminPassword=utpass/g' ${systemdir}/${ini}
sed -i 's/AdminPassword=/AdminPassword=utpass/g' ${systemdir}/${ini}
sleep 1
echo ""
echo "Enabling WebAdmin"
sed -i 's/bEnabled=False/bEnabled=True/g' ${systemdir}/${ini}
sed -i 's/bEnabled=False/bEnabled=True/g' ${systemdir}/${ini}
sleep 1
echo ""
echo "Setting WebAdmin port to 8077"
sed -i 's/ListenPort=80/ListenPort=8077/g' ${systemdir}/${ini}
sed -i 's/ListenPort=80/ListenPort=8077/g' ${systemdir}/${ini}
mkdir ${logdir}
sleep 1
cd ${rootdir}
echo ""
echo ""
cd ${rootdir}
echo "Default Settings"
echo "Default Settings"
echo "=============================="
echo "=============================="
echo "WebAdmin Details:"
echo "WebAdmin Details:"
@ -438,6 +464,7 @@ echo "================================="
echo ""
echo ""
echo "To start server type:"
echo "To start server type:"
echo "${selfname} start"
echo "${selfname} start"
echo ""
}
}
case "$1" in
case "$1" in