From 0611da886866159f1700f5cd0886d3404bafe4bf Mon Sep 17 00:00:00 2001 From: Josh Bryans Date: Sat, 30 Sep 2023 09:30:28 -0400 Subject: [PATCH 1/3] Support pre/post install hook directories --- entrypoint-user.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/entrypoint-user.sh b/entrypoint-user.sh index 7c88029..2495999 100755 --- a/entrypoint-user.sh +++ b/entrypoint-user.sh @@ -12,6 +12,17 @@ exit_handler_user() { echo -e "Loading exit handler" trap exit_handler_user SIGQUIT SIGINT SIGTERM +execute_hook_directory() { + for f in $1; do + bash "$f" + if [ $? -ne 0 ] + then + echo "Failed running hook \"$f\". exit code $?" + exit 1 + fi + done +} + # Setup game server if [ ! -f "${GAMESERVER}" ]; then echo -e "" @@ -30,6 +41,14 @@ elif [ -d "/app/lgsm/modules" ]; then chmod +x /app/lgsm/modules/* fi +# Run pre-install scripts +if [ -d "/app/hooks/pre-install" ]; then + echo -e "" + echo -e "Executing pre-install hooks" + echo -e "=================================" + execute_hook_directory "/app/hooks/pre-install/*.sh" +fi + # Install game server if [ -z "$(ls -A -- "/data/serverfiles" 2> /dev/null)" ]; then echo -e "" @@ -57,6 +76,14 @@ if [ -z "${install}" ]; then ./"${GAMESERVER}" update fi +# Run pre-install scripts +if [ -d "/app/hooks/post-install" ]; then + echo -e "" + echo -e "Executing post-install hooks" + echo -e "=================================" + execute_hook_directory "/app/hooks/post-install/*.sh" +fi + echo -e "" echo -e "Starting ${GAMESERVER}" echo -e "=================================" From 391086c2abcfe3cee887d5e0f657c1ed48d37e10 Mon Sep 17 00:00:00 2001 From: Josh Bryans Date: Sat, 30 Sep 2023 10:19:12 -0400 Subject: [PATCH 2/3] address codacy issue --- entrypoint-user.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/entrypoint-user.sh b/entrypoint-user.sh index 2495999..8eb6177 100755 --- a/entrypoint-user.sh +++ b/entrypoint-user.sh @@ -14,10 +14,9 @@ trap exit_handler_user SIGQUIT SIGINT SIGTERM execute_hook_directory() { for f in $1; do - bash "$f" - if [ $? -ne 0 ] + if ! bash $f then - echo "Failed running hook \"$f\". exit code $?" + echo "Failed running hook \"$f\"" exit 1 fi done From 7435a72127ee21fa743b914c1b3830a19870882c Mon Sep 17 00:00:00 2001 From: Josh Bryans Date: Sat, 30 Sep 2023 10:25:52 -0400 Subject: [PATCH 3/3] address codacy issue --- entrypoint-user.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint-user.sh b/entrypoint-user.sh index 8eb6177..41bbef4 100755 --- a/entrypoint-user.sh +++ b/entrypoint-user.sh @@ -14,7 +14,7 @@ trap exit_handler_user SIGQUIT SIGINT SIGTERM execute_hook_directory() { for f in $1; do - if ! bash $f + if ! bash "$f" then echo "Failed running hook \"$f\"" exit 1