| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- #!/bin/bash
- # Red Orchestra: Ostfront 41-45
- # Server Management Script
- # Author: Daniel Gibbs
- # Website: http://danielgibbs.co.uk
- # Version: 011214
- #### Variables ####
- # Notification Email
- # (on|off)
- emailnotification="off"
- email="email@example.com"
- # Steam login
- steamuser="username"
- steampass="password"
- # Steam
- appid="223250"
- # Directories
- rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
- selfname="$0"
- lockselfname=$(echo ".${servicename}.lock")
- filesdir="${rootdir}/serverfiles"
- systemdir="${filesdir}/system"
- executabledir="${systemdir}"
- executable="./ucc-bin"
- compressedmapsdir="${rootdir}/Maps-Compressed"
- defaultcfg="${systemdir}/default.ini"
- backupdir="backups"
- # Server Details
- servicename="ro-server"
- gamename="Red Orchestra: Ostfront 41-45"
- engine="unreal2"
- ini="${servicename}.ini"
- servername=$(grep -s ServerName= ${systemdir}/${ini}|sed 's/ServerName=//g')
- ip="0.0.0.0"
- # Logging
- logdays="7"
- gamelogdir="${rootdir}/log/server"
- scriptlogdir="${rootdir}/log/script"
- consolelogdir="${rootdir}/log/console"
- gamelog="${gamelogdir}/${servicename}-game.log"
- scriptlog="${scriptlogdir}/${servicename}-script.log"
- consolelog="${consolelogdir}/${servicename}-console.log"
- emaillog="${scriptlogdir}/${servicename}-email.log"
- gamelogdate="${gamelogdir}/${servicename}-game-$(date '+%d-%m-%Y-%H-%M-%S').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="RO-Arad.rom"
- parms="server ${defaultmap}?game=ROGame.ROTeamGame?VACSecured=true -nohomedir ini=${ini} log=${gamelog}"
- }
- ##### Script #####
- # Do not edit
- # unless you know
- # what you are doing
- fn_scriptlog(){
- echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${1}" >> "${scriptlog}"
- }
- # [ FAIL ]
- fn_printfail(){
- echo -en "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
- }
- fn_printfailnl(){
- echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] $@"
- }
- # [ OK ]
- fn_printok(){
- echo -en "\r\033[K[\e[0;32m OK \e[0;39m] $@"
- }
- fn_printoknl(){
- echo -e "\r\033[K[\e[0;32m OK \e[0;39m] $@"
- }
- # [ INFO ]
- fn_printinfo(){
- echo -en "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
- }
- fn_printinfonl(){
- echo -e "\r\033[K[\e[0;36m INFO \e[0;39m] $@"
- }
- # [ WARN ]
- fn_printwarn(){
- echo -en "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
- }
- fn_printwarnnl(){
- echo -e "\r\033[K[\e[1;33m WARN \e[0;39m] $@"
- }
- # [ .... ]
- fn_printdots(){
- echo -en "\r\033[K[ .... ] $@"
- }
- fn_rootcheck(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_syscheck(){
- if [ ! -e "${systemdir}" ]; then
- fn_printfailnl "Cannot access ${systemdir}: No such directory"
- exit
- fi
- }
- fn_autoip(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_logmanager(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_debugserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_console(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_backupserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_distro(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_uptime(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_load(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_emailnotification(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_emailtest(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_serverquery(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_monitorserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_updateserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_validateserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_restartserver(){
- fn_scriptlog "Restarting ${servername}"
- fn_stopserver
- fn_startserver
- }
- fn_stopserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_startserver(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_details(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_runfunction(){
- # Download function if missing
- if [ ! -f "${rootdir}/functions/${functionfile}" ]; then
- cd "${rootdir}"
- if [ ! -d "functions" ]; then
- mkdir functions
- fi
- echo "loading ${functionfile}..."
- cd functions
- wget --no-check-certificate -nv -N https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile}
- chmod +x "${functionfile}"
- cd "${rootdir}"
- sleep 1
- echo ""
- fi
- # Run function
- source "${rootdir}/functions/${functionfile}"
- }
- fn_unreal2compressmaps(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- #
- ## Installer
- #
- fn_rofix(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_header(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_steamdl(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_steaminstall(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_steamfix(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_loginstall(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_getquery(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_retryinstall(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_serverdirectory(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_serverconfig(){
- functionfile="${FUNCNAME}"
- fn_runfunction
- }
- fn_install(){
- fn_rootcheck
- fn_header
- if [ -z "${autoinstall}" ]; then
- fn_serverdirectory
- fn_header
- fi
- fn_steamdl
- fn_steaminstall
- fn_steamfix
- fn_loginstall
- fn_getquery
- fn_serverconfig
- fn_rofix
- fn_header
- fn_details
- echo "================================="
- echo "Install Complete!"
- echo ""
- echo "To start server type:"
- echo "${selfname} start"
- echo ""
- }
- fn_autoinstall(){
- autoinstall=1
- fn_install
- }
- case "$1" in
- start)
- fn_startserver;;
- stop)
- fn_stopserver;;
- restart)
- fn_restartserver;;
- update)
- fn_updateserver;;
- update-restart)
- fn_stopserver
- fn_updateserver
- fn_startserver;;
- validate)
- fn_validateserver;;
- validate-restart)
- fn_stopserver
- fn_validateserver
- fn_startserver;;
- monitor)
- fn_monitorserver;;
- email-test)
- fn_emailtest;;
- details)
- fn_details;;
- backup)
- fn_backupserver;;
- console)
- fn_console;;
- debug)
- fn_debugserver;;
- install)
- fn_install;;
- auto-install)
- fn_autoinstall;;
- map-compressor)
- fn_unreal2compressmaps;;
- *)
- echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install|map-compressor}"
- exit 1;;
- esac
- exit
|