Add script to migrate main instance

This commit is contained in:
Ben Peddell 2015-11-21 23:14:53 +10:00
parent 61446ab88c
commit b2ae770b99
2 changed files with 12 additions and 0 deletions

View File

@ -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!"

10
tools/migrate-main-instance.sh Executable file
View File

@ -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