From ec7dea053d5c9027c84d068033e058fe73fa36ee Mon Sep 17 00:00:00 2001 From: H3o66 Date: Tue, 29 Dec 2020 15:50:02 +0100 Subject: [PATCH] feat(newserver): Vintage Story --- .../config-lgsm/vintsserver/_default.cfg | 168 ++++++++++++++++++ lgsm/data/serverlist.csv | 1 + lgsm/functions/check_deps.sh | 6 + lgsm/functions/command_update.sh | 2 + lgsm/functions/core_functions.sh | 5 + lgsm/functions/info_config.sh | 23 +++ lgsm/functions/info_messages.sh | 13 +- lgsm/functions/install_config.sh | 7 + lgsm/functions/install_server_files.sh | 2 + lgsm/functions/update_vintagestory.sh | 126 +++++++++++++ 10 files changed, 352 insertions(+), 1 deletion(-) create mode 100644 lgsm/config-default/config-lgsm/vintsserver/_default.cfg create mode 100755 lgsm/functions/update_vintagestory.sh diff --git a/lgsm/config-default/config-lgsm/vintsserver/_default.cfg b/lgsm/config-default/config-lgsm/vintsserver/_default.cfg new file mode 100644 index 000000000..e128a9a52 --- /dev/null +++ b/lgsm/config-default/config-lgsm/vintsserver/_default.cfg @@ -0,0 +1,168 @@ +################################## +######## 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 ${vsdataworld}" +} + +#### 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 +vsdatapath="${serverfiles}/data" +vsdataworld="${vsdatapath}/${selfname}" +systemdir="${serverfiles}" +executabledir="${systemdir}" +executable="mono ./VintagestoryServer.exe" +servercfgdir="${vsdataworld}" +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" diff --git a/lgsm/data/serverlist.csv b/lgsm/data/serverlist.csv index 7786158f1..92f194046 100644 --- a/lgsm/data/serverlist.csv +++ b/lgsm/data/serverlist.csv @@ -104,6 +104,7 @@ ut2k4,ut2k4server,Unreal Tournament 2004 ut3,ut3server,Unreal Tournament 3 ut99,ut99server,Unreal Tournament 99 vs,vsserver,Vampire Slayer +vints,vintsserver,Vintage Story wet,wetserver,Wolfenstein: Enemy Territory wf,wfserver,Warfork wurm,wurmserver,Wurm Unlimited diff --git a/lgsm/functions/check_deps.sh b/lgsm/functions/check_deps.sh index 621b12eae..5a9b34be8 100755 --- a/lgsm/functions/check_deps.sh +++ b/lgsm/functions/check_deps.sh @@ -452,6 +452,9 @@ fn_deps_build_debian(){ # Unreal Tournament elif [ "${shortname}" == "ut" ]; then array_deps_required+=( unzip ) + # Vintage Story + elif [ "${shortname}" == "vints" ]; then + array_deps_required+=( mono-complete ) # Wurm: Unlimited elif [ "${shortname}" == "wurm" ]; then array_deps_required+=( xvfb ) @@ -564,6 +567,9 @@ fn_deps_build_redhat(){ # Unreal Tournament elif [ "${shortname}" == "ut" ]; then array_deps_required+=( unzip ) + # Vintage Story + elif [ "${shortname}" == "vints" ]; then + array_deps_required+=( mono-complete ) # Wurm: Unlimited elif [ "${shortname}" == "wurm" ]; then array_deps_required+=( xorg-x11-server-Xvfb ) diff --git a/lgsm/functions/command_update.sh b/lgsm/functions/command_update.sh index b117cbec5..718f5d490 100755 --- a/lgsm/functions/command_update.sh +++ b/lgsm/functions/command_update.sh @@ -28,6 +28,8 @@ elif [ "${shortname}" == "mta" ]; then update_mta.sh elif [ "${shortname}" == "jk2" ]; then update_jediknight2.sh +elif [ "${shortname}" == "vints" ]; then + update_vintagestory.sh else update_steamcmd.sh fi diff --git a/lgsm/functions/core_functions.sh b/lgsm/functions/core_functions.sh index ce8458b5d..3a8c77def 100755 --- a/lgsm/functions/core_functions.sh +++ b/lgsm/functions/core_functions.sh @@ -649,6 +649,11 @@ functionfile="${FUNCNAME[0]}" fn_fetch_function } +update_vintagestory.sh(){ +functionfile="${FUNCNAME[0]}" +fn_fetch_function +} + fn_update_functions.sh(){ functionfile="${FUNCNAME[0]}" fn_fetch_function diff --git a/lgsm/functions/info_config.sh b/lgsm/functions/info_config.sh index 99eed24c4..3720c421e 100755 --- a/lgsm/functions/info_config.sh +++ b/lgsm/functions/info_config.sh @@ -1548,6 +1548,27 @@ fn_info_config_col(){ 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 fn_info_config_assettocorsa elif [ "${shortname}" == "ark" ]; then @@ -1672,4 +1693,6 @@ elif [ "${shortname}" == "mh" ]; then fn_info_config_mordhau elif [ "${shortname}" == "pvr" ];then fn_info_config_pavlovvr +elif [ "${shortname}" == "vints" ]; then + fn_info_config_vintagestory fi diff --git a/lgsm/functions/info_messages.sh b/lgsm/functions/info_messages.sh index 177129bfd..59507370f 100755 --- a/lgsm/functions/info_messages.sh +++ b/lgsm/functions/info_messages.sh @@ -572,7 +572,7 @@ fn_info_message_ports(){ parmslocation="${red}UNKNOWN${default}" # 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 if [ "${shortname}" == "ut3" ]; then parmslocation="${servercfgdir}/UTWeb.ini" @@ -1455,6 +1455,15 @@ fn_info_message_colony(){ } | column -s $'\t' -t } +fn_info_message_vintagestory(){ + echo "netstat -atunp | grep mono" + echo -e "" + { + echo -e "DESCRIPTION\tDIRECTION\tPORT\tPROTOCOL" + echo -e "> Game\tINBOUND\t${port}\tTCP" + } | column -s $'\t' -t +} + fn_info_message_select_engine(){ # Display details depending on game or engine. if [ "${shortname}" == "ac" ]; then @@ -1573,6 +1582,8 @@ fn_info_message_select_engine(){ fn_info_message_pavlovvr elif [ "${shortname}" == "rust" ]; then fn_info_message_rust + elif [ "${shortname}" == "vints" ]; then + fn_info_message_vintagestory elif [ "${shortname}" == "wf" ]; then fn_info_message_warfork elif [ "${shortname}" == "wurm" ]; then diff --git a/lgsm/functions/install_config.sh b/lgsm/functions/install_config.sh index 052e535d2..3efb46a65 100755 --- a/lgsm/functions/install_config.sh +++ b/lgsm/functions/install_config.sh @@ -793,6 +793,13 @@ elif [ "${shortname}" == "unt" ]; then fn_default_config_remote fn_set_config_vars 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 gamedirname="VampireSlayer" array_configs+=( server.cfg ) diff --git a/lgsm/functions/install_server_files.sh b/lgsm/functions/install_server_files.sh index f8b6be4f0..a3c40da37 100755 --- a/lgsm/functions/install_server_files.sh +++ b/lgsm/functions/install_server_files.sh @@ -91,6 +91,8 @@ elif [ "${shortname}" == "fctr" ]; then install_factorio_save.sh elif [ "${shortname}" == "jk2" ]; then 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 if [ "${shortname}" == "ut" ]; then install_eula.sh diff --git a/lgsm/functions/update_vintagestory.sh b/lgsm/functions/update_vintagestory.sh new file mode 100755 index 000000000..a2e0cda34 --- /dev/null +++ b/lgsm/functions/update_vintagestory.sh @@ -0,0 +1,126 @@ +#!/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]}")")" + +remotelocation="vintagestory.at" +apiurl="http://api.${remotelocation}/stable-unstable.json" +local_version_file="${datadir}/vintagestory_version" + +fn_update_vs_remotebuild(){ + if [ "${branch}" == "unstable" ]; then + remotebuild=$(curl -s "${apiurl}" | jq -r '[ to_entries[] ] | .[].key' | grep -E "\-rc|\-pre" | sort -r -V | head -1) + else + remotebuild=$(curl -s "${apiurl}" | jq -r '[ to_entries[] ] | .[].key' | grep -Ev "\-rc|\-pre" | sort -r -V | head -1) + fi +} + +fn_update_vs_get_installed_version(){ + localbuild=$(cat "${local_version_file}" ) + # Alternative: get version from executeable $(mono .exe --version) +} + +fn_update_vs_dl(){ + # get version info for download + vsapiresponse=$(curl -s "${apiurl}" | jq --arg version "${remotebuild}" '.[$version].server') + remotebuildfile=$( echo -e "${vsapiresponse}" | jq -r '.filename' ) + remotebuildlink=$( echo -e "${vsapiresponse}" | jq -r '.urls.cdn' ) + remotebuildmd5=$( echo -e "${vsapiresponse}" | 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 + echo "${remotebuild}" > "${local_version_file}" +} + +if [ -z "${branch}" ]; then + branch="stable" +fi + +if [ "${commandname}" == "INSTALL" ]; then + fn_update_vs_remotebuild + if [ -z "${remotebuild}" ]; then + # cannot get version + fn_print_fail_eol_nl + fn_script_log_fatal "Cannot get version from remote" + core_exit.sh + else + # get version proceed + fn_update_vs_dl + fi +elif [ "${commandname}" == "UPDATE" ]||[ "${commandname}" == "CHECK-UPDATE" ]; then + if [ ! -f "${local_version_file}" ]; then + # server not installed + fn_print_fail_eol_nl + fn_script_log_fatal "Vintage story server not installed" + core_exit.sh + else + fn_update_vs_remotebuild + if [ -z "${remotebuild}" ]; then + fn_print_fail_eol_nl + fn_script_log_fatal "Cannot get version from remote" + core_exit.sh + fi + fn_update_vs_get_installed_version + if [ "${remotebuild}" != "${localbuild}" ]; 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}" + echo -e "* Branch: ${branch}" + echo -en "\n" + fn_script_log_info "Update available" + fn_script_log_info "Local build: ${localbuild}" + fn_script_log_info "Remote build: ${remotebuild}" + + # update server + if [ "${commandname}" == "UPDATE" ]; then + unset updateonstart + check_status.sh + # If server stopped. + if [ "${status}" == "0" ]; then + fn_update_vs_dl + # 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 + unset exitbypass + fi + date +%s > "${lockdir}/lastupdate.lock" + alert="update" + elif [ "${commandname}" == "CHECK-UPDATE" ]; then + alert="check-update" + fi + # trigger alert + alert.sh + elif [ "${remotebuild}" == "${localbuild}" ]; then + 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}" + echo -e "* Branch: ${branch}" + echo -en "\n" + fn_script_log_info "No update available" + fn_script_log_info "Local build: ${localbuild}" + fn_script_log_info "Remote build: ${remotebuild}" + fn_script_log_pass "Latest version ${remotebuild} already installed" + else + fn_print_fail_eol_nl + fn_script_log_fatal "Something went wrong" + core_exit.sh + fi + fi +fi