From 44456606a2ff7ce779caeba8cc2cdfbabbcf1b31 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Mon, 6 Jan 2014 23:06:42 +0000 Subject: [PATCH] added csczserver --- CounterStrike/csserver | 1 - CounterStrikeConditionZero/csczserver | 754 ++++++++++++++++++++++++++ 2 files changed, 754 insertions(+), 1 deletion(-) create mode 100644 CounterStrikeConditionZero/csczserver diff --git a/CounterStrike/csserver b/CounterStrike/csserver index f2fa55184..5284533c6 100644 --- a/CounterStrike/csserver +++ b/CounterStrike/csserver @@ -664,7 +664,6 @@ echo "=================================" echo -e "pausable 0" echo -e "" echo -e "// default server name. Change to \"Bob's Server\", etc." - echo -e "hostname \"${servername}\"" echo -e "" echo -e "// maximum client movement speed " diff --git a/CounterStrikeConditionZero/csczserver b/CounterStrikeConditionZero/csczserver new file mode 100644 index 000000000..97dcc7c3b --- /dev/null +++ b/CounterStrikeConditionZero/csczserver @@ -0,0 +1,754 @@ +#!/bin/bash +# Counter Strike: Condition Zero +# Server Management Script +# Author: Daniel Gibbs +# Website: http://danielgibbs.co.uk +# Version: 060113 + +#### Variables #### + +# Notification Email +# (on|off) +emailnotification="off" +email="email@example.com" + +# Start Variables +defaultmap="de_aztec" +port="27015" +clientport="27005" +maxplayers="16" +ip="0.0.0.0" +# https://developer.valvesoftware.com/wiki/Command_Line_Options#Command-line_parameters_2 +parms="-game czero +map ${defaultmap} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} -maxplayers ${maxplayers}" + +#### Advanced Variables #### + +# Steam +appid="90 -beta beta +app_set_config 90 mod czero" + +# Server Details +servicename="cscz-server" +gamename="Counter Strike: Condition Zero" +engine="goldsource" + +# Directorys +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" +selfname="$0" +filesdir="${rootdir}/serverfiles" +servercfg="${filesdir}/czero/${servicename}.cfg" +backupdir="backups" + +# Server Details +servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') +rcon=$(grep -s rcon_password ${servercfg} | sed 's/rcon_password //g'|sed 's/"//g') + +# Logging +logdays="7" +gamelogdir="${filesdir}/czero/logs" +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" + +##### Script ##### +# Do not edit +# unless you know +# what you are doing + +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 ${filesdir} ]; then + echo -e "\r\033[K[\e[0;31m FAIL \e[0;39m] Cannot access ${filesdir}: No such directory" + exit +fi +} + +fn_autoip(){ +# Identifies the server interface IP +# If multiple interfaces this will need to be set manually +getip=$(/sbin/ifconfig | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'|grep -v 127.0.0.1) +getipwc=$(/sbin/ifconfig | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'|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 interfaces.\n\n" + echo -en "Manually specify the IP in ${selfname}\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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting log cleaner" >> ${scriptlog} + sleep 1 + 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} + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Log cleaner removed ${count} log files" >> ${scriptlog} +fi +} + +fn_debugserver(){ +fn_rootcheck +fn_syscheck +fn_autoip +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 "" +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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started debug mode ${servername} " >> ${scriptlog} +sleep 0.5 +echo -en "\n" +cd ${filesdir} +./hlds_run ${parms} -debug +} + +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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Console accessed" >> ${scriptlog} + 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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Backup started" >> ${scriptlog} +sleep 1 +echo -en "\n" +cd ${rootdir} +mkdir ${backupdir} > /dev/null 2>&1 +tar -cvzf ${backupdir}/${backupname}.tar.gz --exclude ${backupdir} * +echo -en "\r\033[K${servicename} Backup complete" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Backup complete" >> ${scriptlog} +} + +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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Sent email notification to ${email}" >> ${scriptlog} +sleep 1 +echo -en "\n" +} + +fn_emailtest(){ +fn_rootcheck +fn_syscheck +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" + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Email notification not enabled" >> ${scriptlog} +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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Detected gsquery.py " >> ${scriptlog} + sleep 1 + echo -en "\r\033[K[ .... ] Monitoring ${servicename}: Querying port: ${ip}:${port}: QUERYING" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying port: ${ip}:${port}: QUERYING" >> ${scriptlog} + 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}" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying port: ${ip}:${port}: ${serverquery}" >> ${scriptlog} + sleep 1 + echo -en "\n" + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying port: ${ip}:${port}: OK" >> ${scriptlog} + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying port: ${ip}:${port}: ./gsquery.py: Permission denied" >> ${scriptlog} + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Querying port: ${ip}:${port}: UNKNOWN ERROR" >> ${scriptlog} + 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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitoring ${servername}" >> ${scriptlog} +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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Checking session: CHECKING" >> ${scriptlog} + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Checking session: OK" >> ${scriptlog} + 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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Checking session: FAIL" >> ${scriptlog} + 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 + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Monitor is starting ${servername}" >> ${scriptlog} + fn_startserver + fi +else + echo -e "[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: Detected SteamCMD is checking for updates" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Detected SteamCMD is checking for updates" >> ${scriptlog} + sleep 1 + echo -e "[\e[0;36m INFO \e[0;39m] Monitoring ${servicename}: When updates complete ${servicename} will start" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: When updates complete ${servicename} will start" >> ${scriptlog} +fi +} + +fn_updateserver(){ +fn_rootcheck +fn_syscheck +echo -en "\r\033[K[ .... ] Updating ${servicename}: ${servername}" +sleep 0.5 +echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Updating ${servicename}: ${servername}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Updating ${servername}" >> ${scriptlog} +cd ${rootdir} +cd steamcmd +./steamcmd.sh +login anonymous +force_install_dir ${filesdir} +app_update ${appid} validate +quit |tee -a ${scriptlog} +} + +fn_restartserver(){ +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Restarting ${servername}" >> ${scriptlog} +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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Stopping ${servername}" >> ${scriptlog} +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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already stopped" >> ${scriptlog} +else + tmux kill-session -t ${servicename} + echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Stopping ${servicename}: ${servername}" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Stopped ${servername}" >> ${scriptlog} +fi +sleep 0.5 +echo -en "\n" +} + +fn_startserver(){ +fn_rootcheck +fn_syscheck +fn_autoip +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}" +echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Starting ${servername}" >> ${scriptlog} +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" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: ${servername} is already running" >> ${scriptlog} + sleep 0.5 + echo -en "\n" + exit +fi +cd ${filesdir} +tmux new-session -d -s ${servicename} "./hlds_run ${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}" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: failed to start ${servername}" >> ${scriptlog} +else + echo -en "\r\033[K[\e[0;32m OK \e[0;39m] Starting ${servicename}: ${servername}" + echo -e "$(date '+%b %d %H:%M:%S') ${servicename}: Started ${servername}" >> ${scriptlog} +fi +sleep 0.5 +echo -en "\n" +} + +fn_details(){ +echo "" +echo "${gamename} Server Details" +echo "============================" +echo "" +echo "${servername} Ports" +echo "=======================" +servername=$(grep -s hostname ${servercfg} | sed 's/hostname //g'|sed 's/"//g') +rcon=$(grep -s rcon_password ${servercfg} | sed 's/rcon_password //g'|sed 's/"//g') +echo "Ports the server is currently using" +echo "" +echo "DIRECTION DESCRIPTION PORT" +echo "INBOUND Game/Rcon Port ${port}" +if [ "${engine}" = "source" ]; then + echo "INBOUND SourceTV Port ${sourcetvport}" +fi +echo "OUTBOUND Client Port ${clientport}" +echo "" +echo "You can change ports by editing the" +echo "start parameters in ${selfname}" +echo "" +echo "${servername} Details" +echo "=======================" +echo "Server name: ${servername}" +echo "Rcon Password: ${rcon}" +echo "" +echo "Config file:" +echo "${servercfg}" +echo "" +} + +# +## Installer +# + +fn_header(){ +clear +echo "=================================" +echo "${gamename}" +echo "Server Linux Installer" +echo "by Daniel Gibbs" +echo "http://danielgibbs.co.uk" +echo "=================================" +echo "" +} + +fn_steamdl(){ +echo "Installing Steam" +echo "=================================" +cd ${rootdir} +mkdir steamcmd +cd steamcmd +if [ ! -f steamcmd.sh ]; then + wget http://media.steampowered.com/client/steamcmd_linux.tar.gz + tar --verbose -zxf steamcmd_linux.tar.gz + rm -v steamcmd_linux.tar.gz + chmod +x steamcmd.sh +else + echo "Steam already installed!" +fi +} + +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]* ) break;; + [Nn]* ) echo Exiting; return 1;; + * ) echo "Please answer yes or no.";; + esac + done +fi +fn_header +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_steamdl +echo "" +echo "Installing ${gamename} Server" +echo "=================================" + rm -f ${servercfg} + mkdir -v ${filesdir} + echo "" + echo "Downloading appmanifest files (app 90 fix)" + echo "=================================" + sleep 2 + mkdir -v ${filesdir}/1ea271ace3aa6eb2cbade5b6f37851d19ffb9e6f + cd ${filesdir}/1ea271ace3aa6eb2cbade5b6f37851d19ffb9e6f + wget https://raw.github.com/dgibbs64/linuxgameservers/master/CounterStrikeConditionZero/appmanifest/appmanifest_10.acf + wget https://raw.github.com/dgibbs64/linuxgameservers/master/CounterStrikeConditionZero/appmanifest/appmanifest_70.acf + wget https://raw.github.com/dgibbs64/linuxgameservers/master/CounterStrikeConditionZero/appmanifest/appmanifest_80.acf + wget https://raw.github.com/dgibbs64/linuxgameservers/master/CounterStrikeConditionZero/appmanifest/appmanifest_90.acf + echo "Downloading appmanifest files (app 90 fix)" + echo "" + echo "Installing ${gamename} Server" + echo "=================================" + cd ${rootdir}/steamcmd + touch install.txt + chmod 0600 install.txt + echo "login anonymous" > install.txt + echo "force_install_dir ${filesdir}" >> install.txt + echo "app_update ${appid} validate" >> install.txt + echo "quit" >> install.txt + STEAMEXE=steamcmd ./steamcmd.sh +runscript install.txt + STEAMEXE=steamcmd ./steamcmd.sh +runscript install.txt + STEAMEXE=steamcmd ./steamcmd.sh +runscript install.txt + rm install.txt + echo "" + echo "=================================" + 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 +fn_header +echo "Configuring ${gamename} Server" +echo "=================================" + read -p "Enter server name: " servername + read -p "Enter rcon password: " rconpass + sleep 1 + echo "" + echo "Creating server.cfg" + touch ${filesdir}/czero/server.cfg + echo "exec ${servicename}.cfg" > ${filesdir}/czero/server.cfg + sleep 1 + echo "Creating default config file:" + sleep 0.5 + echo "${servercfg}" + touch ${servercfg} + touch ${filesdir}/czero/listip.cfg + touch ${filesdir}/czero/banned.cfg + { + echo -e "// Use this file to configure your DEDICATED server." + echo -e "// This config file is executed on server start." + echo -e "" + echo -e "// disable autoaim" + echo -e "sv_aim 0" + echo -e "" + echo -e "// disable clients' ability to pause the server" + echo -e "pausable 0" + echo -e "" + echo -e "// default server name. Change to \"Bob's Server\", etc." + echo -e "hostname \"${servername}\"" + echo -e "" + echo -e "// maximum client movement speed " + echo -e "sv_maxspeed 320" + echo -e "" + echo -e "// 20 minute timelimit" + echo -e "mp_timelimit 20" + echo -e "" + echo -e "// cheats off" + echo -e "sv_cheats 0" + echo -e "" + echo -e "// load ban files" + echo -e "exec listip.cfg" + echo -e "exec banned.cfg" + echo -e "" + echo -e "// rcon passsword" + echo -e "rcon_password \"${rconpass}\"" + echo -e "" + echo -e "// Server password" + echo -e "sv_password \"\"" + echo -e "" + echo -e "// server logging" + echo -e "log on" + echo -e "sv_logbans 1" + echo -e "sv_logecho 1" + echo -e "sv_logfile 1" + echo -e "sv_log_onefile 0" + }|tee ${servercfg} > /dev/null 2>&1 + sleep 1 + echo "" + echo "Creating log directorys" + mkdir -v ${rootdir}/log + mkdir -v ${scriptlogdir} + mkdir -v ${consolelogdir} + touch ${consolelog} + if [ ! -h ${rootdir}/log/server ]; then + ln -sv ${gamelogdir} ${rootdir}/log/server + else + echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!" + fi + sleep 1 + echo "" + echo "Applying steamclient.so fix" + mkdir -v ${HOME}/.steam + mkdir -v ${HOME}/.steam/sdk32 + cp -v ${filesdir}/steamclient.so ${HOME}/.steam/sdk32/steamclient.so + sleep 1 + fn_header + fn_details + 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;; + update) + fn_stopserver + fn_updateserver + fn_startserver;; + monitor) + fn_monitorserver;; + email-test) + fn_emailtest;; + details) + fn_details;; + backup) + fn_backupserver;; + console) + fn_console;; + debug) + fn_debugserver;; + install) + fn_install;; + *) + echo "Usage: $0 {start|stop|restart|update|monitor|email-test|details|backup|console|debug|install}" + exit 1;; +esac +exit \ No newline at end of file