|
|
@@ -0,0 +1,153 @@
|
|
|
+#!/bin/bash
|
|
|
+# 7 Days To Die
|
|
|
+# Server Management Script
|
|
|
+# Author: Daniel Gibbs
|
|
|
+# Website: http://danielgibbs.co.uk
|
|
|
+# Version: 241214
|
|
|
+
|
|
|
+#### Variables ####
|
|
|
+
|
|
|
+# Notification Email
|
|
|
+# (on|off)
|
|
|
+emailnotification="off"
|
|
|
+email="email@example.com"
|
|
|
+
|
|
|
+# Steam login
|
|
|
+steamuser="username"
|
|
|
+steampass="password"
|
|
|
+
|
|
|
+# Start Variables
|
|
|
+ip="0.0.0.0"
|
|
|
+
|
|
|
+# http://7daystodie.gamepedia.com/Server
|
|
|
+fn_parms(){
|
|
|
+parms="-configfile=\"${servercfgfullpath}\" -dedicated"
|
|
|
+}
|
|
|
+
|
|
|
+#### Advanced Variables ####
|
|
|
+
|
|
|
+# Steam
|
|
|
+appid="294420"
|
|
|
+
|
|
|
+# Server Details
|
|
|
+servicename="sdtd-server"
|
|
|
+gamename="7 Days To Die"
|
|
|
+engine="unity3d"
|
|
|
+
|
|
|
+# Directories
|
|
|
+rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
|
+selfname="$0"
|
|
|
+lockselfname=$(echo ".${servicename}.lock")
|
|
|
+filesdir="${rootdir}/serverfiles"
|
|
|
+systemdir="${filesdir}"
|
|
|
+executabledir="${filesdir}"
|
|
|
+executable="./7DaysToDie.sh"
|
|
|
+servercfgdir="${filesdir}"
|
|
|
+servercfg="${servicename}.xml"
|
|
|
+servercfgfullpath="${servercfgdir}/${servercfg}"
|
|
|
+defaultcfg="${filesdir}/serverconfig.xml"
|
|
|
+backupdir="backups"
|
|
|
+
|
|
|
+# Server Details
|
|
|
+servername=$(grep ServerName "${servercfgfullpath}"|sed 's/^.*value="//'|cut -f1 -d"\"")
|
|
|
+
|
|
|
+# 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"
|
|
|
+
|
|
|
+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_loginstall
|
|
|
+fn_getquery
|
|
|
+fn_serverconfig
|
|
|
+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)
|
|
|
+ fn_update;;
|
|
|
+ auto-update)
|
|
|
+ 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|auto-update|validate|validate-restart|monitor|email-test|details|backup|console|debug|install|auto-install}"
|
|
|
+ exit 1;;
|
|
|
+esac
|
|
|
+exit
|