From 18088bbafd973c63501568513ed3148c269b57b2 Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 1 Jan 2022 02:43:35 -0600 Subject: [PATCH] Change serveradmin.xml to be back in Saves dir --- Scripts/7D2D-Manage.bash | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/Scripts/7D2D-Manage.bash b/Scripts/7D2D-Manage.bash index 4234ebf..0b78ef8 100644 --- a/Scripts/7D2D-Manage.bash +++ b/Scripts/7D2D-Manage.bash @@ -152,6 +152,17 @@ important() { echo_rgb "${1}" 135 195 255 } +xml_lint_dir() { + + for xml_file in "${1}"/*.xml; do + log "info" "Linting $(important "${xml_file}")" + if ! xmllint "${xml_file}" >/dev/null; then + log "error" "Xml parsing error in $(important "${xml_file}"), resolve the error and attempt to start again" + return 1 + fi + done + +} start_server() { local server_id local can_kill @@ -226,11 +237,11 @@ start_server() { local telnet_port local allocs_port # This multiplication gives us 5 available ports for this server, safely allows us to block off ports efficiently - server_port="$((PRIMARY_START_PORT_RANGE + $(("${server_id}" * 5)) ))" + server_port="$((PRIMARY_START_PORT_RANGE + $(("${server_id}" * 5))))" server_port="${SERVER_PORT:-$server_port}" - telnet_port="$(( server_port + 1 ))" - allocs_port="$(( server_port + 2 ))" + telnet_port="$((server_port + 1))" + allocs_port="$((server_port + 2))" telnet_port="${TELNET_PORT:-$telnet_port}" log "info" "Generating a few required directories in $(important "${server_directory}")" @@ -250,10 +261,6 @@ start_server() { # Override UserDataFolder, opiniated in that it should exist in the Server Directory elif [[ "${REPLY}" = *"property name=\"UserDataFolder\""* ]]; then printf "\t%s\n" "" - # This is a path RELATIVE to the save game folder, hence we overwrite ../ so it's in the - # base of the server directory - elif [[ "${REPLY}" = *"property name=\"AdminFileName\""* ]]; then - printf "\t%s\n" "" # Manage the telnet tags elif [[ "${REPLY}" = *"property name=\"TelnetPort\""* ]]; then printf "\t%s\n" "" @@ -273,13 +280,11 @@ start_server() { # xmllint, helps avoiding the random server launch failures for apparently no reason if which xmllint >/dev/null 2>&1; then - for xml_file in "${server_directory}"/*.xml; do - log "info" "Linting $(important "${xml_file}")" - if ! xmllint "${xml_file}" > /dev/null; then - log "error" "Xml parsing error in $(important "${xml_file}"), resolve the error and attempt to start again" - return 1 - fi - done + if ! xml_lint_dir "${server_directory}"; then + return 1 + elif ! xml_lint_dir "${server_directory}/Saves/"; then + return 1 + fi else log "warning" "$(important "xmllint") not installed or not in PATH, skipping lint check" fi @@ -380,7 +385,7 @@ kill_server() { local max_attempts attempts=0 max_attempts=3 - while tmux has-session -t "${session}" > /dev/null 2>&1; do + while tmux has-session -t "${session}" >/dev/null 2>&1; do if [[ "${attempts}" -eq "${max_attempts}" ]]; then log "error" "Unable to kill session ${session}" return 1