From 137c96bbc076a0fcce2ce4b03d63cac478cadebe Mon Sep 17 00:00:00 2001 From: ztimson Date: Sun, 22 Nov 2026 13:02:36 -0500 Subject: [PATCH] More setup script stuff + opentak --- docker/atak.yml | 23 --- docker/bettercap.yml | 16 +- docker/caddy.yml | 52 +++--- docker/cloud.yml | 98 +++++------ docker/librespeed.yml | 42 ++--- docker/maps.yml | 102 ++++++------ docker/sdr.yml | 105 +++--------- install.sh | 371 +++++++++++++++++++++++++++++++++--------- 8 files changed, 472 insertions(+), 337 deletions(-) delete mode 100644 docker/atak.yml diff --git a/docker/atak.yml b/docker/atak.yml deleted file mode 100644 index 684cbaa..0000000 --- a/docker/atak.yml +++ /dev/null @@ -1,23 +0,0 @@ -services: - gotak: - image: kdudkov/goatak_server:latest - platform: linux/amd64 - container_name: viator-gotak - restart: unless-stopped - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/atak:/app - ports: - - "${ATAK_WEB_BIND:-127.0.0.1}:${ATAK_WEB_PORT:-8089}:8080" - - "${ATAK_DATA_BIND:-0.0.0.0}:5222:8999" - - "${ATAK_DATA_BIND:-0.0.0.0}:1100:8088" - networks: - - proxy - labels: - caddy: atak.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 8080}}" - caddy.tls: internal - -networks: - proxy: - external: true - name: viator_proxy diff --git a/docker/bettercap.yml b/docker/bettercap.yml index 1d8dd4d..10b1c43 100644 --- a/docker/bettercap.yml +++ b/docker/bettercap.yml @@ -10,17 +10,11 @@ services: - >- set api.rest.username '${BETTERCAP_USER:-viator}'; set api.rest.password '${BETTERCAP_PASSWORD:?Set BETTERCAP_PASSWORD in viator.env}'; - set api.rest.address '${VIATOR_DOCKER_GATEWAY:-172.17.0.1}'; - set api.rest.port 8081; - set api.rest.alloworigin 'https://bettercap.${VIATOR_DOMAIN:-viator.internal}'; + set api.rest.address '${BETTERCAP_UI_ADDR:-${VIATOR_DOCKER_GATEWAY:-172.17.0.1}}'; + set api.rest.port ${BETTERCAP_API_PORT:-8081}; + set api.rest.alloworigin '${BETTERCAP_ALLOW_ORIGIN:-https://${VIATOR_SUB_BETTERCAP:-bettercap}.${VIATOR_DOMAIN:-viator.internal}}'; api.rest on; - set ui.address '${VIATOR_DOCKER_GATEWAY:-172.17.0.1}'; - set ui.port 1600; + set ui.address '${BETTERCAP_UI_ADDR:-${VIATOR_DOCKER_GATEWAY:-172.17.0.1}}'; + set ui.port ${BETTERCAP_UI_PORT:-1600}; ui on; set gps.device localhost:2947; - labels: - caddy: bettercap.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: host.docker.internal:1600 - - caddy_1: api.bettercap.${VIATOR_DOMAIN:-viator.internal} - caddy_1.reverse_proxy: host.docker.internal:8081 diff --git a/docker/caddy.yml b/docker/caddy.yml index 122ecf7..aeab602 100644 --- a/docker/caddy.yml +++ b/docker/caddy.yml @@ -1,29 +1,31 @@ services: - caddy: - image: lucaslorentz/caddy-docker-proxy:2.9-alpine - container_name: viator-caddy - restart: unless-stopped - extra_hosts: - - "host.docker.internal:host-gateway" - ports: - - "80:80" - - "443:443" - environment: - CADDY_INGRESS_NETWORKS: viator_proxy - volumes: - - /var/run/docker.sock:/var/run/docker.sock:ro - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/caddy/data:/data - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/caddy/config:/config - networks: - - proxy - labels: - caddy: bettercap.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: host.docker.internal:1600 + caddy: + image: lucaslorentz/caddy-docker-proxy:2.9-alpine + container_name: viator-caddy + restart: unless-stopped + extra_hosts: + - "host.docker.internal:host-gateway" + ports: + - "80:80" + - "443:443" + environment: + CADDY_INGRESS_NETWORKS: viator_proxy + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/caddy/data:/data + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/caddy/config:/config + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_BETTERCAP:-bettercap}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: host.docker.internal:${BETTERCAP_UI_PORT:-1600} + caddy.tls: internal - caddy_1: api.bettercap.${VIATOR_DOMAIN:-viator.internal} - caddy_1.reverse_proxy: host.docker.internal:8081 + caddy_1: ${VIATOR_SUB_BETTERCAP_API:-api.bettercap}.${VIATOR_DOMAIN:-viator.internal} + caddy_1.reverse_proxy: host.docker.internal:${BETTERCAP_API_PORT:-8081} + caddy_1.tls: internal networks: - proxy: - external: true - name: viator_proxy + proxy: + external: true + name: viator_proxy diff --git a/docker/cloud.yml b/docker/cloud.yml index 64a3205..c9ef7e1 100644 --- a/docker/cloud.yml +++ b/docker/cloud.yml @@ -1,53 +1,53 @@ services: - harness: - image: git.zakscode.com/ztimson/ai-harness:latest - container_name: viator-ai-harness - restart: unless-stopped - environment: - PUID: ${PUID:-1000} - PGID: ${PGID:-1000} - PUBLIC_URL: home.${VIATOR_DOMAIN:-viator.internal} - OFFICE_URL: office.${VIATOR_DOMAIN:-viator.internal} - OFFICE_SECRET: ${OFFICE_JWT_SECRET:?Office secret is required} - volumes: - - ${VIATOR_FILES_ROOT:-/mnt}:/mnt - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/models:/models - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/AI:/AI - ports: - - "${WEB_BIND:-127.0.0.1}:${HARNESS_PORT:-8082}:80" - networks: - - proxy - labels: - caddy: home.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 80}}" - caddy.tls: internal - caddy.reverse_proxy.lb_policy: client_ip_hash - caddy.reverse_proxy.stream_close_delay: 24h + harness: + image: git.zakscode.com/ztimson/ai-harness:latest + container_name: viator-ai-harness + restart: unless-stopped + environment: + PUID: ${PUID:-1000} + PGID: ${PGID:-1000} + PUBLIC_URL: ${VIATOR_HOST_HARNESS:-${VIATOR_SUB_HARNESS:-home}.${VIATOR_DOMAIN:-viator.internal}} + OFFICE_URL: ${VIATOR_HOST_OFFICE:-${VIATOR_SUB_OFFICE:-office}.${VIATOR_DOMAIN:-viator.internal}} + OFFICE_SECRET: ${OFFICE_JWT_SECRET:?Office secret is required} + volumes: + - ${VIATOR_FILES_ROOT:-/mnt}:/mnt + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/models:/models + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/AI:/AI + ports: + - "${WEB_BIND:-127.0.0.1}:${HARNESS_PORT:-8082}:80" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_HARNESS:-home}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 80}}" + caddy.tls: internal + caddy.reverse_proxy.lb_policy: client_ip_hash + caddy.reverse_proxy.stream_close_delay: 24h - onlyoffice: - image: onlyoffice/documentserver:latest - container_name: viator-onlyoffice - restart: unless-stopped - environment: - JWT_ENABLED: "true" - JWT_SECRET: ${OFFICE_JWT_SECRET:?Office secret is required} - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/data:/var/www/onlyoffice/Data - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/logs:/var/log/onlyoffice - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/lib:/var/lib/onlyoffice - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/db:/var/lib/postgresql - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/rabbitmq:/var/lib/rabbitmq - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/redis:/var/lib/redis - ports: - - "${WEB_BIND:-127.0.0.1}:${OFFICE_PORT:-8083}:80" - networks: - - proxy - labels: - caddy: office.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 80}}" - caddy.tls: internal + onlyoffice: + image: onlyoffice/documentserver:latest + container_name: viator-onlyoffice + restart: unless-stopped + environment: + JWT_ENABLED: "true" + JWT_SECRET: ${OFFICE_JWT_SECRET:?Office secret is required} + volumes: + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/data:/var/www/onlyoffice/Data + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/logs:/var/log/onlyoffice + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/lib:/var/lib/onlyoffice + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/db:/var/lib/postgresql + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/rabbitmq:/var/lib/rabbitmq + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/personal-cloud/office/redis:/var/lib/redis + ports: + - "${WEB_BIND:-127.0.0.1}:${OFFICE_PORT:-8083}:80" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_OFFICE:-office}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 80}}" + caddy.tls: internal networks: - proxy: - external: true - name: viator_proxy + proxy: + external: true + name: viator_proxy diff --git a/docker/librespeed.yml b/docker/librespeed.yml index 8688eff..6c7c778 100644 --- a/docker/librespeed.yml +++ b/docker/librespeed.yml @@ -1,24 +1,24 @@ services: - librespeed: - image: lscr.io/linuxserver/librespeed:latest - container_name: viator-librespeed - restart: unless-stopped - environment: - PUID: ${PUID:-1000} - PGID: ${PGID:-1000} - TZ: ${TZ:-Etc/UTC} - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/librespeed:/config - ports: - - "${LIBRESPEED_BIND:-127.0.0.1}:${LIBRESPEED_PORT:-1900}:80" - networks: - - proxy - labels: - caddy: speedtest.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 80}}" - caddy.tls: internal + librespeed: + image: lscr.io/linuxserver/librespeed:latest + container_name: viator-librespeed + restart: unless-stopped + environment: + PUID: ${PUID:-1000} + PGID: ${PGID:-1000} + TZ: ${TZ:-Etc/UTC} + volumes: + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/librespeed:/config + ports: + - "${LIBRESPEED_BIND:-127.0.0.1}:${LIBRESPEED_PORT:-1900}:80" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_SPEEDTEST:-speedtest}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 80}}" + caddy.tls: internal networks: - proxy: - external: true - name: viator_proxy + proxy: + external: true + name: viator_proxy diff --git a/docker/maps.yml b/docker/maps.yml index 88f841c..a0601d8 100644 --- a/docker/maps.yml +++ b/docker/maps.yml @@ -1,54 +1,58 @@ services: - cartomake: - image: git.zakscode.com/ztimson/cartomake:latest - container_name: viator-cartomake - restart: unless-stopped - environment: - TILESERVER_URL: tiles.${VIATOR_DOMAIN:-viator.internal} - GEOCODE_URL: geocode.${VIATOR_DOMAIN:-viator.internal} - ports: - - "${CARTOMAKE_BIND:-127.0.0.1}:${CARTOMAKE_PORT:-8080}:80" - networks: - - proxy - labels: - caddy: maps.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 80}}" - caddy.tls: internal + cartomake: + image: git.zakscode.com/ztimson/cartomake:latest + container_name: viator-cartomake + restart: unless-stopped + environment: + TILESERVER_URL: ${VIATOR_HOST_TILES:-${VIATOR_SUB_TILES:-tiles}.${VIATOR_DOMAIN:-viator.internal}} + GEOCODE_URL: ${VIATOR_HOST_GEOCODE:-${VIATOR_SUB_GEOCODE:-geocode}.${VIATOR_DOMAIN:-viator.internal}} + ports: + - "${CARTOMAKE_BIND:-127.0.0.1}:${CARTOMAKE_PORT:-8020}:80" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_MAPS:-maps}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 80}}" + caddy.tls: internal - photon: - image: rtuszik/photon-docker:latest - container_name: viator-photon - restart: unless-stopped - profiles: [photon] - environment: - UPDATE_STRATEGY: PARALLEL - UPDATE_INTERVAL: 720h - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/geocoder:/photon/data - networks: - - proxy - labels: - caddy: geocode.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 2322}}" - caddy.tls: internal + photon: + image: rtuszik/photon-docker:latest + container_name: viator-photon + restart: unless-stopped + profiles: [photon] + environment: + UPDATE_STRATEGY: PARALLEL + UPDATE_INTERVAL: 720h + volumes: + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/geocoder:/photon/data + ports: + - "${PHOTON_BIND:-127.0.0.1}:${PHOTON_PORT:-8022}:2322" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_GEOCODE:-geocode}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 2322}}" + caddy.tls: internal - tileserver: - image: maptiler/tileserver-gl:v4.11.0 - container_name: viator-tileserver - restart: unless-stopped - profiles: [tiles] - command: ["--config", "/config/config.json"] - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/tiles:/data - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/tileserver:/config:ro - networks: - - proxy - labels: - caddy: tiles.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 8080}}" - caddy.tls: internal + tileserver: + image: maptiler/tileserver-gl:v4.11.0 + container_name: viator-tileserver + restart: unless-stopped + profiles: [tiles] + command: ["--config", "/config/config.json"] + volumes: + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/tiles:/data + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/maps/tileserver:/config:ro + ports: + - "${TILESERVER_BIND:-127.0.0.1}:${TILESERVER_PORT:-8021}:8080" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_TILES:-tiles}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 8080}}" + caddy.tls: internal networks: - proxy: - external: true - name: viator_proxy + proxy: + external: true + name: viator_proxy diff --git a/docker/sdr.yml b/docker/sdr.yml index 002f27f..928c109 100644 --- a/docker/sdr.yml +++ b/docker/sdr.yml @@ -1,83 +1,28 @@ services: - openwebrx: - image: jketterl/openwebrx:stable - container_name: viator-openwebrx - restart: unless-stopped - profiles: [openwebrx] - devices: - - /dev/bus/usb:/dev/bus/usb - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/openwebrx:/var/lib/openwebrx - tmpfs: - - /tmp/openwebrx - ports: - - "${SDR_BIND:-127.0.0.1}:${OPENWEBRX_PORT:-8073}:8073" - networks: - - proxy - labels: - caddy: sdr.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 8073}}" - caddy.tls: internal - - ultrafeeder: - image: ghcr.io/sdr-enthusiasts/docker-adsb-ultrafeeder:latest - container_name: viator-ultrafeeder - hostname: ultrafeeder - restart: unless-stopped - profiles: [adsb] - device_cgroup_rules: - - "c 189:* rwm" - devices: - - /dev/bus/usb:/dev/bus/usb - environment: - TZ: ${TZ:-Etc/UTC} - LOGLEVEL: error - READSB_DEVICE_TYPE: rtlsdr - READSB_GAIN: autogain - READSB_LAT: ${FEEDER_LAT:-} - READSB_LON: ${FEEDER_LONG:-} - READSB_RX_LOCATION_ACCURACY: "2" - READSB_STATS_RANGE: "true" - TAR1090_DEFAULTCENTERLAT: ${FEEDER_LAT:-0} - TAR1090_DEFAULTCENTERLON: ${FEEDER_LONG:-0} - TAR1090_PAGETITLE: ${FEEDER_NAME:-Viator ADS-B} - TAR1090_MESSAGERATEINTITLE: "true" - TAR1090_PLANECOUNTINTITLE: "true" - TAR1090_ENABLE_AC_DB: "true" - TAR1090_FLIGHTAWARELINKS: "true" - TAR1090_SITESHOW: "true" - GRAPHS1090_DARKMODE: "true" - volumes: - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/adsb/globe_history:/var/globe_history - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/adsb/graphs1090:/var/lib/collectd - - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/adsb/autogain:/run/autogain - - /proc/diskstats:/proc/diskstats:ro - tmpfs: - - /run:exec,size=256M - - /tmp:size=128M - - /var/log:size=32M - ports: - - "${SDR_BIND:-127.0.0.1}:${TAR1090_PORT:-8078}:80" - - "${ADSB_BEAST_BIND:-127.0.0.1}:30005:30005" - networks: - - proxy - labels: - caddy: adsb.${VIATOR_DOMAIN:-viator.internal} - caddy.reverse_proxy: "{{upstreams 80}}" - caddy.tls: internal - - rtl433: - image: hertzg/rtl_433:latest - container_name: viator-rtl433 - restart: unless-stopped - profiles: [rtl433] - devices: - - /dev/bus/usb:/dev/bus/usb - environment: - TZ: ${TZ:-Etc/UTC} - command: ["-M", "time:unix:usec:utc", "-M", "protocol", "-F", "json"] + openwebrx: + image: ${OPENWEBRX_IMAGE:-slechev/openwebrxplus-softmbe:latest} + container_name: viator-openwebrx + restart: unless-stopped + environment: + TZ: ${TZ:-Etc/UTC} + OPENWEBRX_ADMIN_USER: ${OPENWEBRX_ADMIN_USER:-admin} + OPENWEBRX_ADMIN_PASSWORD: ${OPENWEBRX_ADMIN_PASSWORD:?Set OPENWEBRX_ADMIN_PASSWORD in viator.env} + volumes: + - /dev/bus/usb:/dev/bus/usb + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/openwebrx/etc:/etc/openwebrx + - ${VIATOR_DATA_ROOT:?Set VIATOR_DATA_ROOT}/sdr/openwebrx/var:/var/lib/openwebrx + device_cgroup_rules: + - "c 189:* rmw" + ports: + - "${OPENWEBRX_BIND:-127.0.0.1}:${OPENWEBRX_PORT:-8073}:8073" + networks: + - proxy + labels: + caddy: ${VIATOR_SUB_SDR:-sdr}.${VIATOR_DOMAIN:-viator.internal} + caddy.reverse_proxy: "{{upstreams 8073}}" + caddy.tls: internal networks: - proxy: - external: true - name: viator_proxy + proxy: + external: true + name: viator_proxy diff --git a/install.sh b/install.sh index 5aa0de9..c19d72d 100644 --- a/install.sh +++ b/install.sh @@ -14,6 +14,7 @@ TMP_DIR="" LOCK_FILE="/run/lock/viator-install.lock" APT_UPGRADE="no" USE_CADDY="no" +VIATOR_DOMAIN="${VIATOR_DOMAIN:-viator.internal}" ADMIN_USER="${SUDO_USER:-${USER:-root}}" FAILED=() SUCCEEDED=() @@ -82,20 +83,73 @@ ask_password() { } save_env() { - local key value + local key value line sed_line for key in "$@"; do value="${!key-}" value="${value//\\/\\\\}" value="${value//\"/\\\"}" + line="${key}=\"${value}\"" if grep -q "^${key}=" "$ENV_FILE"; then - sed -i "s|^${key}=.*|${key}=\"${value}\"|" "$ENV_FILE" + sed_line="${line//\\/\\\\}" + sed_line="${sed_line//&/\\&}" + sed_line="${sed_line//|/\\|}" + sed -i "s|^${key}=.*|${sed_line}|" "$ENV_FILE" else - printf '%s="%s"\n' "$key" "$value" >> "$ENV_FILE" + printf '%s\n' "$line" >> "$ENV_FILE" fi done chmod 0600 "$ENV_FILE" } +# Plain KEY=value writer for third-party project .env files (no quoting). +env_put() { + local file="$1" key="$2" value="$3" + touch "$file" + if grep -q "^${key}=" "$file"; then + local esc="${value//\\/\\\\}"; esc="${esc//&/\\&}"; esc="${esc//|/\\|}" + sed -i "s|^${key}=.*|${key}=${esc}|" "$file" + else + printf '%s=%s\n' "$key" "$value" >> "$file" + fi +} + +valid_sub() { [[ "$1" =~ ^[a-z0-9]([a-z0-9.-]*[a-z0-9])?$ ]]; } +valid_port() { [[ "$1" =~ ^[0-9]+$ ]] && (( $1 >= 1 && $1 <= 65535 )); } + +# expose KEY "Label" default_subdomain default_port BIND_VAR PORT_VAR [need_host] +# +# Network model (decided once in configure_docker via USE_CADDY): +# Caddy mode -> ask for a subdomain; container ports stay on 127.0.0.1; +# Caddy routes . with internal TLS. +# Own-proxy mode -> ask for a host port; bind 0.0.0.0 so the user's reverse proxy +# can reach it. If need_host=yes, also ask for the public +# hostname (used in links between services). +# Writes VIATOR_SUB_, VIATOR_HOST_, , to viator.env. +expose() { + local key="$1" label="$2" dsub="$3" dport="$4" bindvar="$5" portvar="$6" need_host="${7:-no}" + local subvar="VIATOR_SUB_$key" hostvar="VIATOR_HOST_$key" sub port host + if [[ "$USE_CADDY" == yes ]]; then + sub="$(ask_input "$label" "Subdomain (served as .$VIATOR_DOMAIN):" "${!subvar:-$dsub}")" || return 1 + sub="${sub,,}" + valid_sub "$sub" || { msg "Invalid subdomain: '$sub'"; return 1; } + printf -v "$subvar" '%s' "$sub" + printf -v "$hostvar" '%s' "" + printf -v "$bindvar" '%s' "127.0.0.1" + printf -v "$portvar" '%s' "${!portvar:-$dport}" + else + port="$(ask_input "$label" "Host port (your reverse proxy should forward to this):" "${!portvar:-$dport}")" || return 1 + valid_port "$port" || { msg "Invalid port: '$port'"; return 1; } + printf -v "$bindvar" '%s' "0.0.0.0" + printf -v "$portvar" '%s' "$port" + host="${!hostvar:-}" + if [[ "$need_host" == yes ]]; then + host="$(ask_input "$label" "Public hostname your reverse proxy serves this on (no scheme, e.g. maps.example.com):" "$host")" || return 1 + fi + printf -v "$hostvar" '%s' "$host" + fi + save_env "$subvar" "$hostvar" "$bindvar" "$portvar" +} + apt_install() { local packages=("$@") ((${#packages[@]})) || return 0 @@ -174,17 +228,19 @@ choose_components() { "wireguard" "WireGuard VPN" "fallback-ap" "Fallback wireless access point" "vnc" "VNC remote desktop" - "ai" "Local AI (LiteRT + Gemma)" + "ai" "Local AI (LiteRT)" "hat" "Wireless HAT (GPS, LoRa, RTC, SDR)" - "docker" "Docker Engine and Caddy options" + "docker" "Docker Engine and networking (Caddy / own proxy)" "pentest" "Pen Test Suite (host tools + Bettercap)" "speedtest" "LibreSpeed" - "atak" "GoATAK Server" + "opentak" "OpenTAK Server (ATAK)" "maps" "Maps (Cartomake, Photon, TileServer GL)" - "personal-cloud" "Personal Cloud (AI Harness + OnlyOffice)" + "personal-cloud" "Personal Cloud (AI, file editing, note taking, zim reader)" "sdr" "SDR services (OpenWebRX+, ADS-B, RTL_433)" - "zims" "ZIM Archives" + "zims" "Download ZIM Archives" ) + # Migrate selections from the retired GoATAK component. + sed -i 's/^atak$/opentak/' "$STATE_FILE" for ((i=0; i<${#labels[@]}; i+=2)); do item="${labels[i]}" if grep -qx "$item" "$STATE_FILE"; then choices+=("$item" "${labels[i+1]}" ON) @@ -201,6 +257,11 @@ choose_components() { contains() { local needle="$1" x; for x in "${SELECTED[@]}"; do [[ "$x" == "$needle" ]] && return 0; done; return 1; } +needs_docker() { + contains docker || contains pentest || contains speedtest || contains opentak \ + || contains maps || contains personal-cloud || contains sdr +} + configure_global() { local root user upgrade root="$(ask_input "Storage" "Docker/application data root:" "$DATA_ROOT")" || exit 0 @@ -223,24 +284,65 @@ install_tools() { apt_install btop jq tmux; } install_theme() { local motd="/etc/motd" marker_start="# >>> VIATOR BANNER >>>" marker_end="# <<< VIATOR BANNER <<<" local tmp="$TMP_DIR/motd" - touch "$motd" - awk -v s="$marker_start" -v e="$marker_end" 'BEGIN{skip=0} $0==s{skip=1;next} $0==e{skip=0;next} !skip{print}' "$motd" > "$tmp" - cat >> "$tmp" <<'BANNER' -# >>> VIATOR BANNER >>> - __ ___ _ _____ ___ ____ - \ \ / / | | ||_ _/ _ \| _ \ - \ \ / /| | | | | || | | | |_) | - \ V / | |__| | | || |_| | _ < - \_/ \____/ |_| \___/|_| \_\ - OFF-GRID SYSTEMS -# <<< VIATOR BANNER <<< -BANNER - cp -a "$motd" "$motd.viator-backup.$(date +%s)" - install -m 0644 "$tmp" "$motd" + # Clean old static banner from /etc/motd if present + if [ -f "$motd" ]; then + awk -v s="$marker_start" -v e="$marker_end" 'BEGIN{skip=0} $0==s{skip=1;next} $0==e{skip=0;next} !skip{print}' "$motd" > "$tmp" + cp -a "$motd" "$motd.viator-backup.$(date +%s)" + install -m 0644 "$tmp" "$motd" + fi + cat > /etc/profile.d/viator.sh <<'PROMPT' -# Viator system-wide interactive Bash prompt. +# Viator / OpsBox system-wide interactive Bash banner & prompt. case $- in *i*) ;; *) return ;; esac + +_opsbox_iface() { + local iface="$1" + if [ -d "/sys/class/net/$iface" ]; then + local state ip + state=$(tr '[:lower:]' '[:upper:]' < "/sys/class/net/$iface/operstate" 2>/dev/null) + ip=$(ip -4 -o addr show "$iface" 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -n1) + if [ "$state" = "UP" ]; then + echo "UP${ip:+ ($ip)}" + else + echo "${state:-DOWN}" + fi + else + echo "N/A" + fi +} + +_opsbox_banner() { + local host_node curr_user primary_ip eth0_stat wifi0_stat wifi1_stat last_log + host_node=$(hostname -s 2>/dev/null || echo "LOCALHOST") + curr_user=$(whoami) + primary_ip=$(hostname -I 2>/dev/null | awk '{print $1}') + primary_ip=${primary_ip:-"127.0.0.1"} + + eth0_stat=$(_opsbox_iface "eth0") + wifi0_stat=$(_opsbox_iface "wifi0") + wifi1_stat=$(_opsbox_iface "wifi1") + + [ "$wifi0_stat" = "N/A" ] && [ -d "/sys/class/net/wlan0" ] && wifi0_stat=$(_opsbox_iface "wlan0") + [ "$wifi1_stat" = "N/A" ] && [ -d "/sys/class/net/wlan1" ] && wifi1_stat=$(_opsbox_iface "wlan1") + + last_log=$(last -n 2 -w "$curr_user" 2>/dev/null | awk 'NR==2 {print $4" "$5" "$6" "$7" ("$3")"}') + last_log=${last_log:-"FIRST_SESSION // TTY"} + + printf ".-[ 0PSB0X ]--------------------------------------------------.\n" + printf "|:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|\n" + printf "| >> SYSTEM : %-16s // [STATUS: 0NL1N3] |\n" "$host_node" + printf "| >> ACCESS : %-16s // IP: %-21s |\n" "${curr_user^^}" "$primary_ip" + printf "| >> ETH0 : %-44s |\n" "$eth0_stat" + printf "| >> WIFI0 : %-44s |\n" "$wifi0_stat" + printf "| >> WIFI1 : %-44s |\n" "$wifi1_stat" + printf "| >> LAST : %-44s |\n" "$last_log" + printf "\`-------------------------------------------------[░▒▓█]------'\n" +} + +_opsbox_banner +unset -f _opsbox_banner _opsbox_iface + LINES="\[\e[36m\]" [ "$EUID" -eq 0 ] && LINES="\[\e[91m\]" USERHOST="\[\e[33m\]" @@ -248,6 +350,7 @@ DIRECTORY="\[\e[97m\]" ENDCOLOR="\[\e[m\]" PS1="${LINES}╭──(${USERHOST}\u${LINES}@${USERHOST}\h${LINES})-[${DIRECTORY}\w${LINES}]${ENDCOLOR}\n${LINES}╰─${ENDCOLOR}\$ " PROMPT + chmod 0644 /etc/profile.d/viator.sh } install_wireguard() { @@ -378,7 +481,7 @@ install_caddy() { mkdir -p "$DATA_ROOT/caddy/data" "$DATA_ROOT/caddy/config" docker network inspect viator_proxy >/dev/null 2>&1 || docker network create viator_proxy >/dev/null local compose="$VIATOR_DIR/docker/caddy.yml" - VIATOR_DATA_ROOT="$DATA_ROOT" docker compose -f "$compose" up -d + VIATOR_DATA_ROOT="$DATA_ROOT" docker compose --env-file "$ENV_FILE" -f "$compose" up -d } export_caddy_ca() { @@ -393,16 +496,51 @@ export_caddy_ca() { else warn "Caddy's local root CA is not available yet; export it after the first HTTPS route is active."; fi } +# Bettercap runs with host networking, so it needs its own listen-address/port +# settings. Caddy's routes for it live in docker/caddy.yml, which is why this is +# asked before Caddy is (re)started. +configure_bettercap_net() { + local sub api addr ui api_port origin + BETTERCAP_UI_PORT="${BETTERCAP_UI_PORT:-1600}" + BETTERCAP_API_PORT="${BETTERCAP_API_PORT:-8081}" + if [[ "$USE_CADDY" == yes ]]; then + sub="$(ask_input "Bettercap UI" "Subdomain (served as .$VIATOR_DOMAIN):" "${VIATOR_SUB_BETTERCAP:-bettercap}")" || return 1 + api="$(ask_input "Bettercap API" "API subdomain (served as .$VIATOR_DOMAIN):" "${VIATOR_SUB_BETTERCAP_API:-api.bettercap}")" || return 1 + sub="${sub,,}"; api="${api,,}" + valid_sub "$sub" && valid_sub "$api" || { msg "Invalid subdomain."; return 1; } + VIATOR_SUB_BETTERCAP="$sub"; VIATOR_SUB_BETTERCAP_API="$api" + BETTERCAP_UI_ADDR="" # empty -> Docker gateway (only reachable through Caddy) + BETTERCAP_ALLOW_ORIGIN="" # empty -> https://. + else + addr="$(ask_input "Bettercap" "Address for the UI/API to listen on (0.0.0.0 = all interfaces):" "${BETTERCAP_UI_ADDR:-0.0.0.0}")" || return 1 + ui="$(ask_input "Bettercap" "UI port:" "$BETTERCAP_UI_PORT")" || return 1 + api_port="$(ask_input "Bettercap" "API port:" "$BETTERCAP_API_PORT")" || return 1 + valid_port "$ui" && valid_port "$api_port" || { msg "Invalid port."; return 1; } + origin="$(ask_input "Bettercap" "Public URL of the UI (CORS origin for the API, e.g. https://bettercap.example.com):" "${BETTERCAP_ALLOW_ORIGIN:-http://$(hostname):$ui}")" || return 1 + BETTERCAP_UI_ADDR="$addr"; BETTERCAP_UI_PORT="$ui"; BETTERCAP_API_PORT="$api_port" + BETTERCAP_ALLOW_ORIGIN="$origin" + fi + save_env VIATOR_SUB_BETTERCAP VIATOR_SUB_BETTERCAP_API BETTERCAP_UI_ADDR BETTERCAP_UI_PORT BETTERCAP_API_PORT BETTERCAP_ALLOW_ORIGIN +} + configure_docker() { - local engine caddy - engine="$(whiptail --title "Docker" --yesno "Install or configure Docker Engine? (Required for container packages)" 10 76 3>&1 1>&2 2>&3 && echo yes || echo no)" - caddy="$(whiptail --title "Docker" --yesno "Install Caddy Docker Proxy for local HTTPS hostnames (.home.arpa)?" 10 76 3>&1 1>&2 2>&3 && echo yes || echo no)" - if [[ "$engine" == yes || "$caddy" == yes ]] || contains speedtest || contains atak || contains maps || contains personal-cloud || contains sdr || contains pentest; then + local engine=no caddy=no domain + if ask_yes "Install or configure Docker Engine? (Required for container packages)"; then engine=yes; fi + if ask_yes "Networking mode\n\nYES = Install Caddy: services get . names with internal HTTPS certificates (no existing reverse proxy).\n\nNO = I already have a reverse proxy: services are published on host ports for it to forward to."; then caddy=yes; fi + USE_CADDY="$caddy" + if [[ "$USE_CADDY" == yes ]]; then + domain="$(ask_input "Domain" "Base domain for local HTTPS hostnames (services become .):" "$VIATOR_DOMAIN")" || return 1 + domain="${domain,,}" + valid_sub "$domain" || { msg "Invalid domain: '$domain'"; return 1; } + VIATOR_DOMAIN="$domain" + save_env VIATOR_DOMAIN + fi + save_env USE_CADDY + if contains pentest; then configure_bettercap_net || return 1; fi + if [[ "$engine" == yes || "$caddy" == yes ]] || needs_docker; then install_docker_engine || return 1 fi - USE_CADDY="$caddy" if [[ "$USE_CADDY" == yes ]]; then install_caddy || return 1; fi - save_env USE_CADDY } compose_stack() { @@ -417,41 +555,87 @@ compose_stack() { } install_speedtest() { - local bind=127.0.0.1 port="${LIBRESPEED_PORT:-1900}" - if [[ "$USE_CADDY" != yes ]]; then - bind=0.0.0.0 - port="$(ask_input "LibreSpeed" "Host port for the speed test UI:" "$port")" || return 1 - fi - LIBRESPEED_BIND="$bind" LIBRESPEED_PORT="$port" - save_env LIBRESPEED_BIND LIBRESPEED_PORT + expose SPEEDTEST "LibreSpeed" speedtest 1900 LIBRESPEED_BIND LIBRESPEED_PORT no || return 1 compose_stack librespeed docker/librespeed.yml "$ENV_FILE" } -install_atak() { - local bind=127.0.0.1 port="${ATAK_WEB_PORT:-8089}" - if [[ "$USE_CADDY" != yes ]]; then - bind=0.0.0.0 - port="$(ask_input "GoATAK" "Host port for the web UI:" "$port")" || return 1 + +install_opentak() { + apt_install curl openssl + local dir="$DATA_ROOT/opentak" svc k + expose OPENTAK "OpenTAK Server (web UI)" tak 8090 OTS_WEB_BIND OTS_WEB_PORT no || return 1 + mkdir -p "$dir" + + # Retire the old GoATAK stack if present (its data in $DATA_ROOT/atak is left untouched). + if [[ -f "$VIATOR_DIR/docker/atak.yml" ]]; then + VIATOR_DATA_ROOT="$DATA_ROOT" docker compose --env-file "$ENV_FILE" -f "$VIATOR_DIR/docker/atak.yml" down --remove-orphans 2>/dev/null || true fi - ATAK_WEB_BIND="$bind" ATAK_WEB_PORT="$port" - save_env ATAK_WEB_BIND ATAK_WEB_PORT - compose_stack atak docker/atak.yml "$ENV_FILE" + + # Upstream installer: fetch compose + generate .env under ./data/opentak; don't start yet. + fetch "https://raw.githubusercontent.com/9M2PJU/9M2PJU-OpenTAKServer-Docker/main/scripts/install.sh" "$TMP_DIR/ots-install.sh" || return 1 + bash "$TMP_DIR/ots-install.sh" --prefix "$dir" --no-start || return 1 + + svc="$(cd "$dir" && docker compose config --services | grep -iE 'ots|opentak' | grep -viE 'postgres|rabbit|db|mq' | head -n1 || true)" + [[ -n "$svc" ]] || { err "Could not detect the OpenTAKServer service in $dir/docker-compose.yml"; return 1; } + log "Detected OpenTAKServer service: $svc" + + # Mirror the settings the override needs into the project's own .env so a manual + # `docker compose up` in $dir behaves the same as the installer. + env_put "$dir/.env" OTS_WEB_BIND "$OTS_WEB_BIND" + env_put "$dir/.env" OTS_WEB_PORT "$OTS_WEB_PORT" + env_put "$dir/.env" VIATOR_DOMAIN "$VIATOR_DOMAIN" + env_put "$dir/.env" VIATOR_SUB_OPENTAK "${VIATOR_SUB_OPENTAK:-tak}" + + # Auto-merged by compose; upstream's docker-compose.yml stays untouched/upgradable. + # 8089 (SSL CoT) and 8446 (cert enrollment) are raw TLS, so they're always published + # directly (Caddy cannot proxy them). Only the web UI goes through Caddy / your proxy. + cat > "$dir/docker-compose.override.yml" < /etc/modprobe.d/viator-rtlsdr.conf <<'BLACKLIST' +# Managed by Viator: keep the kernel DVB driver off RTL-SDR dongles so SDR apps can claim them. +blacklist dvb_usb_rtl28xxu +blacklist rtl2832 +blacklist rtl2832_sdr +blacklist rtl2830 +blacklist r820t +BLACKLIST + local m usb + for m in rtl2832_sdr dvb_usb_rtl28xxu rtl2832 rtl2830 r820t; do modprobe -r "$m" 2>/dev/null || true; done + usb="$(lsusb 2>/dev/null || true)" + if grep -qiE '0bda:(2832|2838)' <<<"$usb"; then + log "RTL-SDR detected on USB." + else + warn "No RTL-SDR (0bda:2832/2838) found on USB. OpenWebRX+ will start but has no device until the HAT's SDR is visible (check 'lsusb'; a reboot may be needed after the module blacklist)." + fi +} + +install_openwebrx() { + prepare_rtlsdr_host + expose SDR "OpenWebRX+ (SDR receiver)" sdr 8073 OPENWEBRX_BIND OPENWEBRX_PORT no || return 1 + OPENWEBRX_ADMIN_USER="$(ask_input "OpenWebRX+" "Admin username:" "${OPENWEBRX_ADMIN_USER:-admin}")" || return 1 + [[ "$OPENWEBRX_ADMIN_USER" =~ ^[a-z][a-z0-9_-]*$ ]] || { msg "Username must be lowercase letters, numbers, dash or underscore."; return 1; } + OPENWEBRX_ADMIN_PASSWORD="$(ask_password "OpenWebRX+" "Admin password (12+ chars: letters/numbers/dot/dash/underscore):" "${OPENWEBRX_ADMIN_PASSWORD:-}")" || return 1 + [[ "$OPENWEBRX_ADMIN_PASSWORD" =~ ^[A-Za-z0-9._-]{12,}$ ]] || { msg "Use 12+ characters: letters, numbers, dot, dash or underscore."; return 1; } + OPENWEBRX_IMAGE="${OPENWEBRX_IMAGE:-slechev/openwebrxplus-softmbe:latest}" + save_env OPENWEBRX_ADMIN_USER OPENWEBRX_ADMIN_PASSWORD OPENWEBRX_IMAGE + mkdir -p "$DATA_ROOT/sdr/openwebrx/etc" "$DATA_ROOT/sdr/openwebrx/var" + # The image's runtime uid isn't documented; keep state dirs writable until it's confirmed. + chmod 0777 "$DATA_ROOT/sdr/openwebrx/etc" "$DATA_ROOT/sdr/openwebrx/var" + compose_stack sdr/openwebrx docker/sdr.yml "$ENV_FILE" +} + install_sdr() { - local owx= noads=no rtl=no - ask_yes "Install OpenWebRX+ (general SDR receiver)?" && owx=yes || true + local owx=no noads=no rtl=no + ask_yes "Install OpenWebRX+ (general SDR receiver with extra digital decoders)?" && owx=yes || true ask_yes "Install ADS-B receiver and tar1090?" && noads=yes || true ask_yes "Install RTL_433 sensor decoder?" && rtl=yes || true if [[ "$owx" == yes && "$noads" == yes ]] || [[ "$owx" == yes && "$rtl" == yes ]] || [[ "$noads" == yes && "$rtl" == yes ]]; then @@ -554,11 +763,15 @@ install_sdr() { fi SDR_OPENWEBRX="$owx" SDR_ADSB="$noads" SDR_RTL433="$rtl" save_env SDR_OPENWEBRX SDR_ADSB SDR_RTL433 - local -a profiles=() - [[ "$owx" == yes ]] && profiles+=(--profile openwebrx) - [[ "$noads" == yes ]] && profiles+=(--profile adsb) - [[ "$rtl" == yes ]] && profiles+=(--profile rtl433) - compose_stack sdr docker/sdr.yml "$ENV_FILE" "${profiles[@]}" + local rc=0 + if [[ "$owx" == yes ]]; then install_openwebrx || rc=1; fi + if [[ "$noads" == yes || "$rtl" == yes ]]; then + local -a profiles=() + [[ "$noads" == yes ]] && profiles+=(--profile adsb) + [[ "$rtl" == yes ]] && profiles+=(--profile rtl433) + compose_stack sdr docker/sdr.yml "$ENV_FILE" "${profiles[@]}" || rc=1 + fi + return "$rc" } install_ai() { @@ -777,8 +990,8 @@ main() { summary ask_yes "Begin installation? Existing data will be preserved; individual failures won't stop other components." || exit 0 - # Docker is a shared prerequisite; configure once for all selected container apps. - if contains docker || contains pentest || contains speedtest || contains atak || contains maps || contains personal-cloud || contains sdr; then + # Docker + networking mode (Caddy vs. own reverse proxy) is decided once for all container apps. + if needs_docker; then run_component "Docker" configure_docker fi @@ -791,7 +1004,7 @@ main() { contains hat && run_component "Wireless HAT" install_hat || true contains pentest && run_component "Pen Test Suite" install_pentest || true contains speedtest && run_component "LibreSpeed" install_speedtest || true - contains atak && run_component "GoATAK Server" install_atak || true + contains opentak && run_component "OpenTAK Server" install_opentak || true contains maps && run_component "Maps" install_maps || true contains personal-cloud && run_component "Personal Cloud" install_personal_cloud || true contains sdr && run_component "SDR" install_sdr || true