Kaynağa Gözat

First release of pzserver

Project Zomboid server has its first release
Daniel Gibbs 11 yıl önce
ebeveyn
işleme
99e02e5000

+ 92 - 0
ProjectZomboid/pzserver

@@ -0,0 +1,92 @@
+#!/bin/bash
+# Project Zomboid
+# Server Management Script
+# Author: Daniel Gibbs
+# Website: http://danielgibbs.co.uk
+# Version: 150415
+
+#### Variables ####
+
+# Notification Email
+# (on|off)
+emailnotification="off"
+email="email@example.com"
+
+# Steam login
+steamuser="anonymous"
+steampass=""
+
+# Start Variables
+ip="0.0.0.0"
+
+fn_parms(){
+parms=""
+}
+
+#### Advanced Variables ####
+
+# Steam
+appid="108600"
+
+# Server Details
+servicename="pz-server"
+gamename="Project Zomboid"
+engine="projectzomboid"
+
+# Directories
+rootdir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+selfname="$(basename $0)"
+lockselfname=".${servicename}.lock"
+filesdir="${rootdir}/serverfiles"
+systemdir="${filesdir}/projectzomboid"
+executabledir="${filesdir}"
+executable="./projectzomboid-dedi-server.sh"
+servercfgdir="${rootdir}/Zomboid/Server"
+servercfg="servertest.ini"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+defaultcfg="${servercfgdir}/servertest.ini"
+backupdir="${rootdir}/backups"
+
+# Logging
+logdays="7"
+gamelogdir="${HOME}/Zomboid/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_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/linuxgsm/master/functions/${functionfile} 2>&1 | grep -F HTTP | cut -c45-
+	chmod +x "${functionfile}"
+	cd "${rootdir}"
+	sleep 1
+fi
+source "${rootdir}/functions/${functionfile}"
+}
+
+fn_functions(){
+# Functions are defined in fn_functions.
+functionfile="${FUNCNAME}"
+fn_runfunction
+}
+
+fn_functions
+
+getopt=$1
+fn_getopt

+ 10 - 1
functions/fn_check_logs

@@ -2,7 +2,7 @@
 # LGSM fn_check_logs function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 230215
+# Version: 160415
 # Description: Checks that log files exist on server start
 
 # Create dir's for the script and console logs
@@ -17,6 +17,12 @@ if [ ! -f "${scriptlog}" ]; then
 	touch "${scriptlog}"
 	mkdir -v "${consolelogdir}"
 	touch "${consolelog}"
+
+	# If a server is Project Zomboid create a symbolic link to the game server logs
+	if [ "${engine}" == "projectzomboid" ]; then
+		ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
+	fi
+
 	# If a server is source or goldsource create a symbolic link to the game server logs
 	if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 		if [ ! -h "${rootdir}/log/server" ]; then
@@ -25,6 +31,7 @@ if [ ! -f "${scriptlog}" ]; then
 			echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
 		fi
 	fi
+
 	# If a server is unreal2 or unity3d create a dir
 	if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]; then
 		mkdir -pv "${gamelogdir}"
@@ -34,6 +41,7 @@ if [ ! -f "${scriptlog}" ]; then
 			ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt"
 		fi
 	fi
+
 	# If a server is starbound create a symbolic link to the game server logs
 	if [ "${engine}" == "starbound" ]; then
 		if [ ! -h "${rootdir}/log/server" ]; then
@@ -42,6 +50,7 @@ if [ ! -f "${scriptlog}" ]; then
 			echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
 		fi
 	fi
+
 	# If server uses SteamCMD create a symbolic link to the Steam logs
 	if [ -d "${rootdir}/Steam/logs" ]; then
 		if [ ! -h "${rootdir}/log/steamcmd" ]; then

+ 30 - 1
functions/fn_details

@@ -2,7 +2,7 @@
 # LGSM fn_details function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 230214
+# Version: 160414
 
 # Description: Displays server infomation.
 
@@ -168,6 +168,33 @@ rm -f .fn_details_ports
 fn_details_statusbottom
 }
 
