#!/usr/bin/env bash set -euo pipefail script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # shellcheck source=/dev/null source "${script_dir}/aqua-mirror-service-common.sh" apply=0 replace_existing=0 hosted_config_explicit=0 mirror_dir_explicit=0 state_file_explicit=0 platform="$(aquaclaw_mirror_detect_platform || true)" if [[ -z "${platform}" ]]; then echo "unsupported platform: $(uname -s). This installer supports macOS launchd and Linux systemd user services." >&2 exit 1 fi label="$(aquaclaw_mirror_default_label)" workspace_root="$(aquaclaw_mirror_default_workspace_root)" hub_url="$(aquaclaw_mirror_default_hub_url)" mode="$(aquaclaw_mirror_default_mode)" hosted_config="$(aquaclaw_mirror_default_hosted_config "${workspace_root}")" mirror_dir="$(aquaclaw_mirror_default_mirror_dir "${workspace_root}")" state_file="$(aquaclaw_mirror_default_state_file "${mirror_dir}")" reconnect_seconds="$(aquaclaw_mirror_default_reconnect_seconds)" hydrate_conversations="$(aquaclaw_mirror_default_hydrate_conversations)" hydrate_public_threads="$(aquaclaw_mirror_default_hydrate_public_threads)" public_thread_limit="$(aquaclaw_mirror_default_public_thread_limit)" stdout_log="$(aquaclaw_mirror_default_stdout_log)" stderr_log="$(aquaclaw_mirror_default_stderr_log)" while [[ $# -gt 0 ]]; do case "$1" in --apply) apply=1 shift ;; --replace) replace_existing=1 shift ;; --label) label="$2" shift 2 ;; --workspace-root) workspace_root="$2" if [[ "${hosted_config_explicit}" -ne 1 ]]; then hosted_config="$(aquaclaw_mirror_default_hosted_config "${workspace_root}")" fi if [[ "${mirror_dir_explicit}" -ne 1 ]]; then mirror_dir="$(aquaclaw_mirror_default_mirror_dir "${workspace_root}")" fi if [[ "${state_file_explicit}" -ne 1 ]]; then state_file="$(aquaclaw_mirror_default_state_file "${mirror_dir}")" fi shift 2 ;; --hub-url) hub_url="$2" shift 2 ;; --mode) mode="$2" shift 2 ;; --hosted-config) hosted_config="$2" hosted_config_explicit=1 shift 2 ;; --mirror-dir) mirror_dir="$2" mirror_dir_explicit=1 if [[ "${state_file_explicit}" -ne 1 ]]; then state_file="$(aquaclaw_mirror_default_state_file "${mirror_dir}")" fi shift 2 ;; --state-file) state_file="$2" state_file_explicit=1 shift 2 ;; --reconnect-seconds) reconnect_seconds="$2" shift 2 ;; --hydrate-conversations) hydrate_conversations=1 shift ;; --hydrate-public-threads) hydrate_public_threads=1 shift ;; --public-thread-limit) public_thread_limit="$2" shift 2 ;; --stdout-log) stdout_log="$2" shift 2 ;; --stderr-log) stderr_log="$2" shift 2 ;; -h|--help) cat <<'EOF' Usage: install-aquaclaw-mirror-service.sh [options] Options: --apply Actually write and start the service --replace Overwrite an existing service file --label