From 681ffc488d33733f694b0a908933914f5c903294 Mon Sep 17 00:00:00 2001 From: Matthew Dangerfield <45240788+mdangerf@users.noreply.github.com> Date: Sun, 7 Jul 2024 19:24:02 -0400 Subject: [PATCH] [Arma 3] Added RPT logging (#253) - Adds RPT logging (logs will be located in `/home/container/serverprofile/rpt/`, but only if `-noLogs` is not used as a startup parameter) - Fixes edge case where clearing HC cache on first boot may fail due to a missing `serverprofile/` folder. --- games/arma3/entrypoint.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/games/arma3/entrypoint.sh b/games/arma3/entrypoint.sh index c78599c93..62496bda1 100644 --- a/games/arma3/entrypoint.sh +++ b/games/arma3/entrypoint.sh @@ -346,6 +346,12 @@ if [[ ${MODS_LOWERCASE} == "1" ]]; then done fi +# Define the log file path with a timestamp +LOG_FILE="/home/container/serverprofile/rpt/arma3server_$(date '+%m_%d_%Y_%H%M%S').rpt" + +# Ensure the logs directory exists +mkdir -p /home/container/serverprofile/rpt + # Clear HC cache, if specified if [[ ${CLEAR_CACHE} == "1" ]]; then echo -e "\n${GREEN}[STARTUP]: ${CYAN}Clearing Headless Client profiles cache...${NC}" @@ -395,7 +401,11 @@ fi # Start the Server echo -e "\n${GREEN}[STARTUP]:${NC} Starting server with the following startup command:" echo -e "${CYAN}${modifiedStartup}${NC}\n" -${modifiedStartup} +if [[ "$STARTUP_PARAMS" == *"-noLogs"* ]]; then + ${modifiedStartup} +else + ${modifiedStartup} 2>&1 | tee -a "$LOG_FILE" +fi if [ $? -ne 0 ]; then echo -e "\n${RED}PTDL_CONTAINER_ERR: There was an error while attempting to run the start command.${NC}\n"