#!/bin/bash # Unreal Tournament 99 # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk # Version: 010214 #### Variables #### # Notification Email # (on|off) emailnotification="off" email="email@example.com" # Directorys rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/System" executabledir="${systemdir}" executable="./ucc-bin" compressedmapsdir="${rootdir}/Maps-Compressed" defaultcfg="${systemdir}/Default.ini" backupdir="backups" # Server Details servicename="ut99-server" gamename="Unreal Tournament 99" engine="unreal" ini="${servicename}.ini" servername=$(grep -s ServerName= ${systemdir}/${ini}|sed 's/ServerName=//g') ip="0.0.0.0" # Logging logdays="7" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" scriptlog="${scriptlogdir}/${servicename}-script.log" consolelog="${consolelogdir}/${servicename}-console.log" emaillog="${scriptlogdir}/${servicename}-email.log" scriptlogdate="${scriptlogdir}/${servicename}-script-$(date '+%d-%m-%Y-%H-%M-%S').log" consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M-%S').log" # Start Variables fn_parms(){ defaultmap="DM-Deck16][" parms="server ${defaultmap}.unr ini=${systemdir}/${ini}" } ##### Script ##### # Do not edit # unless you know # what you are doing fn_scriptlog(){ echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: '$1'" >> ${scriptlog} } fn_rootcheck(){ if [ `whoami` = "root" ]; then echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Script will not run as root!" exit fi } fn_syscheck(){ if [ ! -e "${systemdir}" ]; then echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Cannot access ${systemdir}: No such directory" exit fi } fn_autoip(){ # Identifies the server interface IP # If multiple interfaces this will need to be set manually getip=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1) getipwc=$(ip -o -4 addr|awk '{print $4 }'|grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}'|grep -v 127.0.0.1|wc -l) if [ "${ip}" == "0.0.0.0" ]||[ "${ip}" == "" ]; then if [ "${getipwc}" -ge "2" ]; then echo -en "[\e[1;33m WARN \e[0;39m] Multiple active network interfaces.\n\n" echo -en "Manually specify the IP you want to use within the ${selfname} script.\n" echo -en "Set ip=\"0.0.0.0\" to one of the following:\n" echo -en "${getip}\n" exit else ip=${getip} fi fi } 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 "\r\033[K[\e[0;32m OK \e[0;39m] Starting log cleaner" fn_scriptlog "Starting log cleaner" sleep 1 echo -e "[\e[0;36m INFO \e[0;39m] Removing logs older than ${logdays} days" fn_scriptlog "Removing logs older than ${logdays} days" sleep 1 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) 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" fn_scriptlog "Log cleaner removed ${count} log files" fi } fn_debugserver(){ fn_rootcheck fn_syscheck fn_autoip fn_parms echo "" echo "${gamename} Debug" echo "============================" echo "" echo -e "Use for identifying server issues only!" echo -e "Press CTRL+c to drop out of debug mode" echo -e "\e[0;31mWARNING!\e[0;39m If ${servicename} is already running it will be stopped" echo "" echo "Start parameters:" echo ${parms} echo "" while true; do read -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done fn_stopserver echo -en "\r\033[K[ .... ] Starting debug mode ${servicename}: ${servername}" sleep 0.5 echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Starting debug mode ${servicename}: ${servername}" fn_scriptlog "Started debug mode ${servername}" sleep 0.5 echo -en "\n" cd "${executabledir}" ${executable} ${parms} } fn_console(){ fn_rootcheck fn_syscheck echo "" echo "${gamename} Console" echo "============================" echo "" echo "Press \"CTRL+b d\" to exit console" echo -e "\e[0;31mWARNING!\e[0;39m Do NOT press CTRL+c to exit" echo "" while true; do read -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done echo -en "\r\033[K[ .... ] Starting ${servicename} console" sleep 0.5 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then echo -e "\r\033[K[\e[0;32m OK \e[0;39m] Starting ${servicename} console" fn_scriptlog "Console accessed" sleep 1 tmux attach-session -t ${servicename} else echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Starting ${servicename} console: ${servername} not running" sleep 0.5 while true; do read -p "Do you want to start the server? [y/N]" yn case $yn in [Yy]* ) fn_startserver;break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done fi } fn_backupserver(){ fn_rootcheck fn_syscheck backupname="${servicename}-$(date '+%Y-%m-%d-%H%M%S')" echo "" echo "${gamename} Backup" echo "============================" echo "" echo "The following backup will be created." echo "" echo "${backupdir}/${backupname}.tar.gz" echo "" while true; do read -p "Continue? [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then echo -e "\e[0;31mWARNING!\e[0;39m ${servicename} is currently running" while true; do read -p "Would you like to stop ${servicename} while running the backup? [y/N]" yn case $yn in [Yy]* ) fn_stopserver;break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done fi echo -en "\r\033[K[ .... ] Starting backup ${servicename}: ${servername}" sleep 1 echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Starting backup ${servicename}: ${servername}" fn_scriptlog "Backup started" sleep 1 echo -en "\n" cd "${rootdir}" mkdir -pv "${backupdir}" > /dev/null 2>&1 tar -cvzf "${backupdir}/${backupname}.tar.gz" --exclude "${backupdir}" * echo -en "\r\033[K${servicename} Backup complete" fn_scriptlog "Backup complete" } fn_distro(){ arch=$(uname -m) kernel=$(uname -r) if [ -f /etc/lsb-release ]; then os=$(lsb_release -s -d) elif [ -f /etc/debian_version ]; then os="Debian $(cat /etc/debian_version)" elif [ -f /etc/redhat-release ]; then os=$(cat /etc/redhat-release) else os="$(uname -s) $(uname -r)" fi } fn_uptime(){ uptime=$( /dev/null 2>&1 tail -25 "${scriptlog}" >> "${emaillog}" if [ ! -z "${consolelog}" ]; then echo -e "\n\nConsole log\n====================\n" >> "${emaillog}" tail -25 "${consolelog}" >> "${emaillog}" fi if [ ! -z "${gamelogdir}" ]; then echo -e "\n\nServer log\n====================\n" >> "${emaillog}" tail "${gamelogdir}"/*|grep -v "==>"|sed '/^$/d'|tail -25 >> "${emaillog}" fi mail -s "${subject}" ${email} < "${emaillog}" echo -en "[\e[0;36m INFO \e[0;39m] Sent email notification to ${email}" fn_scriptlog "Sent email notification to ${email}" sleep 1 echo -en "\n" } fn_emailtest(){ fn_rootcheck fn_syscheck fn_scriptlog "Emailing test notification" if [ "${emailnotification}" = "on" ]; then subject="${servicename} Email Test Notification - Testing ${servername}" failurereason="Testing ${servicename} email notification" actiontaken="Sent test email...hello is this thing on?" fn_emailnotification else echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Email notification not enabled" fn_scriptlog "Email notification not enabled" fi sleep 0.5 echo -en "\n" } fn_serverquery(){ # uses gsquery.py to directly query the server # detects if the server locks up if [ -f gsquery.py ]; then if [ "${engine}" == "unreal" ]||[ "${engine}" == "unreal2" ]; then gameport=$(grep Port= ${systemdir}/${ini}|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|sed 's/\Port=//g') port=$((${gameport} + 1)) elif [ "${engine}" == "spark" ]; then port=$((${port} + 1)) fi echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Detected gsquery.py" fn_scriptlog "Detected gsquery.py" sleep 1 echo -en "\r\033[K[ .... ] Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" fn_scriptlog "Querying port: ${ip}:${port}: QUERYING" serverquery=$(./gsquery.py -a ${ip} -p ${port} -e ${engine} 2>&1) exitcode=$? sleep 1 if [ "${exitcode}" == "1" ]||[ "${exitcode}" == "2" ]||[ "${exitcode}" == "3" ]||[ "${exitcode}" == "4" ]; then echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Querying port: ${ip}:${port}: ${serverquery}" fn_scriptlog "Querying port: ${ip}:${port}: ${serverquery}" sleep 1 echo -en "\n" if [[ -z "${secondquery}" ]]; then echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Waiting 30 seconds to re-query" fn_scriptlog "Waiting 30 seconds to re-query" sleep 30 secondquery=1 fn_serverquery fi if [ "${emailnotification}" = "on" ]; then subject="${servicename} Monitor - Starting ${servername}" failurereason="Failed to query ${servicename}: ${serverquery}" actiontaken="restarted ${servicename}" fn_emailnotification fi fn_restartserver exit elif [ "${exitcode}" == "0" ]; then echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Monitoring ${servicename}: Querying port: ${ip}:${port}: OK" fn_scriptlog "Querying port: ${ip}:${port}: OK" sleep 1 echo -en "\n" exit elif [ "${exitcode}" == "126" ]; then echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Querying port: ${ip}:${port}: ERROR: ./gsquery.py: Permission denied" fn_scriptlog "Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" sleep 1 echo -en "\n" echo "Attempting to resolve automatically" chmod +x -v gsquery.py exitcode=$? if [ "${exitcode}" == "0" ]; then fn_serverquery else echo -en "\nUnable to resolve automatically. Please manually fix permissions\n" owner=$(ls -al gsquery.py|awk '{ print $3 }') echo "As user ${owner} or root run the following command" whoami=$(whoami) echo -en "\nchown ${whoami}:${whoami} gsquery.py\n\n" exit fi else echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" fn_scriptlog "Querying port: ${ip}:${port}: UNKNOWN ERROR" sleep 1 echo -en "\n" ./gsquery.py -a ${ip} -p ${port} -e ${engine} exit fi fi } fn_monitorserver(){ fn_rootcheck fn_syscheck fn_autoip echo -en "\r\033[K[ .... ] Monitoring ${servicename}: ${servername}" fn_scriptlog "Monitoring ${servername}" sleep 1 updatecheck=$(ps -ef|grep "${selfname} update"|grep -v grep|wc -l) if [ "${updatecheck}" = "0" ]; then echo -en "\r\033[K[ .... ] Monitoring ${servicename}: Checking session: CHECKING" fn_scriptlog "Checking session: CHECKING" sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 1 ]; then echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Monitoring ${servicename}: Checking session: OK" fn_scriptlog "Checking session: OK" sleep 1 echo -en "\n" fn_serverquery exit else echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Monitoring ${servicename}: Checking session: FAIL" fn_scriptlog "Checking session: FAIL" sleep 1 echo -en "\n" if [ "${emailnotification}" = "on" ]; then subject="${servicename} Monitor - Starting ${servername}" failurereason="${servicename} process not running" actiontaken="${servicename} has been restarted" fn_emailnotification fi fn_scriptlog "Monitor is starting ${servername}" fn_startserver fi else echo -e "[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Detected SteamCMD is checking for updates" fn_scriptlog "Detected SteamCMD is checking for updates" sleep 1 echo -e "[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: When updates complete ${servicename} will start" fn_scriptlog "When updates complete ${servicename} will start" fi } fn_restartserver(){ fn_scriptlog "Restarting ${servername}" fn_stopserver fn_startserver } fn_stopserver(){ fn_rootcheck fn_syscheck pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) echo -en "\r\033[K[ .... ] Stopping ${servicename}: ${servername}" fn_scriptlog "Stopping ${servername}" sleep 0.5 if [ "${pid}" == "0" ]; then echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Stopping ${servicename}: ${servername} is already stopped" fn_scriptlog "${servername} is already stopped" else tmux kill-session -t ${servicename} echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Stopping ${servicename}: ${servername}" fn_scriptlog "Stopped ${servername}" fi sleep 0.5 echo -en "\n" } fn_startserver(){ fn_rootcheck fn_syscheck fn_autoip fn_parms fn_logmanager tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -v failed|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then mv "${scriptlog}" "${scriptlogdate}" mv "${consolelog}" "${consolelogdate}" fi echo -en "\r\033[K[ .... ] Starting ${servicename}: ${servername}" fn_scriptlog "Starting ${servername}" sleep 0.5 if [ ${tmuxwc} -eq 1 ]; then echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] Starting ${servicename}: ${servername} is already running" fn_scriptlog "${servername} is already running" sleep 0.5 echo -en "\n" exit fi cd "${executabledir}" tmux new-session -d -s ${servicename} "${executable} ${parms}|tee -a '${consolelog}'" sleep 1 tmuxwc=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) if [ ${tmuxwc} -eq 0 ]; then echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] Starting ${servicename}: Failed to start ${servername}" fn_scriptlog "failed to start ${servername}" else echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}" fn_scriptlog "Started ${servername}" fi sleep 0.5 echo -en "\n" } fn_utdetails(){ fn_autoip pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l) gameport=$(grep Port= "${systemdir}/${ini}"|grep -v Master|grep -v LAN|grep -v Proxy|grep -v Listen|sed 's/\Port=//g') queryport=$((${gameport} + 1)) gsqueryport=$(grep OldQueryPortNumber= "${systemdir}/${ini}"|sed 's/\OldQueryPortNumber=//g') udplinkport=$((${gameport} + 2)) webadminport=$(grep ListenPort= "${systemdir}/${ini}"|sed 's/\ListenPort=//g') if [ "${engine}" == "unreal" ]; then webadminuser=$(grep AdminUsername= "${systemdir}/${ini}"|sed 's/\AdminUsername=//g') else webadminuser=$(grep AdminName= "${systemdir}/${ini}"|sed 's/\AdminName=//g') fi webadminpass=$(grep AdminPassword= "${systemdir}/${ini}"|sed 's/\AdminPassword=//g') echo "" echo "${gamename} Server Details" echo "============================" echo "" echo "Server name: ${servername}" echo "Server IP: ${ip}:${gameport}" echo "Config file: ${systemdir}/${ini}" echo "" echo "${servername} Ports" echo "=======================" echo "Ports the server is currently using" echo "" echo "DIRECTION DESCRIPTION PORT INI VARIABLE" echo "INBOUND Game Port ${gameport} UDP Port=${gameport}" echo "INBOUND Query Port ${queryport} UDP n/a" if [ "${engine}" == "unreal" ]; then echo "OUTBOUND UdpLink Port (random) ${udplinkport}+ UDP n/a" fi if [ "${engine}" != "unreal" ] && [ "${appid}" != "223250" ]; then echo "INBOUND GameSpy Query Port ${gsqueryport} UDP OldQueryPortNumber=${gsqueryport}" fi if [ "${appid}" == "215360" ]; then echo "OUTBOUND Master Server port 28852 TCP/UDP n/a" else echo "OUTBOUND Master Server port 28900/28902 TCP/UDP n/a" fi if [ "${appid}" ]; then if [ "${appid}" == "223250" ]; then echo "OUTBOUND Steam Port 20610 UDP n/a" else echo "OUTBOUND Steam Port 20660 UDP n/a" fi fi echo "INBOUND WebAdmin ${webadminport} TCP ListenPort=${webadminport}" echo "" echo "${servername} WebAdmin" echo "=======================" echo "WebAdmin URL: http://${ip}:${webadminport}" echo "WebAdmin Username: ${webadminuser}" echo "WebAdmin Password: ${webadminpass}" echo "" if [ "${pid}" == "0" ]; then echo -e "Status:\e[0;31m OFFLINE\e[0;39m" else echo -e "Status:\e[0;32m ONLINE\e[0;39m" fi echo "" } fn_ut99compressmaps(){ fn_rootcheck clear echo "${gamename} Map Compressor" echo "============================" echo "Will compress all maps in:" echo "" pwd echo "" echo "Compressed maps saved to:" echo "" echo "${compressedmapsdir}" echo "" while true; do read -p "Start compression [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done mkdir -pv "${compressedmapsdir}" > /dev/null 2>&1 rm -rfv "${filesdir}/Maps/*.unr.uz" cd "${systemdir}" for map in `ls "${filesdir}/Maps"`; do ./ucc-bin compress ../Maps/${map} --nohomedir done mv -fv "${filesdir}/Maps/*.unr.uz" "${compressedmapsdir}" } # ## Installer # fn_header(){ clear echo "=================================" echo "${gamename}" echo "Linux Game Server Manager" echo "by Daniel Gibbs" echo "http://danielgibbs.co.uk" echo "=================================" echo "" } fn_ut99filesdl(){ echo "Downloading Server Files" echo "=================================" cd "${rootdir}" mkdir -pv "${filesdir}" cd "${filesdir}" if [ ! -f ut-server-436.tar.gz ]; then wget http://danielgibbs.co.uk/wp-content/uploads/ut-server-436.tar.gz else echo "ut-server-436.tar.gz already downloaded!" fi echo "Running MD5 checksum to verify the file" sleep 1 echo "MD5 checksum: 10cd7353aa9d758a075c600a6dd193fd" md5check=$(md5sum ut-server-436.tar.gz| awk '{print $1;}') echo "File returned: ${md5check}" if [ "${md5check}" != "10cd7353aa9d758a075c600a6dd193fd" ]; then echo "MD5 checksum: FAILED!" read -p "Retry download? [y/N]" yn case $yn in [Yy]* ) rm -fv ut-server-436.tar.gz; fn_filesdl;; [Nn]* ) echo Exiting; exit;; * ) echo "Please answer yes or no.";; esac else echo "MD5 checksum: PASSED" fi if [ ! -f UTPGPatch451.tar.bz2 ]; then wget http://danielgibbs.co.uk/wp-content/uploads/UTPGPatch451.tar.bz2 else echo "UTPGPatch451.tar.bz2 already downloaded!" fi echo "Running MD5 checksum to verify the file" sleep 1 echo "MD5 checksum: 77a735a78b1eb819042338859900b83b" md5check=$(md5sum UTPGPatch451.tar.bz2| awk '{print $1;}') echo "File returned: ${md5check}" if [ "${md5check}" != "77a735a78b1eb819042338859900b83b" ]; then echo "MD5 checksum: FAILED!" read -p "Retry download? [y/N]" yn case $yn in [Yy]* ) rm -fv UTPGPatch451.tar.bz2; fn_filesdl;; [Nn]* ) echo Exiting; exit;; * ) echo "Please answer yes or no.";; esac else echo "MD5 checksum: PASSED" fi echo "" } fn_ut99install(){ echo "Installing ${gamename} Server" echo "=================================" sleep 1 mkdir -pv "${filesdir}" cd "${filesdir}" echo "Extracting ut-server-436.tar.gz" sleep 1 tar -zxvf ut-server-436.tar.gz ut-server/ --strip-components=1 echo "Extracting UTPGPatch451.tar.bz2" sleep 1 tar -jxvf UTPGPatch451.tar.bz2 while true; do read -p "Was the install successful? [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) fn_retryinstall;; * ) echo "Please answer yes or no.";; esac done while true; do read -p "Remove ut-server-436.tar.gz? [y/N]" yn case $yn in [Yy]* ) rm -fv ut-server-436.tar.gz;break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done while true; do read -p "Remove UTPGPatch451.tar.bz2? [y/N]" yn case $yn in [Yy]* ) rm -fv UTPGPatch451.tar.bz2; break;; [Nn]* ) break;; * ) echo "Please answer yes or no.";; esac done echo "" } fn_utloginstall(){ echo "Creating log directorys" echo "=================================" sleep 1 mkdir -pv "${rootdir}/log" mkdir -pv "${scriptlogdir}" touch "${scriptlog}" mkdir -pv "${consolelogdir}" touch "${consolelog}" sleep 1 echo "" } fn_retryinstall(){ while true; do read -p "Retry install? [y/N]" yn case $yn in [Yy]* ) fn_install;; [Nn]* ) echo Exiting; exit;; * ) echo "Please answer yes or no.";; esac done } fn_install(){ fn_rootcheck fn_header if [ -d "${filesdir}" ]; then echo "${gamename} Server is already installed here:" pwd echo "" while true; do read -p "Continue [y/N]" yn case $yn in [Yy]* ) fn_header; break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done fi echo "Install Directory:" pwd echo "" while true; do read -p "Continue [y/N]" yn case $yn in [Yy]* ) break;; [Nn]* ) echo Exiting; return 1;; * ) echo "Please answer yes or no.";; esac done fn_header fn_ut99filesdl fn_ut99install fn_utloginstall echo "Configuring ${gamename} Server" echo "=================================" sleep 1 echo "Copying "${defaultcfg}" to ${systemdir}/${ini}" tr -d '\r' < "${defaultcfg}" > ${systemdir}/${ini} sleep 1 echo "Enabling UdpServerUplink" { echo "[IpServer.UdpServerUplink]" echo "DoUplink=True" echo "UpdateMinutes=1" echo "MasterServerAddress=unreal.epicgames.com" echo "MasterServerPort=27900" echo "Region=0" }|tee -a ${systemdir}/${ini} > /dev/null 2>&1 sleep 1 echo "Removing dead mplayer.com master server" sed -i '/master.mplayer.com/d' ${systemdir}/${ini} sleep 1 echo "Inserting qtracker.com master server" sed -i '66i\ServerActors=IpServer.UdpServerUplink MasterServerAddress=master.qtracker.com MasterServerPort=27900' ${systemdir}/${ini} sleep 1 echo "Enabling WebAdmin" sed -i 's/bEnabled=False/bEnabled=True/g' ${systemdir}/${ini} sleep 1 echo "Setting WebAdmin port to 8076" sed -i '467i\ListenPort=8076' ${systemdir}/${ini} sleep 1 fn_header sleep 1 fn_utdetails sleep 1 echo "=================================" echo "Install Complete!" echo "" echo "To start server type:" echo "${selfname} start" echo "" } case "$1" in start) fn_startserver;; stop) fn_stopserver;; restart) fn_restartserver;; monitor) fn_monitorserver;; email-test) fn_emailtest;; details) fn_utdetails;; backup) fn_backupserver;; console) fn_console;; debug) fn_debugserver;; install) fn_install;; map-compressor) fn_ut2k4compressmaps;; *) echo "Usage: $0 {start|stop|restart|monitor|email-test|details|backup|console|debug|install|map-compressor}" exit 1;; esac exit