#!/bin/bash # Counter Strike: Global Offensive # Server Management Script # Author: Daniel Gibbs # Website: http://danielgibbs.co.uk # Version: 010115 #### Variables #### # Notification Email # (on|off) emailnotification="off" email="email@example.com" # Steam login steamuser="anonymous" steampass="" # Start Variables # https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Dedicated_Servers#Starting_the_Server # [Game Modes] gametype gamemode # Arms Race 1 0 # Classic Casual 0 0 # Classic Competitive 0 1 # Demolition 1 1 # Deathmatch 1 2 gamemode="0" gametype="0" defaultmap="de_dust2" mapgroup="random_classic" maxplayers="16" tickrate="64" port="27015" sourcetvport="27020" clientport="27005" ip="0.0.0.0" # Optional: Workshop Parameters # https://developer.valvesoftware.com/wiki/CSGO_Workshop_For_Server_Operators # To get an authkey visit - http://steamcommunity.com/dev/apikey # authkey="" # ws_collection_id="" # ws_start_map="" # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server fn_parms(){ parms="-game csgo -usercon -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} -tickrate ${tickrate} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers_override ${maxplayers} +mapgroup ${mapgroup} +game_mode ${gamemode} +game_type ${gametype} +host_workshop_collection ${ws_collection_id} +workshop_start_map ${ws_start_map} -authkey ${authkey}" } #### Advanced Variables #### # Steam appid="740" # Server Details servicename="csgo-server" gamename="Counter Strike: Global Offensive" engine="source" # Directories rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )" selfname="$0" lockselfname=$(echo ".${servicename}.lock") filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/csgo" executabledir="${filesdir}" executable="./srcds_run" servercfgdir="${systemdir}/cfg" servercfg="${servicename}.cfg" servercfgfullpath="${servercfgdir}/${servercfg}" defaultcfg="${servercfgdir}/server.cfg" backupdir="backups" # Server Details servername=$(grep -s hostname "${servercfgfullpath}"|sed 's/hostname //g'|sed 's/"//g') rcon=$(grep -s rcon_password "${servercfgfullpath}"|sed 's/rcon_password //g'|sed 's/"//g') # Logging logdays="7" gamelogdir="${systemdir}/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 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_csgofix fn_header fn_details fn_installcomplete } fn_functions(){ # Functions are defines in fn_functions. functionfile="${FUNCNAME}" fn_runfunction } fn_runfunction(){ # Functions are downloaded and run with this function if [ ! -f "${rootdir}/functions/${functionfile}" ]; then cd "${rootdir}" if [ ! -d "functions" ]; then mkdir functions fi cd functions echo -e "loading ${functionfile}...\c" wget -N --no-check-certificate /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgameservers/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- chmod +x "${functionfile}" cd "${rootdir}" sleep 1 fi source "${rootdir}/functions/${functionfile}" } fn_functions case "$1" in start) fn_startserver;; stop) fn_stopserver;; restart) fn_restartserver;; update) norestart=1; fn_versioncheck;; update-restart) fn_versioncheck;; 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;; *) echo "Usage: $0 {start|stop|restart|update|update-restart|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}" exit 1;; esac exit