From e77f916ec50bc59d46049cba934137059a59a98e Mon Sep 17 00:00:00 2001 From: uprightbass360 Date: Sun, 2 Nov 2025 18:08:17 -0500 Subject: [PATCH] fixing beastmaster and default lua install --- config/modules.json | 2 +- scripts/hooks/copy-standard-lua | 10 ++++----- scripts/hooks/fix-beastmaster-sql | 36 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 6 deletions(-) create mode 100755 scripts/hooks/fix-beastmaster-sql diff --git a/config/modules.json b/config/modules.json index aa8dc31..336fff3 100644 --- a/config/modules.json +++ b/config/modules.json @@ -301,7 +301,7 @@ "repo": "https://github.com/azerothcore/mod-npc-beastmaster.git", "needs_build": true, "type": "cpp", - "post_install_hooks": [], + "post_install_hooks": ["fix-beastmaster-sql"], "config_cleanup": [ "npc_beastmaster.conf*" ], diff --git a/scripts/hooks/copy-standard-lua b/scripts/hooks/copy-standard-lua index e1f7394..d027e1d 100755 --- a/scripts/hooks/copy-standard-lua +++ b/scripts/hooks/copy-standard-lua @@ -16,11 +16,11 @@ fi echo "📜 copy-standard-lua: Processing $MODULE_NAME" -# Create target directory -mkdir -p "$LUA_SCRIPTS_TARGET" 2>/dev/null || { - echo "âš ī¸ copy-standard-lua: Cannot create target directory $LUA_SCRIPTS_TARGET" - exit 1 -} +# Create target directory if possible +if ! mkdir -p "$LUA_SCRIPTS_TARGET" 2>/dev/null; then + echo "â„šī¸ copy-standard-lua: Target directory $LUA_SCRIPTS_TARGET not accessible (will be copied during container build)" + exit 0 +fi copied_count=0 diff --git a/scripts/hooks/fix-beastmaster-sql b/scripts/hooks/fix-beastmaster-sql new file mode 100755 index 0000000..76277ab --- /dev/null +++ b/scripts/hooks/fix-beastmaster-sql @@ -0,0 +1,36 @@ +#!/bin/bash +# Post-install hook to fix beastmaster SQL duplicate key issue +set -e + +MODULE_DIR="${MODULE_DIR:-}" +MODULE_NAME="${MODULE_NAME:-}" + +if [ -z "$MODULE_DIR" ] || [ ! -d "$MODULE_DIR" ]; then + echo "❌ fix-beastmaster-sql: Invalid module directory: $MODULE_DIR" + exit 2 +fi + +echo "🔧 fix-beastmaster-sql: Patching SQL file for $MODULE_NAME" + +SQL_FILE="$MODULE_DIR/data/sql/db-world/beastmaster_tames_inserts.sql" + +if [ ! -f "$SQL_FILE" ]; then + echo " â„šī¸ SQL file not found, skipping: $SQL_FILE" + exit 0 +fi + +# Check if already patched +if grep -q "INSERT IGNORE INTO" "$SQL_FILE" 2>/dev/null; then + echo " ✅ SQL file already patched" + exit 0 +fi + +# Apply patch to make SQL idempotent +if sed -i 's/^INSERT INTO beastmaster_tames/INSERT IGNORE INTO beastmaster_tames/g' "$SQL_FILE"; then + echo " ✅ Patched SQL file to use INSERT IGNORE" +else + echo " âš ī¸ Failed to patch SQL file" + exit 1 +fi + +exit 0