#!/usr/bin/env bash set -euo pipefail ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" . "$ROOT_DIR/scripts/lib.sh" SERVICE="${1:-}" [ -n "$SERVICE" ] || fail_json "XUQM_PRIVATE_1002" "service name is required (im|push|update|license)" "disable-service" if [ ! -f "$ROOT_DIR/.env" ]; then cp "$ROOT_DIR/.env.example" "$ROOT_DIR/.env" fi load_env audit "disable-service" "STARTED" "$SERVICE" progress "disable-service" "STARTED" "$SERVICE" case "$SERVICE" in im|push|update|license) ;; *) fail_json "XUQM_PRIVATE_1002" "unknown service: $SERVICE (valid: im push update license)" "disable-service" ;; esac # Stop the container first (data is preserved) compose stop "${SERVICE}-service" 2>/dev/null || true compose rm -f "${SERVICE}-service" 2>/dev/null || true # Update feature flag and profile set_env_value "$ROOT_DIR/.env" "ENABLE_$(printf '%s' "$SERVICE" | tr '[:lower:]' '[:upper:]')" "false" NEW_PROFILES="$(remove_profile "${COMPOSE_PROFILES:-base}" "$SERVICE")" set_env_value "$ROOT_DIR/.env" "COMPOSE_PROFILES" "$NEW_PROFILES" load_env "$ROOT_DIR/scripts/render-config.sh" audit "disable-service" "DONE" "$SERVICE profiles=$NEW_PROFILES" progress "disable-service" "DONE" "$SERVICE" printf 'Service disabled: %s\nActive profiles: %s\nNote: data is preserved.\n' "$SERVICE" "$NEW_PROFILES"