Resolved Game-Primary.ini writing errors

This commit is contained in:
Price Hiller 2021-08-28 21:34:36 -05:00
parent e29004869a
commit 9cfa799a60

View File

@ -165,7 +165,7 @@ kill_server() {
case ${1} in
-h | -\? | --help)
printf "Usage: %s\n" \
"kill --server <server id: int> | kill -s <server id: int>
"kill [options]
--server <server id: int> | -s <server id: int>
Kills the server with the given id
@ -260,7 +260,7 @@ generate_default_configs() {
mkdir -p "${BASE_DIR}" && log "info" "Created base directory if it didn't exist"
mkdir -p "${CONFIG_DIRECTORY}" && log "info" "Created config directory if it didn't exist"
cat << __EOF__ > "${CONFIG_DIRECTORY}"/readme.txt
cat <<__EOF__ >"${CONFIG_DIRECTORY}"/readme.txt
Some notes about the configuration within this directory:
All configs (server.pass, rcon.pass, etc.) write to each server's Game-Primary.ini when invoked.
@ -415,7 +415,7 @@ configure() {
[[ ! -f "${primary_server_config}" ]] &&
log "error" "Unable to find a config for $(important "Server-${server_num}") (${primary_server_config})" &&
continue
continue
if [[ "${verbose}" -eq 1 ]]; then
echo ""
@ -442,12 +442,13 @@ start() {
case ${1} in
-h | -\? | --help)
printf "Usage: %s\n" \
"start --server <server id: int> | kill -s <server id: int>
"start [options]
--server <server id: int> | -s <server id: int>
Starts the given server id
Example:
--server 3
--can-kill | -c
Automatically kills the server if it is running without prompting
@ -568,10 +569,12 @@ start() {
# Loading primary config bool is incredibly important as it controls loading the external configurations to the server
local primary_config_admins_mods
local loading_primary_config
local removing_old_primary_config
local loaded_primary_config
loading_primary_config=0
loaded_primary_config=0
removing_old_primary_config=0
primary_config_admins_mods="$(
cat <<__EOF__
# BEGIN PRIMARY CONFIG - DO NOT INCLUDE SERVER SPECIFIC CONFIGURATION BETWEEN THIS LINE AND "END PRIMARY CONFIG"
@ -587,27 +590,40 @@ __EOF__
log "info" "Overwriting Game.ini..."
while read -r line; do
if [[ "${line}" == "RconPort="* ]] && [ "${updated_rcon_port}" -eq 0 ]; then
if [[ "${line}" == "RconPort="* ]] && [[ "${updated_rcon_port}" -eq 0 ]]; then
echo "RconPort=${rcon_port}"
updated_rcon_port=1
elif [[ "${line}" == "RconPassword="* ]] && [ "${updated_rcon_pass}" -eq 0 ]; then
[[ -n "${rcon_pass}" ]] && \
elif [[ "${line}" == "RconPassword="* ]] && [[ "${updated_rcon_pass}" -eq 0 ]]; then
[[ -n "${rcon_pass}" ]] &&
echo "RconPassword=${rcon_pass}"
updated_rcon_pass=1
elif [[ "${line}" == "ServerPassword="* ]] && [ "${updated_server_pass}" -eq 0 ]; then
[[ -n "${server_pass}" ]] && \
elif [[ "${line}" == "ServerPassword="* ]] && [[ "${updated_server_pass}" -eq 0 ]]; then
[[ -n "${server_pass}" ]] &&
echo "ServerPassword=${server_pass}"
updated_server_pass=1
elif [[ "${line}" == *"BEGIN PRIMARY CONFIG"* ]]; then
elif [[ "${line}" == *"Mordhau.MordhauGameSession"* ]]; then
loading_primary_config=1
elif [[ "${line}" == *"END PRIMARY CONFIG"* ]]; then
loading_primary_config=0
echo "${primary_config_admins_mods}"
loaded_primary_config=1
elif [ "${loading_primary_config}" -eq 0 ]; then
echo "${line}"
elif [[ "${loading_primary_config}" -eq 1 ]]; then
if [[ "${line}" == *"["* ]]; then
echo "${primary_config_admins_mods}"
loading_primary_config=0
loaded_primary_config=1
echo ""
echo "${line}"
else
if [[ "${line}" == *"BEGIN PRIMARY CONFIG"* ]]; then
removing_old_primary_config=1
elif [[ "${line}" == *"END PRIMARY CONFIG"* ]]; then
removing_old_primary_config=0
elif [[ "${removing_old_primary_config}" -eq 0 ]]; then
echo "${line}"
fi
fi
else
echo "${line}"
fi
done <"${game_primary}" >"serv.temp"
done < "${game_primary}" >"serv.temp"
if [ "${loaded_primary_config}" -eq 0 ]; then
log "info" "Primary config not injected, loading it now..."
@ -654,14 +670,18 @@ update() {
case ${1} in
-h | -\? | --help)
printf "Usage: %s\n" \
"update --server <server id: int> | kill -s <server id: int>
"update [options]
--server <server id: int> | -s <server id: int>
Starts the given server id
Example:
--server 3
--redownload-mods | -r
Redownloads all mods by clearing the .modio folder"
--redownload-mods | -r
Redownloads all mods by clearing the .modio folder
Example:
--redownload-mods"
exit
;;
--) # End of all options.
@ -702,10 +722,10 @@ update() {
log "info" "Verifying and updating server"
steamcmd +login anonymous +force_install_dir "${server_directory}" +app_update 629800 validate +quit
run_and_stop "${server_id}"
[[ ! -f "${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" ]] \
&& log "info" "Generating a Game-Primary.ini as it did not exist" \
&& cat "${server_config}" > "${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" \
&& log "info" "Game-Primary.ini created"
[[ ! -f "${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" ]] &&
log "info" "Generating a Game-Primary.ini as it did not exist" &&
cat "${server_config}" >"${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" &&
log "info" "Game-Primary.ini created"
log "info" "Successfully verified and updated $(important "Server-${server_id}")"
}
@ -719,7 +739,7 @@ install() {
case ${1} in
-h | -\? | --help)
printf "Usage: %s\n" \
"install --server <server id: int> | install -s <server id: int>
"install [options]
--server <server id: int> | -s <server id: int>
Installs the server to the given id if it doesn't exist
@ -769,8 +789,8 @@ install() {
run_and_stop "${server_id}"
cat "${server_config}" > "${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" \
&& log "info" "Created the Game-Primary.ini file"
cat "${server_config}" >"${server_directory}/Mordhau/Saved/Config/LinuxServer/Game-Primary.ini" &&
log "info" "Created the Game-Primary.ini file"
log "info" "Finished setting up Server-${server_id}"