summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBotond Hende <nettingman@gmail.com>2024-11-19 22:15:52 +0100
committerBotond Hende <nettingman@gmail.com>2024-11-19 22:15:52 +0100
commit40bc20606e5f2bf960b04586dcf922488fc1f943 (patch)
tree01dc6ac8e065e39721fc893735c68ed582abe802
parentf31ad9a665890a0ef868c7bc402c566be56b6293 (diff)
added server config backup
-rwxr-xr-xupdate_and_start.sh15
1 files changed, 14 insertions, 1 deletions
diff --git a/update_and_start.sh b/update_and_start.sh
index 93ff5c3..8e72105 100755
--- a/update_and_start.sh
+++ b/update_and_start.sh
@@ -2,15 +2,22 @@
SERVER_PATH=/opt/ss14/server
BUILD_JSON_PATH="$SERVER_PATH"/build.json
+CONFIG_PATH="$SERVER_PATH"/server_config.toml
SERVER="$SERVER_PATH"/Robust.Server
TEMP_ZIP_PATH=/tmp/ss14-temp.zip
+TEMP_CONFIG_PATH=/tmp/server_config.toml
LATEST_VER=$(curl https://wizards.cdn.spacestation14.com/fork/wizards | sed -nE 's/(\s*)<dd><span class="versionNumber">(.*)<\/span><\/dd>/\2/p' | head -1)
if [ \! -f "$BUILD_JSON_PATH" ] || ! grep -q "$LATEST_VER" "$BUILD_JSON_PATH"; then
rm -r "$SERVER_PATH"/*
+ # backup server config
+ if [ -f "$CONFIG_PATH" ]; then
+ cp "$CONFIG_PATH" "$TEMP_CONFIG_PATH"
+ fi
+
# ARM64 version
wget "https://wizards.cdn.spacestation14.com/fork/wizards/version/$LATEST_VER/file/SS14.Server_linux-arm64.zip" -O "$TEMP_ZIP_PATH"
@@ -21,7 +28,13 @@ if [ \! -f "$BUILD_JSON_PATH" ] || ! grep -q "$LATEST_VER" "$BUILD_JSON_PATH"; t
rm "$TEMP_ZIP_PATH"
chmod +x "$SERVER"
- cp server_config.toml "$SERVER_PATH"
+
+ # restore config or copy default
+ if [ -f "$TEMP_CONFIG_PATH" ]; then
+ cp "$TEMP_CONFIG_PATH" "$SERVER_PATH"
+ else
+ cp server_config.toml "$SERVER_PATH"
+ fi
fi
"$SERVER"