+fn_details_projectzomboid(){
+fn_check_ip
+fn_details_config
+fn_details_distro
+fn_details_os
+fn_details_performance
+fn_details_disk
+fn_details_gameserver
+fn_details_backup
+pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
+echo -e ""
+echo -e "\e[92mPorts\e[0m"
+printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' =
+echo -e "Change ports by editing the command-line"
+echo -e "parameters in ${selfname}."
+echo -e ""
+echo -e "Useful port diagnostic command:"
+echo -e "netstat -atunp | grep java"
+echo -e ""
+echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" >> .fn_details_ports
+echo -e "> Game/RCON\tINBOUND\t${port}\tudp" >> .fn_details_ports
+column -s $'\t' -t .fn_details_ports
+rm -f .fn_details_ports
+fn_details_statusbottom
+}
+
+
 fn_details_realvirtuality(){
 fn_check_ip
 pid=$(tmux list-sessions 2>&1|awk '{print $1}'|grep -E "^${servicename}:"|wc -l)
@@ -463,6 +490,8 @@ fn_details_statusbottom
 
 if [ "${engine}" == "avalanche" ]; then
 	fn_details_avalanche
+elif [ "${engine}" == "projectzomboid" ]; then
+	fn_details_projectzomboid
 elif [ "${engine}" == "realvirtuality" ]; then
 	fn_details_realvirtuality
 elif [ "${engine}" == "seriousengine35" ]; then

+ 7 - 2
functions/fn_details_config

@@ -2,12 +2,16 @@
 # LGSM fn_details_config function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 080215
+# Version: 160415
 
 # Description: Gets specific details from config files.
 
 if [ "${engine}" == "avalanche" ]; then
-	 servername=$(grep -s Name "${servercfgfullpath}"|sed 's/Name//g' | tr -d '=\"; '|sed 's/,//g')
+	 servername=$(grep -s Name "${servercfgfullpath}"|sed 's/Name//g'|tr -d '=\"; '|sed 's/,//g')
+
+elif [ "${engine}" == "projectzomboid" ]; then
+	servername=$(grep -s PublicName= "${servercfgfullpath}"|sed 's/PublicName=//g'|tr -d '=\";'|sed 's/,//g')
+	port=$(grep -s DefaultPort= "${servercfgfullpath}"|sed 's/DefaultPort=//g'|tr -cd [:digit:])
 
 elif [ "${engine}" == "realvirtuality" ]; then
 	servername=$(grep -s hostname "${servercfgfullpath}"| grep -v //|sed -e 's/\<hostname\>//g'| tr -d '=\"; ')
@@ -39,6 +43,7 @@ elif [ "${gamename}" == "Teamspeak 3" ]; then
 		queryport="10011"
 		fileport="30033"
 	fi
+
 elif [ "${engine}" == "unity3d" ]; then
 	servername=$(grep ServerName "${servercfgfullpath}"|sed 's/^.*value="//'|cut -f1 -d"\"")
 	port=$(grep ServerPort "${servercfgfullpath}"|tr -cd [:digit:])

+ 10 - 1
functions/fn_install_logs

@@ -2,7 +2,7 @@
 # LGSM fn_install_logs function
 # Author: Daniel Gibbs
 # Website: http://danielgibbs.co.uk
-# Version: 230215
+# Version: 160415
 
 echo ""
 echo "Creating log directorys"
@@ -14,6 +14,12 @@ mkdir -v "${scriptlogdir}"
 touch "${scriptlog}"
 mkdir -v "${consolelogdir}"
 touch "${consolelog}"
+
+# If a server is Project Zomboid create a symbolic link to the game server logs
+if [ "${engine}" == "projectzomboid" ]; then
+	ln -nfsv "${gamelogdir}" "${rootdir}/log/server"
+fi
+
 # If a server is source or goldsource create a symbolic link to the game server logs
 if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 	if [ ! -h "${rootdir}/log/server" ]; then
@@ -22,6 +28,7 @@ if [ "${engine}" == "source" ]||[ "${engine}" == "goldsource" ]; then
 		echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
 	fi
 fi
+
 # If a server is unreal2 or unity3d create a dir
 if [ "${engine}" == "unreal2" ]||[ "${engine}" == "unity3d" ]; then
 	mkdir -pv "${gamelogdir}"
@@ -31,6 +38,7 @@ if [ "${gamename}" == "7 Days To Die" ]; then
 		ln -nfsv "${filesdir}/7DaysToDie_Data/output_log.txt" "${gamelogdir}/output_log.txt"
 	fi
 fi
+
 # If a server is starbound create a symbolic link to the game server logs
 if [ "${engine}" == "starbound" ]; then
 	if [ ! -h "${rootdir}/log/server" ]; then
@@ -39,6 +47,7 @@ if [ "${engine}" == "starbound" ]; then
 		echo "Symbolic link ${gamelogdir} => ${rootdir}/log/server already exists!"
 	fi
 fi
+
 # If server uses SteamCMD create a symbolic link to the Steam logs
 if [ -d "${rootdir}/Steam/logs" ]; then
 	if [ ! -h "${rootdir}/log/steamcmd" ]; then