diff --git a/tools/install.sh b/tools/install.sh index 5c66dab..73bfb98 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -182,6 +182,7 @@ if [ "$userinstall" == "yes" ]; then # Copy arkmanager.cfg to ~/.arkmanager.cfg if it doesn't already exist if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}" + bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg" echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it." echo "A copy of the new configuration file was included in '${CONFIGFILE}.NEW'. Make sure to review any changes and update your config accordingly!" @@ -306,6 +307,7 @@ else if [ -f "${INSTALL_ROOT}${CONFIGFILE}" ]; then bash ./migrate-config.sh "${INSTALL_ROOT}${CONFIGFILE}" + bash ./migrate-main-instance.sh "${INSTALL_ROOT}${CONFIGFILE}" "${INSTALL_ROOT}${INSTANCEDIR}/main.cfg" echo "A previous version of ARK Server Tools was detected in your system, your old configuration was not overwritten. You may need to manually update it." echo "A copy of the new configuration file was included in /etc/arkmanager. Make sure to review any changes and update your config accordingly!" diff --git a/tools/migrate-main-instance.sh b/tools/migrate-main-instance.sh new file mode 100755 index 0000000..79cdfd6 --- /dev/null +++ b/tools/migrate-main-instance.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +configfile="$1" +instancefile="$2" + +if grep "^arkserverroot=" <"$configfile" >/dev/null 2>&1 && [ ! -f "$instancefile" ]; then + sed -n '/^#*\(ark\(\|flag\|opt\)_[^=]*\|arkserverroot\|serverMap\(\|ModId\)\)=/p' <"$configfile" >"$instancefile" + sed -i '/^ark\(serverroot\|_\(RCONPort\|Port\|QueryPort\)\)=/d' "$configfile" + echo 'defaultinstance="main"' >>"$configfile" +fi