#!/usr/bin/env bash # # Imports tickets from a Hesk 3.x helpdesk database into this app, filtered # to one e-mail domain. Thin wrapper around `php artisan hesk:import` (see # ../../src/app/Console/Commands/ImportHeskTickets.php for the actual logic) # — this script only wires up the Hesk DB credentials and runs it inside the # app container. See README.md in this folder for full setup/usage docs. # # Setup: copy .env.example (this folder) to .env (gitignored) and fill in # your Hesk database's host/port/database/username/password. # # Usage: # scripts/hesk-import/hesk-import.sh --domain=firma.pl # dry run (default, writes nothing) # scripts/hesk-import/hesk-import.sh --domain=firma.pl --limit=10 --commit # real run, first 10 tickets only # scripts/hesk-import/hesk-import.sh --domain=firma.pl --commit # real run, everything # # Safe to re-run: already-imported Hesk tickets are tracked in # storage/app/hesk-import-state.json inside the app container and skipped. set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPO_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)" ENV_FILE="$SCRIPT_DIR/.env" if [[ ! -f "$ENV_FILE" ]]; then echo "Brak $ENV_FILE — skopiuj scripts/hesk-import/.env.example i uzupełnij dane dostępowe do bazy Heska." >&2 exit 1 fi set -a # shellcheck disable=SC1090 source "$ENV_FILE" set +a : "${HESK_DB_HOST:?ustaw HESK_DB_HOST w $ENV_FILE}" : "${HESK_DB_DATABASE:?ustaw HESK_DB_DATABASE w $ENV_FILE}" : "${HESK_DB_USERNAME:?ustaw HESK_DB_USERNAME w $ENV_FILE}" HESK_DB_PORT="${HESK_DB_PORT:-3306}" cd "$REPO_ROOT" exec sudo docker compose exec \ -e HESK_DB_HOST="$HESK_DB_HOST" \ -e HESK_DB_PORT="$HESK_DB_PORT" \ -e HESK_DB_DATABASE="$HESK_DB_DATABASE" \ -e HESK_DB_USERNAME="$HESK_DB_USERNAME" \ -e HESK_DB_PASSWORD="$HESK_DB_PASSWORD" \ app php artisan hesk:import "$@"