#!/usr/bin/env bash # Stop optional hub modules that compete with streaming CPU. # Defaults are ENABLE_*=0 in system-stack.env.example; console Start still works. set -euo pipefail ROOT_DIR="$(cd "$(dirname "$0")/../.." && pwd)" cd "$ROOT_DIR" . scripts/linux/lib/common.sh load_env STACK_ENV="$ROOT_DIR/config/system-stack.env" mkdir -p "$(dirname "$STACK_ENV")" stack_env_upsert() { local key="$1" value="$2" touch "$STACK_ENV" if grep -q "^${key}=" "$STACK_ENV" 2>/dev/null; then sed -i "s/^${key}=.*/${key}=${value}/" "$STACK_ENV" else printf '%s=%s\n' "$key" "$value" >>"$STACK_ENV" fi } OPTIONAL_KEYS=( ENABLE_REDROID ENABLE_FRIGATE FRIGATE_USB_AUTOSTART ENABLE_HOMEASSISTANT HOMEASSISTANT_AUTOSTART ENABLE_OPENCLAW ENABLE_SRS ENABLE_MITMPROXY ENABLE_VSCODE_SERVER ENABLE_HOMEPAGE ENABLE_FILEBROWSER ENABLE_UPTIME_KUMA ENABLE_NTFY ENABLE_ANDROID_PANEL ENABLE_WEBTTY ENABLE_PULSEAUDIO ) for key in "${OPTIONAL_KEYS[@]}"; do stack_env_upsert "$key" "0" done CTL="$ROOT_DIR/scripts/linux/service_ctl.sh" for svc in redroid frigate homeassistant openclaw srs mitmproxy vscode_server homepage filebrowser uptime_kuma ntfy android_panel webtty pulseaudio; do bash "$CTL" "$svc" stop >/dev/null 2>&1 || true done for unit in live-redroid-host.service live-frigate-usb-watch.service live-android-panel.service live-webtty.service live-pulseaudio.service; do systemctl disable --now "$unit" >/dev/null 2>&1 || true done # Belt-and-suspenders: stop leftover optional containers (compose project prefixes vary). OPTIONAL_PATTERNS='live-frigate|live-homeassistant|live-openclaw|live-srs|live-mitmproxy|live-code-server|live-homepage|live-filebrowser|live-uptime-kuma|live-ntfy|redroid' mapfile -t _left < <(docker ps --format '{{.Names}}' 2>/dev/null | grep -E "$OPTIONAL_PATTERNS" || true) if [ "${#_left[@]}" -gt 0 ]; then docker stop "${_left[@]}" >/dev/null 2>&1 || true fi echo "[optional-stop] disabled optional hub modules in $STACK_ENV" docker ps --format '{{.Names}}' 2>/dev/null | grep -E '^live-neko-[0-9]+$' | sort -V || true uptime