Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(scripts): read ENGINE_TYPE through the config layers in backup
Yudhi Armyndharisbe2a79bee94f
diff --git a/scripts/backup.sh b/scripts/backup.shindex 2b6fb1541..528428200 100755--- a/scripts/backup.sh+++ b/scripts/backup.sh@@ -222,7 +222,7 @@ if [ -d "$BAILEYS_DIR" ]; thenif [ -n "$(find -H "$BAILEYS_DIR" -mindepth 1 -maxdepth 1 -type d -print -quit)" ]; thenrecord_engine_state_note "baileys/ (recorded whenever Baileys state exists; it cannot show whether it was live)"fi-elif [ "${ENGINE_TYPE:-}" = "baileys" ]; then+elif [ "$(openwa_resolve ENGINE_TYPE '')" = "baileys" ]; thenlog "WARN: ENGINE_TYPE=baileys but $BAILEYS_DIR was not found — restored sessions will require pairing"fidiff --git a/scripts/smoke-test-backup-restore.sh b/scripts/smoke-test-backup-restore.shindex 385d1c593..aff62dbe2 100755--- a/scripts/smoke-test-backup-restore.sh+++ b/scripts/smoke-test-backup-restore.sh@@ -42,6 +42,7 @@# (aa) engine auth state copied from a running app (an open whatsapp-web.js profile, Baileys state)# is noted in the archive and printed by restore, which does not refuse it even with --strict# (ab) a blank ./.env line keeps data/.env.generated from supplying the key, so the default applies+# (ac) a missing Baileys auth dir is reported when data/.env.generated selects the Baileys engine## Usage: ./scripts/smoke-test-backup-restore.sh# Requires: bash, tar, node (restore.sh path resolution). sqlite3 is optional (see (c) and (k)).@@ -1248,5 +1249,20 @@ if [ "$(db_fingerprint "$AB/extract/openwa.sqlite")" != "bravo2-default" ]; thenfipass "(ab) a blank ./.env line stops the lookup and the built-in default applies"+echo ""+echo "==> (ac) a Baileys engine chosen in the dashboard is warned about when its auth dir is missing"+# Compose forwards a blank ENGINE_TYPE and the dashboard saves the real one in data/.env.generated, so+# reading the environment alone never saw Baileys there and skipped the re-pairing warning.+AC="$WORK/ac"+mkdir -p "$AC/data"+make_fixture "$AC/data/main.sqlite" "charlie2-main"+make_fixture "$AC/data/openwa.sqlite" "charlie2-data"+printf 'ENGINE_TYPE=baileys\n' >"$AC/data/.env.generated"+OUT_AC="$(cd "$AC" && ENGINE_TYPE='' BACKUP_DIR="$AC/out" "$BACKUP" 2>&1)"+if ! printf '%s' "$OUT_AC" | grep -q 'ENGINE_TYPE=baileys but .* was not found'; then+ fail "(ac) a dashboard-selected Baileys engine with no auth dir was not reported: $OUT_AC"+fi+pass "(ac) the missing Baileys auth dir is reported when data/.env.generated selects Baileys"+echo ""echo "All smoke tests passed!"