Change serveradmin.xml to be back in Saves dir

This commit is contained in:
Price Hiller 2022-01-01 02:43:35 -06:00
parent a77535a1d1
commit 18088bbafd

View File

@ -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" "<property name=\"UserDataFolder\" value=\"${server_userdata_dir}\" />"
# 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" "<property name=\"AdminFileName\" value=\"../serveradmin.xml\" />"
# Manage the telnet tags
elif [[ "${REPLY}" = *"property name=\"TelnetPort\""* ]]; then
printf "\t%s\n" "<property name=\"TelnetPort\" value=\"${telnet_port}\" />"
@ -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