Refactor script paths to use dynamic root directory

Replaced hardcoded paths with dynamic root directory selection based on the environment. Removed unused variable and simplified the `load-script.sh` invocation. These changes improve maintainability and adaptability for different environments.
This commit is contained in:
Nick Guy 2025-06-02 22:13:10 +01:00
parent ae1f3bd2c7
commit a334ba6823
2 changed files with 11 additions and 8 deletions

View file

@ -2,13 +2,17 @@
DIR=$(realpath $(dirname $0))
directory=$1
shift
script_name=$1
shift
if [[ -e /.dockerenv ]]; then
root_dir="/scripts"
else
root_dir="/pelican/data/botc"
fi
if [[ "${script_name}x" != "x" ]]; then
script_file="${directory}/${script_name}.png"
script_file="${root_dir}/${script_name}.png"
else
script_file="${DIR}/templates/map_background.png"
fi
@ -19,7 +23,7 @@ rm ${map_file}
cp ${script_file} ${map_file}
# Package resource pack
pushd "${DIR}/templates"
mkdir -p /scripts/files
rm /scripts/files/botc-script-resource-pack.zip
zip -r /scripts/files/botc-script-resource-pack.zip texture-pack
mkdir -p "${root_dir}/files"
rm "${root_dir}/files/botc-script-resource-pack.zip"
zip -r "${root_dir}/files/botc-script-resource-pack.zip" texture-pack
popd

View file

@ -4,10 +4,9 @@
: "${ACTIVE_SCRIPT:=}"
SCRIPT_DIR="/scripts"
TOOL_SCRIPT_DIR="/home/container/.scripts"
"${TOOL_SCRIPT_DIR}"/load-script.sh "${SCRIPT_DIR}" "${ACTIVE_SCRIPT}"
"${TOOL_SCRIPT_DIR}/load-script.sh" "${ACTIVE_SCRIPT}"
echo "Memory: ${SERVER_MEMORY}"