From 0403d2949519e8f32c65dfe5d4e9e75811e84967 Mon Sep 17 00:00:00 2001 From: Ben Peddell Date: Sun, 7 Aug 2016 15:37:52 +1000 Subject: [PATCH] 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 ;;