diff --git a/Insurgency/cfg/servers/.gitignore b/Insurgency/cfg/servers/.gitignore new file mode 100644 index 000000000..fbba9e662 --- /dev/null +++ b/Insurgency/cfg/servers/.gitignore @@ -0,0 +1,3 @@ +* +!.gitignore +!_default.cfg diff --git a/Insurgency/cfg/servers/_default.cfg b/Insurgency/cfg/servers/_default.cfg new file mode 100644 index 000000000..5777a26cf --- /dev/null +++ b/Insurgency/cfg/servers/_default.cfg @@ -0,0 +1,22 @@ +# Default config - Changes will be overwritten by updates. +# Your settings for all servers go in _common.cfg +# Server-specific settings go into $SERVER.cfg +appid="237410" +beta="" #To enable beta, use " -beta beta" +clientport="27005" +defaultmap="ministry" +defaultmode="checkpoint" +email="email@example.com" +emailnotification="off" # (on|off) +ip="0.0.0.0" +lgsm_version="031115" +logdays="7" +mapcyclefile="mapcycle.txt" +maxplayers="16" +playlist="custom" +port="27015" +sourcetvport="27020" +srcds_parms="" +steampass="" +steamuser="anonymous" +updateonstart="off" diff --git a/Insurgency/insserver b/Insurgency/insserver old mode 100644 new mode 100755 index f5a69ebbb..844ca742b --- a/Insurgency/insserver +++ b/Insurgency/insserver @@ -3,46 +3,87 @@ # Server Management Script # Author: Daniel Gibbs # Website: http://gameservermanagers.com -version="291015" +version="031115" #### Variables #### -# Notification Email -# (on|off) -emailnotification="off" -email="email@example.com" +# The name of this script file, used to show the LGSM link properly +selfname=$(basename $(readlink -f "${BASH_SOURCE[0]}")) -# Steam login -steamuser="anonymous" -steampass="" +# Directories +rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +scriptcfgdir="${rootdir}/cfg/servers" + +# Settings to get before config parsing begins +engine="source" +game="insurgency" +gamename="Insurgency" +servicename="$(basename $0)" + +#ipaddr=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') -# Start Variables +# Config files +cfg_default="${scriptcfgdir}/_default.cfg" +cfg_common="${scriptcfgdir}/_common.cfg" +cfg_instance="${scriptcfgdir}/${servicename}.cfg" + +#If config directory does not exist, create it +if [ ! -e $scriptcfgdir ]; then mkdir -p "$scriptcfgdir"; fi + +# If default config does not exist, create it. This should come from Git, and will be overwritten by updates. +# Rather than try to wget it from Github or other fancy ways to get it, the simplest way to ensure it works is to simply create it here. +fn_create_default_config(){ +cat <<'EOF' >> $cfg_default +# Default config - Changes will be overwritten by updates. +# Your settings for all servers go in _common.cfg +# Server-specific settings go into $SERVER.cfg +appid="237410" +beta="" #To enable beta, use " -beta beta" +clientport="27005" defaultmap="ministry" +defaultmode="checkpoint" +email="email@example.com" +emailnotification="off" # (on|off) +ip="0.0.0.0" +lgsm_version="031115" +logdays="7" +mapcyclefile="mapcycle.txt" maxplayers="16" +playlist="custom" port="27015" sourcetvport="27020" -clientport="27005" -ip="0.0.0.0" +srcds_parms="" +steampass="" +steamuser="anonymous" updateonstart="off" +EOF +} +if [ ! -f $cfg_default ] +then + fn_create_default_config +fi + +# Load defaults +source $cfg_default +#If defaults are from an older version, overwrite the file +if [ "${lgsm_version}" != "${version}" ]; then fn_create_default_config; fi + +# Load sitewide common settings (so that Git updates can safely overwrite default.cfg) +if [ ! -f $cfg_common ]; then touch $cfg_common; else source $cfg_common; fi + +# Load instance specific settings +if [ ! -f $cfg_instance ]; then touch $cfg_instance; else source $cfg_instance; fi + +# Set the paramaters to send to srcds # https://developer.valvesoftware.com/wiki/Command_Line_Options#Source_Dedicated_Server fn_parms(){ -parms="-game insurgency -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +map ${defaultmap} +servercfgfile ${servercfg} -maxplayers ${maxplayers}" +#TODO: Put in some conditional logic to handle generating the parm string so we can make this a little less game specific +parms="-game ${game} -strictportbind -ip ${ip} -port ${port} +clientport ${clientport} +tv_port ${sourcetvport} +sv_playlist ${playlist} +mapcyclefile ${mapcyclefile}+servercfgfile ${servercfg} +map ${defaultmap} ${defaultmode} -maxplayers ${maxplayers} ${srcds_parms}" } #### Advanced Variables #### - -# Steam -appid="237410" - -# Server Details -servicename="ins-server" -gamename="Insurgency" -engine="source" - # Directories -rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -selfname="$(basename $0)" lockselfname=".${servicename}.lock" filesdir="${rootdir}/serverfiles" systemdir="${filesdir}/insurgency" @@ -54,8 +95,10 @@ servercfgfullpath="${servercfgdir}/${servercfg}" servercfgdefault="${servercfgdir}/lgsm-default.cfg" backupdir="${rootdir}/backups" +#In the event that you have library issues after an update, this may resolve it. +#export LD_LIBRARY_PATH="${filesdir}:${filesdir}/bin:${LD_LIBRARY_PATH}" + # Logging -logdays="7" gamelogdir="${systemdir}/logs" scriptlogdir="${rootdir}/log/script" consolelogdir="${rootdir}/log/console" @@ -71,19 +114,19 @@ consolelogdate="${consolelogdir}/${servicename}-console-$(date '+%d-%m-%Y-%H-%M- # Do not edit fn_runfunction(){ +functiondir="${rootdir}/functions" +functionpath"${functiondir}/${functionfile}" # Functions are downloaded and run with this function -if [ ! -f "${rootdir}/functions/${functionfile}" ]; then - cd "${rootdir}" - if [ ! -d "functions" ]; then - mkdir functions +if [ ! -f "${functionpath}" ]; then +# cd "${rootdir}" + if [ ! -d "${functiondir}" ]; then + mkdir -p "${functiondir}" fi - cd functions echo -e " loading ${functionfile}...\c" - wget -N /dev/null https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45- - chmod +x "${functionfile}" - cd "${rootdir}" + wget -N /dev/null "https://raw.githubusercontent.com/dgibbs64/linuxgsm/master/functions/${functionfile}" -O "${functionpath}" 2>&1 | grep -F HTTP | cut -c45- + chmod +x "${functionpath}" fi -source "${rootdir}/functions/${functionfile}" +source "${functionpath}" } fn_functions(){