Просмотр исходного кода

feat(newserver): Vintage Story (#3156)

Co-authored-by: Daniel Gibbs <me@danielgibbs.co.uk>
Christian 5 лет назад
Родитель
Сommit
a0cbfc4957

+ 171 - 0
lgsm/config-default/config-lgsm/vintsserver/_default.cfg

@@ -0,0 +1,171 @@
+##################################
+######## Default Settings ########
+##################################
+# DO NOT EDIT, ANY CHANGES WILL BE OVERWRITTEN!
+# Copy settings from here and use them in either:
+# common.cfg - applies settings to every instance.
+# [instance].cfg - applies settings to a specific instance.
+
+#### Game Server Settings ####
+
+## Server Parameters | https://docs.linuxgsm.com/configuration/start-parameters#additional-parameters
+fn_parms(){
+parms="--datapath ${servercfgdir}"
+}
+
+## Release Settings | https://docs.linuxgsm.com/game-servers/vintagestory#release-settings
+# Branch (stable|unstable)
+branch="stable"
+
+#### LinuxGSM Settings ####
+
+## LinuxGSM Stats
+# Send useful stats to LinuxGSM developers.
+# https://docs.linuxgsm.com/configuration/linuxgsm-stats
+# (on|off)
+stats="off"
+
+## Notification Alerts
+# (on|off)
+
+# Display IP | https://docs.linuxgsm.com/alerts#display-ip
+displayip=""
+
+# More info | https://docs.linuxgsm.com/alerts#more-info
+postalert="off"
+
+# Discord Alerts | https://docs.linuxgsm.com/alerts/discord
+discordalert="off"
+discordwebhook="webhook"
+
+# Email Alerts | https://docs.linuxgsm.com/alerts/email
+emailalert="off"
+email="email@example.com"
+emailfrom=""
+
+# IFTTT Alerts | https://docs.linuxgsm.com/alerts/ifttt
+iftttalert="off"
+ifttttoken="accesstoken"
+iftttevent="linuxgsm_alert"
+
+# Mailgun Email Alerts | https://docs.linuxgsm.com/alerts/mailgun
+mailgunalert="off"
+mailgunapiregion="us"
+mailguntoken="accesstoken"
+mailgundomain="example.com"
+mailgunemailfrom="alert@example.com"
+mailgunemail="email@myemail.com"
+
+# Pushbullet Alerts | https://docs.linuxgsm.com/alerts/pushbullet
+pushbulletalert="off"
+pushbullettoken="accesstoken"
+channeltag=""
+
+# Pushover Alerts | https://docs.linuxgsm.com/alerts/pushover
+pushoveralert="off"
+pushovertoken="accesstoken"
+pushoveruserkey="userkey"
+
+# Rocket.Chat Alerts | https://docs.linuxgsm.com/alerts/rocket.chat
+rocketchatalert="off"
+rocketchatwebhook="webhook"
+rocketchattoken=""
+
+# Slack Alerts | https://docs.linuxgsm.com/alerts/slack
+slackalert="off"
+slackwebhook="webhook"
+
+# Telegram Alerts | https://docs.linuxgsm.com/alerts/telegram
+# You can add a custom cURL string eg proxy (useful in Russia) in "curlcustomstring".
+# For example "--socks5 ipaddr:port" for socks5 proxy see more in "curl --help".
+telegramalert="off"
+telegramtoken="accesstoken"
+telegramchatid=""
+curlcustomstring=""
+
+## Updating | https://docs.linuxgsm.com/commands/update
+updateonstart="off"
+
+## Backup | https://docs.linuxgsm.com/commands/backup
+maxbackups="4"
+maxbackupdays="30"
+stoponbackup="on"
+
+## Logging | https://docs.linuxgsm.com/features/logging
+consolelogging="on"
+logdays="7"
+
+## Monitor | https://docs.linuxgsm.com/commands/monitor
+# Query delay time
+querydelay="1"
+
+## ANSI Colors | https://docs.linuxgsm.com/features/ansi-colors
+ansi="on"
+
+#### Advanced Settings ####
+
+## Message Display Time | https://docs.linuxgsm.com/features/message-display-time
+sleeptime="0.5"
+
+## Stop Mode | https://docs.linuxgsm.com/features/stop-mode
+# 1: tmux kill
+# 2: CTRL+c
+# 3: quit
+# 4: quit 120s
+# 5: stop
+# 6: q
+# 7: exit
+# 8: 7 Days to Die
+# 9: GoldSrc
+# 10: Avorion
+# 11: end
+stopmode="2"
+
+## Query mode
+# 1: session only
+# 2: gamedig (gsquery fallback)
+# 3: gamedig
+# 4: gsquery
+# 5: tcp
+querymode="5"
+querytype=""
+
+## Console type
+consoleverbose="yes"
+consoleinteract="yes"
+
+## Game Server Details
+# Do not edit
+gamename="Vintage Story"
+engine="vintagestory"
+glibc="2.17"
+
+#### Directories ####
+# Edit with care
+
+## Game Server Directories
+systemdir="${serverfiles}"
+executabledir="${systemdir}"
+preexecutable="mono"
+executable="./VintagestoryServer.exe"
+servercfgdir="${serverfiles}/data/${selfname}"
+servercfg="serverconfig.json"
+servercfgdefault="serverconfig.json"
+servercfgfullpath="${servercfgdir}/${servercfg}"
+
+## Backup Directory
+backupdir="${lgsmdir}/backup"
+
+## Logging Directories
+logdir="${rootdir}/log"
+gamelogdir="${vsdataworld}/Logs"
+lgsmlogdir="${logdir}/script"
+consolelogdir="${logdir}/console"
+lgsmlog="${lgsmlogdir}/${selfname}-script.log"
+consolelog="${consolelogdir}/${selfname}-console.log"
+alertlog="${lgsmlogdir}/${selfname}-alert.log"
+postdetailslog="${lgsmlogdir}/${selfname}-postdetails.log"
+
+## Logs Naming
+lgsmlogdate="${lgsmlogdir}/${selfname}-script-$(date '+%Y-%m-%d-%H:%M:%S').log"
+consolelogdate="${consolelogdir}/${selfname}-console-$(date '+%Y-%m-%d-%H:%M:%S').log"

+ 1 - 0
lgsm/data/serverlist.csv

@@ -104,6 +104,7 @@ ut2k4,ut2k4server,Unreal Tournament 2004
 ut3,ut3server,Unreal Tournament 3
 ut3,ut3server,Unreal Tournament 3
 ut99,ut99server,Unreal Tournament 99
 ut99,ut99server,Unreal Tournament 99
 vs,vsserver,Vampire Slayer
 vs,vsserver,Vampire Slayer
+vints,vintsserver,Vintage Story
 wet,wetserver,Wolfenstein: Enemy Territory
 wet,wetserver,Wolfenstein: Enemy Territory
 wf,wfserver,Warfork
 wf,wfserver,Warfork
 wurm,wurmserver,Wurm Unlimited
 wurm,wurmserver,Wurm Unlimited

+ 6 - 0
lgsm/functions/check_deps.sh

@@ -452,6 +452,9 @@ fn_deps_build_debian(){
 	# Unreal Tournament
 	# Unreal Tournament
 	elif [ "${shortname}" == "ut" ]; then
 	elif [ "${shortname}" == "ut" ]; then
 		array_deps_required+=( unzip )
 		array_deps_required+=( unzip )
+	# Vintage Story
+	elif [ "${shortname}" == "vints" ]; then
+		array_deps_required+=( mono-complete )
 	# Wurm: Unlimited
 	# Wurm: Unlimited
 	elif [ "${shortname}" == "wurm" ]; then
 	elif [ "${shortname}" == "wurm" ]; then
 		array_deps_required+=( xvfb )
 		array_deps_required+=( xvfb )
@@ -564,6 +567,9 @@ fn_deps_build_redhat(){
 	# Unreal Tournament
 	# Unreal Tournament
 	elif [ "${shortname}" == "ut" ]; then
 	elif [ "${shortname}" == "ut" ]; then
 		array_deps_required+=( unzip )
 		array_deps_required+=( unzip )
+	# Vintage Story
+	elif [ "${shortname}" == "vints" ]; then
+		array_deps_required+=( mono-complete )
 	# Wurm: Unlimited
 	# Wurm: Unlimited
 	elif [ "${shortname}" == "wurm" ]; then
 	elif [ "${shortname}" == "wurm" ]; then
 		array_deps_required+=( xorg-x11-server-Xvfb )
 		array_deps_required+=( xorg-x11-server-Xvfb )

+ 2 - 0
lgsm/functions/command_update.sh

@@ -28,6 +28,8 @@ elif [ "${shortname}" == "mta" ]; then
 	update_mta.sh
 	update_mta.sh
 elif [ "${shortname}" == "jk2" ]; then
 elif [ "${shortname}" == "jk2" ]; then
 	update_jediknight2.sh
 	update_jediknight2.sh
+elif [ "${shortname}" == "vints" ]; then
+	update_vintagestory.sh
 else
 else
 	update_steamcmd.sh
 	update_steamcmd.sh
 fi
 fi

+ 5 - 0
lgsm/functions/core_functions.sh

@@ -649,6 +649,11 @@ functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function
 }
 }
 
 
+update_vintagestory.sh(){
+functionfile="${FUNCNAME[0]}"
+fn_fetch_function
+}
+
 fn_update_functions.sh(){
 fn_update_functions.sh(){
 functionfile="${FUNCNAME[0]}"
 functionfile="${FUNCNAME[0]}"
 fn_fetch_function
 fn_fetch_function

+ 23 - 0
lgsm/functions/info_config.sh

@@ -1548,6 +1548,27 @@ fn_info_config_col(){
 	fi
 	fi
 }
 }
 
 
+fn_info_config_vintagestory(){
+	if [ ! -f "${servercfgfullpath}" ]; then
+		servername="${unavailable}"
+		maxplayers="${unavailable}"
+		serverpassword="${unavailable}"
+		port="${unavailable}"
+		queryport="${unavailable}"
+		configip="${unavailable}"
+	else
+		servername=$(jq -r '.ServerName' "${servercfgfullpath}")
+		maxplayers=$(jq -r '.MaxClients' "${servercfgfullpath}")
+		serverpassword=$(jq -r 'select(.Password != null) | .Password' "${servercfgfullpath}")
+		port=$(jq -r '.Port' "${servercfgfullpath}")
+		queryport=${port:-"0"}
+		configip=$(jq -r 'select(.Ip != null) | .Ip' "${servercfgfullpath}")
+
+		serverpassword=${serverpassword:-"NOT SET"}
+		configip=${configip:-"0.0.0.0"}
+	fi
+}
+
 if [ "${shortname}" == "ac" ]; then
 if [ "${shortname}" == "ac" ]; then
 	fn_info_config_assettocorsa
 	fn_info_config_assettocorsa
 elif [ "${shortname}" == "ark" ]; then
 elif [ "${shortname}" == "ark" ]; then
@@ -1672,4 +1693,6 @@ elif [ "${shortname}" == "mh" ]; then
 	fn_info_config_mordhau
 	fn_info_config_mordhau
 elif [ "${shortname}" == "pvr" ];then
 elif [ "${shortname}" == "pvr" ];then
 	fn_info_config_pavlovvr
 	fn_info_config_pavlovvr
+elif [ "${shortname}" == "vints" ]; then
+	fn_info_config_vintagestory
 fi
 fi

+ 12 - 1
lgsm/functions/info_messages.sh

@@ -572,7 +572,7 @@ fn_info_message_ports(){
 
 
 	parmslocation="${red}UNKNOWN${default}"
 	parmslocation="${red}UNKNOWN${default}"
 	# engines/games that require editing in the config file.
 	# engines/games that require editing in the config file.
-	local ports_edit_array=( "avalanche2.0" "avalanche3.0" "Ballistic Overkill" "Barotrauma" "dontstarve" "Eco" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "Minecraft Bedrock" "Project Cars" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "Stationeers" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" "wurm")
+	local ports_edit_array=( "avalanche2.0" "avalanche3.0" "Ballistic Overkill" "Barotrauma" "dontstarve" "Eco" "idtech2" "idtech3" "idtech3_ql" "lwjgl2" "Minecraft Bedrock" "Project Cars" "projectzomboid" "quake" "refractor" "realvirtuality" "renderware" "Stationeers" "teeworlds" "terraria" "unreal" "unreal2" "unreal3" "TeamSpeak 3" "Mumble" "7 Days To Die" "Vintage Story" "wurm")
 	for port_edit in "${ports_edit_array[@]}"; do
 	for port_edit in "${ports_edit_array[@]}"; do
 		if [ "${shortname}" == "ut3" ]; then
 		if [ "${shortname}" == "ut3" ]; then
 			parmslocation="${servercfgdir}/UTWeb.ini"
 			parmslocation="${servercfgdir}/UTWeb.ini"
@@ -1455,6 +1455,15 @@ fn_info_message_colony(){
 	} | column -s $'\t' -t
 	} | column -s $'\t' -t
 }
 }
 
 
+fn_info_message_vintagestory(){
+	echo "netstat -atunp | grep cli"
+	echo -e ""
+	{
+		echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL"
+		echo -e "> Game\tINBOUND\t${port}\tTCP"
+	} | column -s $'\t' -t
+}
+
 fn_info_message_select_engine(){
 fn_info_message_select_engine(){
 	# Display details depending on game or engine.
 	# Display details depending on game or engine.
 	if [ "${shortname}" == "ac" ]; then
 	if [ "${shortname}" == "ac" ]; then
@@ -1573,6 +1582,8 @@ fn_info_message_select_engine(){
 		fn_info_message_pavlovvr
 		fn_info_message_pavlovvr
 	elif [ "${shortname}" == "rust" ]; then
 	elif [ "${shortname}" == "rust" ]; then
 		fn_info_message_rust
 		fn_info_message_rust
+	elif [ "${shortname}" == "vints" ]; then
+		fn_info_message_vintagestory
 	elif [ "${shortname}" == "wf" ]; then
 	elif [ "${shortname}" == "wf" ]; then
 		fn_info_message_warfork
 		fn_info_message_warfork
 	elif [ "${shortname}" == "wurm" ]; then
 	elif [ "${shortname}" == "wurm" ]; then

+ 7 - 0
lgsm/functions/install_config.sh

@@ -793,6 +793,13 @@ elif [ "${shortname}" == "unt" ]; then
 	fn_default_config_remote
 	fn_default_config_remote
 	fn_set_config_vars
 	fn_set_config_vars
 	fn_list_config_locations
 	fn_list_config_locations
+elif [ "${shortname}" == "vints" ]; then
+	gamedirname="VintageStory"
+	array_configs+=( serverconfig.json )
+	fn_fetch_default_config
+	fn_default_config_remote
+	fn_set_config_vars
+	fn_list_config_locations
 elif [ "${shortname}" == "vs" ]; then
 elif [ "${shortname}" == "vs" ]; then
 	gamedirname="VampireSlayer"
 	gamedirname="VampireSlayer"
 	array_configs+=( server.cfg )
 	array_configs+=( server.cfg )

+ 2 - 0
lgsm/functions/install_server_files.sh

@@ -91,6 +91,8 @@ elif [ "${shortname}" == "fctr" ]; then
 	install_factorio_save.sh
 	install_factorio_save.sh
 elif [ "${shortname}" == "jk2" ]; then
 elif [ "${shortname}" == "jk2" ]; then
 	update_jediknight2.sh
 	update_jediknight2.sh
+elif [ "${shortname}" == "vints" ]; then
+	update_vintagestory.sh
 elif [ -z "${appid}" ]||[ "${shortname}" == "ahl" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "sfc" ]||[ "${shortname}" == "ts" ]||[ "${shortname}" == "vs" ]||[ "${shortname}" == "zmr" ]; then
 elif [ -z "${appid}" ]||[ "${shortname}" == "ahl" ]||[ "${shortname}" == "bd" ]||[ "${shortname}" == "bb" ]||[ "${shortname}" == "ns" ]||[ "${shortname}" == "sfc" ]||[ "${shortname}" == "ts" ]||[ "${shortname}" == "vs" ]||[ "${shortname}" == "zmr" ]; then
 	if [ "${shortname}" == "ut" ]; then
 	if [ "${shortname}" == "ut" ]; then
 		install_eula.sh
 		install_eula.sh

+ 1 - 1
lgsm/functions/update_minecraft.sh

@@ -88,10 +88,10 @@ fn_update_minecraft_compare(){
 		echo -e "Update available"
 		echo -e "Update available"
 		echo -e "* Local build: ${red}${localbuild}${default}"
 		echo -e "* Local build: ${red}${localbuild}${default}"
 		echo -e "* Remote build: ${green}${remotebuild}${default}"
 		echo -e "* Remote build: ${green}${remotebuild}${default}"
-		echo -en "\n"
 		if [ -n "${branch}" ]; then
 		if [ -n "${branch}" ]; then
 			echo -e "* Branch: ${branch}"
 			echo -e "* Branch: ${branch}"
 		fi
 		fi
+		echo -en "\n"
 		fn_script_log_info "Update available"
 		fn_script_log_info "Update available"
 		fn_script_log_info "Local build: ${localbuild}"
 		fn_script_log_info "Local build: ${localbuild}"
 		fn_script_log_info "Remote build: ${remotebuild}"
 		fn_script_log_info "Remote build: ${remotebuild}"

+ 145 - 0
lgsm/functions/update_vintagestory.sh

@@ -0,0 +1,145 @@
+#!/bin/bash
+# LinuxGSM update_vintagestory.sh function
+# Author: Christian Birk
+# Website: https://linuxgsm.com
+# Description: Handles updating of Vintage Story servers.
+
+functionselfname="$(basename "$(readlink -f "${BASH_SOURCE[0]}")")"
+
+fn_update_vs_dl(){
+	# get version info for download
+	remotebuildresponse=$(curl -s "${apiurl}" | jq --arg version "${remotebuild}" '.[$version].server')
+	remotebuildfile=$(echo -e "${remotebuildresponse}" | jq -r '.filename')
+	remotebuildlink=$(echo -e "${remotebuildresponse}" | jq -r '.urls.cdn')
+	remotebuildmd5=$(echo -e "${remotebuildresponse}" | jq -r '.md5')
+
+	# Download and extract files to serverfiles
+	fn_fetch_file "${remotebuildlink}" "" "" "" "${tmpdir}" "${remotebuildfile}" "nochmodx" "norun" "force" "${remotebuildmd5}"
+	fn_dl_extract "${tmpdir}" "${remotebuildfile}" "${serverfiles}"
+	fn_clear_tmp
+}
+
+fn_update_vs_localbuild(){
+	# Gets local build info.
+	fn_print_dots "Checking local build: ${remotelocation}"
+	# Uses executable to find local build.
+	cd "${executabledir}" || exit
+	if [ -f "${executable}" ]; then
+		localbuild="$(${preexecutable} ${executable} --version | sed '/^[[:space:]]*$/d')"
+		fn_print_ok "Checking local build: ${remotelocation}"
+		fn_script_log_pass "Checking local build"
+	else
+		localbuild="0"
+		fn_print_error "Checking local build: ${remotelocation}"
+		fn_script_log_error "Checking local build"
+	fi
+}
+
+fn_update_vs_remotebuild(){
+	if [ "${branch}" == "stable" ]; then
+		remotebuild=$(curl -s "${apiurl}" | jq -r '[ to_entries[] ] | .[].key' | grep -Ev "\-rc|\-pre" | sort -r -V | head -1)
+	else
+		remotebuild=$(curl -s "${apiurl}" | jq -r '[ to_entries[] ] | .[].key' | grep -E "\-rc|\-pre" | sort -r -V | head -1)
+	fi
+
+	if [ "${firstcommandname}" != "INSTALL" ]; then
+		fn_print_dots "Checking remote build: ${remotelocation}"
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_fail "Checking remote build: ${remotelocation}"
+			fn_script_log_fatal "Checking remote build"
+			core_exit.sh
+		else
+			fn_print_ok "Checking remote build: ${remotelocation}"
+			fn_script_log_pass "Checking remote build"
+		fi
+	else
+		# Checks if remotebuild variable has been set.
+		if [ -z "${remotebuild}" ]||[ "${remotebuild}" == "null" ]; then
+			fn_print_failure "Unable to get remote build"
+			fn_script_log_fatal "Unable to get remote build"
+			core_exit.sh
+		fi
+	fi
+}
+
+fn_update_vs_compare(){
+	# Removes dots so if statement can compare version numbers.
+	fn_print_dots "Checking for update: ${remotelocation}"
+	if [ "${localbuild}" != "${remotebuild}" ]||[ "${forceupdate}" == "1" ]; then
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "Update available"
+		echo -e "* Local build: ${red}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		if [ -n "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		echo -en "\n"
+		fn_script_log_info "Update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		fn_script_log_info "${localbuild} > ${remotebuild}"
+
+		unset updateonstart
+		check_status.sh
+		# If server stopped.
+		if [ "${status}" == "0" ]; then
+			exitbypass=1
+			fn_update_vs_dl
+			exitbypass=1
+			command_start.sh
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+		# If server started.
+		else
+			fn_print_restart_warning
+			exitbypass=1
+			command_stop.sh
+			fn_firstcommand_reset
+			exitbypass=1
+			fn_update_vs_dl
+			exitbypass=1
+			command_start.sh
+			fn_firstcommand_reset
+		fi
+		unset exitbypass
+		date +%s > "${lockdir}/lastupdate.lock"
+		alert="update"
+		alert.sh
+	else
+		fn_print_ok_nl "Checking for update: ${remotelocation}"
+		echo -en "\n"
+		echo -e "No update available"
+		echo -e "* Local build: ${green}${localbuild}${default}"
+		echo -e "* Remote build: ${green}${remotebuild}${default}"
+		if [ -n "${branch}" ]; then
+			echo -e "* Branch: ${branch}"
+		fi
+		echo -en "\n"
+		fn_script_log_info "No update available"
+		fn_script_log_info "Local build: ${localbuild}"
+		fn_script_log_info "Remote build: ${remotebuild}"
+		if [ -n "${branch}" ]; then
+			fn_script_log_info "Branch: ${branch}"
+		fi
+	fi
+}
+
+# The location where the builds are checked and downloaded.
+remotelocation="vintagestory.at"
+apiurl="http://api.${remotelocation}/stable-unstable.json"
+localversionfile="${datadir}/vintagestoryversion"
+
+if [ "${firstcommandname}" == "INSTALL" ]; then
+	fn_update_vs_remotebuild
+	fn_update_vs_dl
+else
+	fn_print_dots "Checking for update"
+	fn_print_dots "Checking for update: ${remotelocation}"
+	fn_script_log_info "Checking for update: ${remotelocation}"
+	fn_update_vs_localbuild
+	fn_update_vs_remotebuild
+	fn_update_vs_compare
+fi