diff --git a/linuxgsm.sh b/linuxgsm.sh index ca3bfc746..2961596ae 100644 --- a/linuxgsm.sh +++ b/linuxgsm.sh @@ -387,76 +387,75 @@ else else echo -e "OK" fi - else - function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg") - if [ "${function_file_diff}" != "" ]; then - fn_print_warn_nl "_default.cfg has altered. reloading config." - echo -en "copying _default.cfg...\c" - cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" - if [ $? != 0 ]; then - echo -e "FAIL" - exit 1 - else - echo -e "OK" - fi + else + function_file_diff=$(diff -q "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg") + if [ "${function_file_diff}" != "" ]; then + fn_print_warn_nl "_default.cfg has altered. reloading config." + echo -en "copying _default.cfg...\c" + cp -R "${configdirdefault}/config-lgsm/${gameservername}/_default.cfg" "${configdirserver}/_default.cfg" + if [ $? != 0 ]; then + echo -e "FAIL" + exit 1 + else + echo -e "OK" fi fi - # Configs have to be loaded twice to allow start startparameters to pick up all vars + fi + # Configs have to be loaded twice to allow start startparameters to pick up all vars + # shellcheck source=/dev/null + source "${configdirserver}/_default.cfg" + # Load the common.cfg config. If missing download it. + if [ ! -f "${configdirserver}/common.cfg" ]; then + fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5" + # shellcheck source=/dev/null + source "${configdirserver}/common.cfg" + else + # shellcheck source=/dev/null + source "${configdirserver}/common.cfg" + fi + # Load the secrets-common.cfg config. If missing download it. + if [ ! -f "${configdirserver}/secrets-common.cfg" ]; then + fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-common-template.cfg" "${configdirserver}" "secrets-common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5" + # shellcheck source=/dev/null + source "${configdirserver}/secrets-common.cfg" + else + # shellcheck source=/dev/null + source "${configdirserver}/secrets-common.cfg" + fi + # Load the instance.cfg config. If missing download it. + if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then + fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5" + # shellcheck source=/dev/null + source "${configdirserver}/${selfname}.cfg" + else + # shellcheck source=/dev/null + source "${configdirserver}/${selfname}.cfg" + fi + # Load the secrets-instance.cfg config. If missing download it. + if [ ! -f "${configdirserver}/secrets-${selfname}.cfg" ]; then + fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-instance-template.cfg" "${configdirserver}" "secrets-${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5" + # shellcheck source=/dev/null + source "${configdirserver}/secrets-${selfname}.cfg" + else + # shellcheck source=/dev/null + source "${configdirserver}/secrets-${selfname}.cfg" + fi + if [ -n "$(grep startparameters "${configdirserver}/common.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/${selfname}.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/secrets-common.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/secrets-${selfname}.cfg" | sed -e '/^#/d')" ]; then + : + else + if [ "${shortname}" == "wurm" ]; then # shellcheck source=/dev/null - source "${configdirserver}/_default.cfg" - # Load the common.cfg config. If missing download it. - if [ ! -f "${configdirserver}/common.cfg" ]; then - fn_fetch_config "lgsm/config-default/config-lgsm" "common-template.cfg" "${configdirserver}" "common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5" - # shellcheck source=/dev/null - source "${configdirserver}/common.cfg" - else - # shellcheck source=/dev/null - source "${configdirserver}/common.cfg" - fi - # Load the secrets-common.cfg config. If missing download it. - if [ ! -f "${configdirserver}/secrets-common.cfg" ]; then - fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-common-template.cfg" "${configdirserver}" "secrets-common.cfg" "${chmodx}" "nochmodx" "norun" "noforcedl" "nomd5" - # shellcheck source=/dev/null - source "${configdirserver}/secrets-common.cfg" - else - # shellcheck source=/dev/null - source "${configdirserver}/secrets-common.cfg" - fi - # Load the instance.cfg config. If missing download it. - if [ ! -f "${configdirserver}/${selfname}.cfg" ]; then - fn_fetch_config "lgsm/config-default/config-lgsm" "instance-template.cfg" "${configdirserver}" "${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5" - # shellcheck source=/dev/null - source "${configdirserver}/${selfname}.cfg" - else - # shellcheck source=/dev/null - source "${configdirserver}/${selfname}.cfg" - fi - # Load the secrets-instance.cfg config. If missing download it. - if [ ! -f "${configdirserver}/secrets-${selfname}.cfg" ]; then - fn_fetch_config "lgsm/config-default/config-lgsm" "secrets-instance-template.cfg" "${configdirserver}" "secrets-${selfname}.cfg" "nochmodx" "norun" "noforcedl" "nomd5" - # shellcheck source=/dev/null - source "${configdirserver}/secrets-${selfname}.cfg" - else - # shellcheck source=/dev/null - source "${configdirserver}/secrets-${selfname}.cfg" - fi - if [ -n "$(grep startparameters "${configdirserver}/common.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/${selfname}.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/secrets-common.cfg" | sed -e '/^#/d')" ]||[ -n "$(grep startparameters "${configdirserver}/secrets-${selfname}.cfg" | sed -e '/^#/d')" ]; then - : - else - if [ "${shortname}" == "wurm" ]; then - # shellcheck source=/dev/null - source "${servercfgfullpath}" - fi - eval startparameters="$(grep -w startparameters= "${configdirserver}/_default.cfg" | sed -e 's/startparameters=//g')" - eval executable="$(grep -w executable= "${configdirserver}/_default.cfg" | sed -e 's/executable=//g')" - fi - - # Load the linuxgsm.sh in to tmpdir. If missing download it. - if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then - fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5" - fi + source "${servercfgfullpath}" + fi + eval startparameters="$(grep -w startparameters= "${configdirserver}/_default.cfg" | sed -e 's/startparameters=//g')" + eval executable="$(grep -w executable= "${configdirserver}/_default.cfg" | sed -e 's/executable=//g')" + fi + # Load the linuxgsm.sh in to tmpdir. If missing download it. + if [ ! -f "${tmpdir}/linuxgsm.sh" ]; then + fn_fetch_file_github "" "linuxgsm.sh" "${tmpdir}" "chmodx" "norun" "noforcedl" "nomd5" fi +fi # Enables ANSI colours from core_messages.sh. Can be disabled with ansi=off. fn_ansi_loader