From 54d0e81ee8ede04e02802c6b1d835e03b68c1d22 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 7 Aug 2016 15:15:12 +1000 Subject: [PATCH 1/3] Add support for arkmod_* in config --- tools/arkmanager | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/arkmanager b/tools/arkmanager index 7b709d3..c653be9 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -660,6 +660,22 @@ doRun() { arkserveropts="$serverMap" + while read varname; do + val="${!varname}" + modid="${varname#arkmod_}" + case "$val" in + game*|enabled) + ark_GameModIds="${ark_GameModIds}${ark_GameModIds:+,}${modid}" + ;; + map*) + serverMapModId="${modid}" + ;; + tc|total*) + ark_TotalConversionMod="${modid}" + ;; + esac + done < <(sed -n 's/^\(arkmod_[^= ]*\)=.*/\1/p' <"$configfile") + if [ -n "$serverMapModId" ]; then serverMap="$(perl -e ' my $data; @@ -1488,6 +1504,11 @@ getModIds(){ echo "${serverMapModId}" echo "${ark_TotalConversionMod}" echo "${ark_GameModIds}" | tr ',' '\n' + for v in "${!arkmod_@}"; do + if [ "${!v}" != "disabled" ]; then + echo "${v#arkmod_}" + fi + done find "${arkserverroot}/ShooterGame/Content/Mods" -maxdepth 1 -type d -printf "%P\n" ) | sort | uniq | grep '^[1-9][0-9]*$' } From 0403d2949519e8f32c65dfe5d4e9e75811e84967 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 7 Aug 2016 15:37:52 +1000 Subject: [PATCH 2/3] Add enablemod and disablemod commands --- README.asciidoc | 40 ++++++++++++++++++++++++++++++++++++++++ tools/arkmanager | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 77 insertions(+) diff --git a/README.asciidoc b/README.asciidoc index 3bc4e16..d11ce84 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -242,6 +242,22 @@ instances. Runs the `uninstallmod` command followed by the `installmod` command +`enablemod `:: +`enablemod =`:: + Enables the `arkmod_` setting in the instance config. + modtype defaults to `game`. + Mod types: + + `game`;; + A mod in `GameModIds` + + `map`;; + The `MapModId` mod + + `tc`;; + `totalconversion`;; + The `TotalConversionMod` mod + `backup`:: Backs up the saved world and game config files to a compressed tar file in the backups directory specified in the config @@ -495,6 +511,30 @@ the global config. the `-StructureDestructionTag=DestroySwampSnowStructures` option. +`arkmod_=`:: + Specifies a mod that can be enabled or disabled using + `enablemod` and `disablemod`. Note that mod ids specified + using these options are in addition to those specified directly + in the `ark_GameModIds` option, and override those specified in the + `ark_MapModId`, `serverMapMod` and `ark_TotalConversionMod` + options. Options are processed in the order they are specified + in the instance config file, and `arkmod_*` options in the + common config file are not applied. + Mod types: + + `game`;; + A mod to be specified in `GameModIds` + + `map`;; + The mod to be specified in `MapModId` + + `tc`;; + `totalconversion`;; + The mod to be specified in `TotalConversionMod` + + `disabled`;; + A disabled mod + Common ARK options ~~~~~~~~~~~~~~~~~~ diff --git a/tools/arkmanager b/tools/arkmanager index c653be9..6fe9697 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -1843,6 +1843,37 @@ doUninstallMod(){ fi } +# +# Enables a mod in the config +# +doEnableMod(){ + local modid="${1%=*}" + local modtype="${1#*=}" + if [ "$modtype" = "$1" ]; then + modtype=game + fi + local modvar="arkmod_${modid}" + if [ -n "${!modvar}" ]; then + sed -i "s|^\(${modvar}\)=[^ ]*|\1=${modtype}|" "$configfile" + else + echo "${modvar}=${modtype}" >>"$configfile" + fi +} + +# +# Disable a mod in the config +# +doDisableMod(){ + local modid="$1" + local modvar="arkmod_$modid" + if [ "$ark_GameModIds" = *"$modid"* ]; then + sed -i "s|^\(ark_GameModIds=\(\|[\"']\)\(\|[^\"' ]*,\)\)${modid},*|\1|" "$configfile" + fi + if [ -n "$modvar" ]; then + sed -i "s|^\(arkmod_${modid}\)=[^ ]*|\1=disabled|" "$configfile" + fi +} + # # Removes mod from steamcmd workshop directory # @@ -2506,6 +2537,12 @@ main(){ installmod) doInstallMod "${args[@]}" ;; + enablemod) + doEnableMod "${args[@]}" + ;; + disablemod) + doDisableMod "${args[@]}" + ;; installmods) doInstallAllMods ;; From 653006a66c4a70dd3e14444ad790e62944f7c0d3 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 21 Aug 2016 22:27:18 +1000 Subject: [PATCH 3/3] Prevent server start during update --- tools/arkmanager | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/arkmanager b/tools/arkmanager index 2b9fc93..0cdf58d 100755 --- a/tools/arkmanager +++ b/tools/arkmanager @@ -591,6 +591,14 @@ function numPlayersConnected(){ doRun() { cd "$arkserverroot" + if [ -f "${arkserverroot}/.ark-update.lock" ]; then + local updatepid="$(<"${arkserverroot}/.ark-update.lock")" + if kill -0 "$updatepid" >/dev/null 2>&1; then + echo "An update is currently in progress. Start aborted" + return 1 + fi + fi + arkserveropts="$serverMap" if [ -n "$serverMapModId" ]; then @@ -728,6 +736,15 @@ doRun() { # start function # doStart() { + if [ -f "${arkserverroot}/.ark-update.lock" ]; then + local updatepid="$(<"${arkserverroot}/.ark-update.lock")" + if kill -0 "$updatepid" >/dev/null 2>&1; then + touch "${arkserverroot}/.startAfterUpdate" + echo "An update is currently in progress. Start aborted" + return 1 + fi + fi + if isTheServerRunning; then echo "The server is already running" else @@ -766,6 +783,8 @@ doStartAll(){ # stop the ARK server # doStop() { + rm -f "${arkserverroot}/.startAfterUpdate" + if isTheServerRunning; then if [[ " $* " =~ " --warn " ]]; then doWarn "$1" @@ -1151,7 +1170,9 @@ doUpdate() { fi # we restart the server only if it was started before the update - if [ $serverWasAlive -eq 1 ]; then + if [ $serverWasAlive -eq 1 ] || [ -f "${arkserverroot}/.startAfterUpdate" ]; then + rm -f "${arkserverroot}/.startAfterUpdate" + rm -f "${arkserverroot}/.ark-update.lock" doStart --noautoupdate fi else