diff --git a/entrypoint-user.sh b/entrypoint-user.sh index 7c88029..41bbef4 100755 --- a/entrypoint-user.sh +++ b/entrypoint-user.sh @@ -12,6 +12,16 @@ exit_handler_user() { echo -e "Loading exit handler" trap exit_handler_user SIGQUIT SIGINT SIGTERM +execute_hook_directory() { + for f in $1; do + if ! bash "$f" + then + echo "Failed running hook \"$f\"" + exit 1 + fi + done +} + # Setup game server if [ ! -f "${GAMESERVER}" ]; then echo -e "" @@ -30,6 +40,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 +75,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 "================================="