Add Khanegi SMS sync inventory, batch import, and rollout helpers.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
# Run on SuperAdmin host. Imports one Khanegi version MySQL → SuperAdmin SmsAccount.
|
||||
#
|
||||
# Usage:
|
||||
# bash deploy/khanegi-sms-import-one.sh DOMAIN DB_HOST DB_USER DB_PASSWORD DB_NAME [--apply]
|
||||
#
|
||||
# Default is dry-run. Pass --apply for real write.
|
||||
set -euo pipefail
|
||||
|
||||
DOMAIN="${1:-}"
|
||||
DB_HOST="${2:-127.0.0.1}"
|
||||
DB_USER="${3:-}"
|
||||
DB_PASSWORD="${4:-}"
|
||||
DB_NAME="${5:-}"
|
||||
MODE="${6:-}"
|
||||
|
||||
if [[ -z "$DOMAIN" || -z "$DB_USER" || -z "$DB_NAME" ]]; then
|
||||
echo "Usage: $0 DOMAIN DB_HOST DB_USER DB_PASSWORD DB_NAME [--apply]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
if [[ -d /var/www/superadmin/api ]]; then
|
||||
API_DIR=/var/www/superadmin/api
|
||||
elif [[ -f "$SCRIPT_DIR/../package.json" ]]; then
|
||||
API_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
else
|
||||
API_DIR="$(cd "$SCRIPT_DIR/../apps/api" && pwd)"
|
||||
fi
|
||||
|
||||
cd "$API_DIR"
|
||||
|
||||
export SMS_IMPORT_DOMAIN="$DOMAIN"
|
||||
export SMS_IMPORT_PRODUCT=khanegi
|
||||
export SMS_IMPORT_DB_HOST="$DB_HOST"
|
||||
export SMS_IMPORT_DB_PORT=3306
|
||||
export SMS_IMPORT_DB_USER="$DB_USER"
|
||||
export SMS_IMPORT_DB_PASSWORD="$DB_PASSWORD"
|
||||
export SMS_IMPORT_DB_DATABASE="$DB_NAME"
|
||||
|
||||
if [[ "$MODE" == "--apply" ]]; then
|
||||
unset SMS_IMPORT_DRY_RUN || true
|
||||
echo "APPLY import for $DOMAIN"
|
||||
else
|
||||
export SMS_IMPORT_DRY_RUN=1
|
||||
echo "DRY-RUN import for $DOMAIN"
|
||||
fi
|
||||
|
||||
npm run prisma:import-sms-from-product
|
||||
Reference in New Issue
Block a user