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:
parent
ae1f3bd2c7
commit
a334ba6823
2 changed files with 11 additions and 8 deletions
|
@ -2,13 +2,17 @@
|
||||||
|
|
||||||
DIR=$(realpath $(dirname $0))
|
DIR=$(realpath $(dirname $0))
|
||||||
|
|
||||||
directory=$1
|
|
||||||
shift
|
|
||||||
script_name=$1
|
script_name=$1
|
||||||
shift
|
shift
|
||||||
|
|
||||||
|
if [[ -e /.dockerenv ]]; then
|
||||||
|
root_dir="/scripts"
|
||||||
|
else
|
||||||
|
root_dir="/pelican/data/botc"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "${script_name}x" != "x" ]]; then
|
if [[ "${script_name}x" != "x" ]]; then
|
||||||
script_file="${directory}/${script_name}.png"
|
script_file="${root_dir}/${script_name}.png"
|
||||||
else
|
else
|
||||||
script_file="${DIR}/templates/map_background.png"
|
script_file="${DIR}/templates/map_background.png"
|
||||||
fi
|
fi
|
||||||
|
@ -19,7 +23,7 @@ rm ${map_file}
|
||||||
cp ${script_file} ${map_file}
|
cp ${script_file} ${map_file}
|
||||||
# Package resource pack
|
# Package resource pack
|
||||||
pushd "${DIR}/templates"
|
pushd "${DIR}/templates"
|
||||||
mkdir -p /scripts/files
|
mkdir -p "${root_dir}/files"
|
||||||
rm /scripts/files/botc-script-resource-pack.zip
|
rm "${root_dir}/files/botc-script-resource-pack.zip"
|
||||||
zip -r /scripts/files/botc-script-resource-pack.zip texture-pack
|
zip -r "${root_dir}/files/botc-script-resource-pack.zip" texture-pack
|
||||||
popd
|
popd
|
|
@ -4,10 +4,9 @@
|
||||||
|
|
||||||
: "${ACTIVE_SCRIPT:=}"
|
: "${ACTIVE_SCRIPT:=}"
|
||||||
|
|
||||||
SCRIPT_DIR="/scripts"
|
|
||||||
TOOL_SCRIPT_DIR="/home/container/.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}"
|
echo "Memory: ${SERVER_MEMORY}"
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue