| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #!/usr/bin/env bash
- set -euo pipefail
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
- # shellcheck source=wp13-common.sh
- source "${SCRIPT_DIR}/wp13-common.sh"
- usage() {
- cat <<'EOF'
- Usage: install_offline.sh [options]
- Verify, load, and start a DataOps offline Compose bundle.
- Options:
- --bundle-root PATH Extracted bundle root (default: parent of operations/).
- --env-file PATH Optional environment file.
- --project-name NAME Compose project (default: dataops-test).
- --timeout SECONDS Health timeout (default: 600).
- --help Show this help.
- EOF
- }
- BUNDLE_ROOT="$(wp13_default_root)"
- ENV_FILE=""
- PROJECT_NAME="dataops-test"
- TIMEOUT_SECONDS=600
- while [[ $# -gt 0 ]]; do
- case "$1" in
- --bundle-root) BUNDLE_ROOT="$2"; shift 2 ;;
- --env-file) ENV_FILE="$2"; shift 2 ;;
- --project-name) PROJECT_NAME="$2"; shift 2 ;;
- --timeout) TIMEOUT_SECONDS="$2"; shift 2 ;;
- --help|-h) usage; exit 0 ;;
- *) wp13_die "unknown argument: $1" ;;
- esac
- done
- BUNDLE_ROOT="$(cd "${BUNDLE_ROOT}" && pwd)"
- COMPOSE_FILE="${BUNDLE_ROOT}/deploy/docker/docker-compose.yml"
- wp13_verify_checksums "${BUNDLE_ROOT}"
- wp13_require_command docker
- if [[ -f "${BUNDLE_ROOT}/images/dataops-images.tar" ]]; then
- wp13_log "loading offline images"
- docker load -i "${BUNDLE_ROOT}/images/dataops-images.tar" >/dev/null
- else
- wp13_log "image archive not present; using preloaded local images"
- fi
- preflight_args=(
- --bundle-root "${BUNDLE_ROOT}"
- --compose-file "${COMPOSE_FILE}"
- --project-name "${PROJECT_NAME}"
- )
- [[ -z "${ENV_FILE}" ]] || preflight_args+=(--env-file "${ENV_FILE}")
- bash "${SCRIPT_DIR}/preflight.sh" "${preflight_args[@]}"
- wp13_compose "${COMPOSE_FILE}" "${PROJECT_NAME}" "${ENV_FILE}" \
- up -d --no-build
- wp13_wait_for_project "${PROJECT_NAME}" "${TIMEOUT_SECONDS}"
- current="$(
- wp13_compose "${COMPOSE_FILE}" "${PROJECT_NAME}" "${ENV_FILE}" \
- exec -T backend alembic -c alembic.ini current \
- | awk 'NF {print $1; exit}'
- )"
- head="$(
- wp13_compose "${COMPOSE_FILE}" "${PROJECT_NAME}" "${ENV_FILE}" \
- exec -T backend alembic -c alembic.ini heads \
- | awk 'NF {print $1; exit}'
- )"
- [[ -n "${current}" && "${current}" == "${head}" ]] \
- || wp13_die "post-install migration mismatch: current=${current:-unknown}, head=${head:-unknown}"
- cp "${BUNDLE_ROOT}/release-manifest.txt" \
- "${BUNDLE_ROOT}/installed-${PROJECT_NAME}.manifest"
- wp13_log "offline install completed at migration ${current}"
|