Merge pull request #40 from outis1one/claude/dazzling-mendel-J4fi4

chore: add versioned snapshot setup_v0.9.5.sh, reset VERSION to 0.9.5
This commit is contained in:
Outis
2026-06-03 20:38:06 -04:00
committed by GitHub
30 changed files with 4803 additions and 1278 deletions
+12 -2
View File
@@ -1,8 +1,18 @@
# Changelog
All notable changes to this project. Versions follow `MAJOR.MINOR.PATCH`.
The project is pre-1.0 while the modular system reaches parity with the
monolithic `ubuntu-post-install-*.sh` scripts.
## [0.9.5] - 2026-06-03
### Changed
- VERSION reset from 1.0.0 to 0.9.5 — versioning now tracks `setup_v<X.Y.Z>.sh`
snapshot files. Each release creates a new numbered file (old files stay). The
current `setup.sh` is always the live version; `setup_v0.9.5.sh` is the first
named snapshot.
### Added
- `setup_v0.9.5.sh` — first versioned snapshot of `setup.sh`. Future changes
produce `setup_v0.9.6.sh`, etc. Previous snapshots are never removed.
## [1.0.0] - 2026-06-03
+2 -2
View File
@@ -95,7 +95,7 @@ is retained as a frozen evolution record.
| `homelab` | `caddy`, `crowdsec`, `authelia`, `homeassistant` |
| `utilities` | `actualbudget`, `ddclient`, `filebrowser`, `fmd`, `magicmirror`, `mealie`, `meshcentral`, `ntfy`, `portainer`, `traccar`, `uptimekuma`, `watchtower`, `wg-easy` |
| `media` | `arm`, `audiobookshelf`, `emby`, `immich`, `jellyfin`, `lyrion` |
| `cameras` | `frigate`, `frigate-notify` |
| `cameras` | `frigate`, `frigate-audio`, `frigate-notify`, `sky-cam` |
| `gaming` | `js99er`, `minecraft`, `wolf`, `wolf-pair` |
| `extras` | `linux-to-sync`, `silent-send` |
| `extras` | `linux-to-sync`, `silent-send`, `sync-cc` |
| `backup` | `backup` |
+70 -1171
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1 +1 @@
1.0.0
0.9.5
Executable
+47
View File
@@ -0,0 +1,47 @@
#!/bin/bash
# bootstrap.sh — get and run ubuntu-post-install on a fresh system.
#
# One command to paste into a new Ubuntu box:
# curl -fsSL https://raw.githubusercontent.com/outis1one/ubuntu-post-install/main/bootstrap.sh | sudo bash
#
# What it does:
# 1. Installs git if missing (the only hard dependency)
# 2. Clones (or updates) the repo to ~/ubuntu-post-install
# 3. Launches the interactive setup wizard
set -euo pipefail
REPO_URL="https://github.com/outis1one/ubuntu-post-install.git"
DEST="${HOME:-/root}/ubuntu-post-install"
# Resolve actual user home when running under sudo
if [ -n "${SUDO_USER:-}" ]; then
ACTUAL_HOME="$(getent passwd "$SUDO_USER" | cut -d: -f6)"
DEST="$ACTUAL_HOME/ubuntu-post-install"
fi
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ ubuntu-post-install · bootstrap ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
# 1) Ensure git is available
if ! command -v git >/dev/null 2>&1; then
echo "Installing git..."
apt-get update -qq && apt-get install -y git
fi
# 2) Clone or update
if [ -d "$DEST/.git" ]; then
echo "Repo already exists at $DEST — pulling latest..."
git -C "$DEST" pull --ff-only || echo " (pull failed — continuing with existing version)"
else
echo "Cloning to $DEST ..."
git clone "$REPO_URL" "$DEST"
fi
echo ""
echo "Launching setup..."
echo ""
exec bash "$DEST/setup.sh"
+3195
View File
File diff suppressed because it is too large Load Diff
+97
View File
@@ -47,6 +47,103 @@ register_service() {
SERVICE_ORDER+=("$name")
}
# ── Site-wide defaults ────────────────────────────────────────────────────────
# Stored in $DOCKER_DIR/.config (key=value, one per line).
# Service modules read these as prompt defaults so the user only types
# timezone, domain, and Caddy network once. Run: sudo ./setup.sh configure
SITE_TZ=""
SITE_DOMAIN=""
SITE_CADDY_NET="caddy_net"
SITE_PUID=""
SITE_PGID=""
load_site_config() {
local cfg="$DOCKER_DIR/.config"
[ -f "$cfg" ] || return 0
local key val
while IFS='=' read -r key val; do
[[ "$key" =~ ^[[:space:]]*# ]] && continue
[[ -z "${key// }" ]] && continue
case "$key" in
SITE_TZ) SITE_TZ="$val" ;;
SITE_DOMAIN) SITE_DOMAIN="$val" ;;
SITE_CADDY_NET) SITE_CADDY_NET="$val" ;;
SITE_PUID) SITE_PUID="$val" ;;
SITE_PGID) SITE_PGID="$val" ;;
BASE_DOMAIN) [ -z "$SITE_DOMAIN" ] && SITE_DOMAIN="$val" ;;
esac
done < "$cfg"
export SITE_TZ SITE_DOMAIN SITE_CADDY_NET SITE_PUID SITE_PGID
}
save_site_config() {
local cfg="$DOCKER_DIR/.config"
mkdir -p "$(dirname "$cfg")"
{
echo "# ubuntu-post-install site defaults"
echo "# Re-run wizard: sudo ./setup.sh configure"
[ -n "$SITE_TZ" ] && echo "SITE_TZ=$SITE_TZ"
[ -n "$SITE_DOMAIN" ] && echo "SITE_DOMAIN=$SITE_DOMAIN"
[ -n "$SITE_CADDY_NET" ] && echo "SITE_CADDY_NET=$SITE_CADDY_NET"
[ -n "$SITE_PUID" ] && echo "SITE_PUID=$SITE_PUID"
[ -n "$SITE_PGID" ] && echo "SITE_PGID=$SITE_PGID"
# Backward-compat alias for services that still read BASE_DOMAIN directly
[ -n "$SITE_DOMAIN" ] && echo "BASE_DOMAIN=$SITE_DOMAIN"
} > "$cfg"
chmod 600 "$cfg"
}
# Load immediately so all service modules inherit the values when sourced
load_site_config
# ── OS detection ─────────────────────────────────────────────────────────────
OS_DISTRO="unknown"
OS_VERSION="unknown"
OS_CODENAME="unknown"
detect_os() {
[ -f /etc/os-release ] || return 0
local key val
while IFS='=' read -r key val; do
val="${val//\"/}"
case "$key" in
ID) OS_DISTRO="$val" ;;
VERSION_ID) OS_VERSION="$val" ;;
VERSION_CODENAME|UBUNTU_CODENAME)
[ "$OS_CODENAME" = "unknown" ] && OS_CODENAME="$val" ;;
esac
done < /etc/os-release
export OS_DISTRO OS_VERSION OS_CODENAME
}
# Return 0 (true) if the detected Ubuntu version is >= the argument (e.g., "24.04").
ubuntu_version_ge() {
[ "$OS_DISTRO" = "ubuntu" ] || return 1
local a="${OS_VERSION//./}" b="${1//./}"
[ "${a:-0}" -ge "${b:-0}" ] 2>/dev/null
}
# pip install --user as actual user.
# --break-system-packages overrides PEP 668 ("externally managed environment"),
# required on Ubuntu 24.04+ — the flag name sounds alarming but with --user the
# install goes to ~/.local/ which apt never touches; nothing system-level is at risk.
# The flag was added in pip 22.3; probe once so older pip (Ubuntu 22.04) still works.
_PIP_HAS_BSP=""
_pip_probe() {
[ -n "$_PIP_HAS_BSP" ] && return
pip3 install --help 2>/dev/null | grep -q -- '--break-system-packages' \
&& _PIP_HAS_BSP=1 || _PIP_HAS_BSP=0
}
pip_user_install() {
_pip_probe
local flags="--user --quiet"
[ "$_PIP_HAS_BSP" = "1" ] && flags="$flags --break-system-packages"
sudo -u "$ACTUAL_USER" pip3 install $flags "$@"
}
detect_os
# ── Pre-flight ───────────────────────────────────────────────────────────────
require_root() {
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
+1 -1
View File
@@ -24,7 +24,7 @@ install_actualbudget() {
ensure_docker_dir_ownership "$AB_DIR"
cd "$AB_DIR" || return 1
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
cat > docker-compose.yml << 'AB_COMPOSE'
name: actualbudget
+1 -1
View File
@@ -45,7 +45,7 @@ install_arm() {
cd "$ARM_DIR" || return 1
local TZ_VAL UID_VAL GID_VAL
TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
UID_VAL=$(id -u "$ACTUAL_USER"); GID_VAL=$(id -g "$ACTUAL_USER")
cat > docker-compose.yml << ARM_COMPOSE
+1 -1
View File
@@ -30,7 +30,7 @@ install_audiobookshelf() {
ensure_docker_dir_ownership "$ABS_DIR"
cd "$ABS_DIR" || return 1
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
cat > docker-compose.yml << ABS_COMPOSE
name: audiobookshelf
+10 -8
View File
@@ -36,9 +36,10 @@ install_authelia() {
echo ""
echo " Authelia needs a few details to configure."
echo ""
local CADDY_NET="${SITE_CADDY_NET:-caddy_net}"
local AUTHELIA_DOMAIN AUTHELIA_ADMIN_USER AUTHELIA_ADMIN_DISPLAY AUTHELIA_ADMIN_EMAIL
local AUTHELIA_SMTP_HOST AUTHELIA_SMTP_PORT AUTHELIA_SMTP_USER AUTHELIA_SMTP_PASS AUTHELIA_TZ
prompt_text " Your domain (e.g., example.com):" "example.com" AUTHELIA_DOMAIN
prompt_text " Your domain (e.g., example.com):" "${SITE_DOMAIN:-example.com}" AUTHELIA_DOMAIN
prompt_text " Admin username:" "admin" AUTHELIA_ADMIN_USER
prompt_text " Admin display name:" "Administrator" AUTHELIA_ADMIN_DISPLAY
prompt_text " Admin email:" "admin@${AUTHELIA_DOMAIN}" AUTHELIA_ADMIN_EMAIL
@@ -46,7 +47,7 @@ install_authelia() {
prompt_text " SMTP port:" "587" AUTHELIA_SMTP_PORT
prompt_text " SMTP username (full email):" "authelia@${AUTHELIA_DOMAIN}" AUTHELIA_SMTP_USER
prompt_text " SMTP password:" "" AUTHELIA_SMTP_PASS
prompt_text " Timezone (e.g., America/New_York):" "America/New_York" AUTHELIA_TZ
prompt_text " Timezone (e.g., America/New_York):" "${SITE_TZ:-America/New_York}" AUTHELIA_TZ
# ── Secrets ──────────────────────────────────────────────────────────────
echo ""
@@ -81,7 +82,7 @@ install_authelia() {
cat > .env << AUTHELIA_ENV
MY_DOMAIN=${AUTHELIA_DOMAIN}
SMTP_USER=${AUTHELIA_SMTP_USER}
DOCKER_MY_NETWORK=caddy_net
DOCKER_MY_NETWORK=${CADDY_NET}
TZ=${AUTHELIA_TZ}
AUTHELIA_ENV
@@ -115,6 +116,7 @@ networks:
caddy_net:
external: true
AUTHELIA_COMPOSE
[ "$CADDY_NET" != "caddy_net" ] && sed -i "s/caddy_net/${CADDY_NET}/g" docker-compose.yml
# ── configuration.yml ────────────────────────────────────────────────────
cat > config/configuration.yml << AUTHELIA_CONFIG
@@ -199,12 +201,12 @@ AUTHELIA_USERS
chown -R 1000:1000 "$AUTHELIA_DIR/config" "$AUTHELIA_DIR/data"
log_success "Authelia configured at $AUTHELIA_DIR"
# ── caddy_net network ────────────────────────────────────────────────────
if ! docker network ls --format '{{.Name}}' | grep -q "^caddy_net$"; then
docker network create caddy_net >/dev/null 2>&1 && echo " ✓ Created docker network caddy_net" \
|| echo " ⚠ Failed to create caddy_net"
# ── Docker network ────────────────────────────────────────────────────────
if ! docker network ls --format '{{.Name}}' | grep -q "^${CADDY_NET}$"; then
docker network create "$CADDY_NET" >/dev/null 2>&1 && echo " ✓ Created docker network ${CADDY_NET}" \
|| echo " ⚠ Failed to create ${CADDY_NET}"
else
echo " ✓ Docker network caddy_net already exists"
echo " ✓ Docker network ${CADDY_NET} already exists"
fi
# ── Caddyfile forward-auth snippet + portal block ────────────────────────
+1 -1
View File
@@ -25,7 +25,7 @@ install_ddclient() {
ensure_docker_dir_ownership "$DDCLIENT_DIR"
cd "$DDCLIENT_DIR" || return 1
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
cat > docker-compose.yml << 'DDCLIENT_COMPOSE'
name: ddclient
+1 -1
View File
@@ -34,7 +34,7 @@ install_emby() {
cd "$EMBY_DIR" || return 1
local TZ_VAL UID_VAL GID_VAL
TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
UID_VAL=$(id -u "$ACTUAL_USER"); GID_VAL=$(id -g "$ACTUAL_USER")
cat > docker-compose.yml << EMBY_COMPOSE
+1 -1
View File
@@ -33,7 +33,7 @@ services:
environment:
- PUID=$(id -u "$ACTUAL_USER")
- PGID=$(id -g "$ACTUAL_USER")
- TZ=$(cat /etc/timezone 2>/dev/null || echo "UTC")
- TZ=${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}
volumes:
- ${FB_PATH}:/srv
- ./database/filebrowser.db:/database/filebrowser.db
+556
View File
@@ -0,0 +1,556 @@
#!/bin/bash
# services/frigate-audio.sh — Frigate NVR + Mosquitto MQTT + frigate-notify
# full-stack with audio support and push notifications via ntfy.
# Part of the modular post-install system (sourced by setup.sh).
#
# Based on outis1one/frigate_w_audio. This is the full stack:
# Frigate 0.17 NVR, face recognition, LPR, motion detection
# Mosquitto MQTT broker (events bus between Frigate and notify)
# frigate-notify Event consumer — sends ntfy push notifications
#
# Audio is OFF by default in the Frigate config (audio.enabled: false).
# To enable it you need at least one camera with a working microphone —
# see the HOW TO ADD A CAMERA WITH A MIC section in the generated config.yml.
#
# Hardware acceleration and Coral TPU are opt-in during setup; the
# default falls back to CPU detection so the stack runs everywhere.
#
# Differs from services/frigate.sh (simpler, standalone Frigate only):
# • includes Mosquitto + frigate-notify
# • audio-ready camera config template
# • Frigate 0.17 schema with face recognition + LPR pre-configured
register_service frigate-audio cameras "Frigate NVR + MQTT + push notifications (audio-ready stack)" 8971
install_frigate-audio() {
require_docker || return 1
local DIR="$DOCKER_DIR/frigate-audio"
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] frigate-audio would:"
echo " Create $DIR with Frigate + Mosquitto + frigate-notify stack"
echo " Prompt for camera RTSP credentials, IPs, MQTT password, ntfy server"
echo " Generate docker-compose.yml, frigate config, mosquitto config, .env"
echo " Bootstrap the Mosquitto password file"
return 0
fi
echo ""
echo "╔═══════════════════════════════════════════════════════════════╗"
echo "║ Frigate + Mosquitto + frigate-notify (audio-ready stack) ║"
echo "║ Face recognition · LPR · ntfy push alerts ║"
echo "╚═══════════════════════════════════════════════════════════════╝"
echo ""
# ── Media storage path ─────────────────────────────────────────────────────
log_info "Frigate media storage (recordings, snapshots)"
echo " Recordings can fill tens of GB quickly — a dedicated drive is recommended."
echo ""
local FRIGATE_MEDIA_DIR=""
local DEFAULT_MEDIA="$DOCKER_DIR/frigate-audio/media"
if declare -f select_storage_path &>/dev/null; then
select_storage_path "Frigate recordings" FRIGATE_MEDIA_DIR
[ -z "$FRIGATE_MEDIA_DIR" ] && FRIGATE_MEDIA_DIR="$DEFAULT_MEDIA"
else
prompt_text "Frigate media path [$DEFAULT_MEDIA]:" "$DEFAULT_MEDIA" FRIGATE_MEDIA_DIR
fi
log_info "Media path: $FRIGATE_MEDIA_DIR"
# ── Camera credentials ─────────────────────────────────────────────────────
echo ""
log_info "Camera 1 — Front Door (required)"
local CAM1_USER="" CAM1_PASS="" CAM1_IP=""
prompt_text " RTSP username [admin]:" "admin" CAM1_USER
prompt_text " RTSP password:" "" CAM1_PASS
prompt_text " Camera IP [192.168.1.100]:" "192.168.1.100" CAM1_IP
echo ""
log_info "Camera 2 — Back Door (optional, press Enter to skip IP)"
local CAM2_USER="" CAM2_PASS="" CAM2_IP=""
prompt_text " RTSP username [admin]:" "admin" CAM2_USER
prompt_text " RTSP password [changeme]:" "changeme" CAM2_PASS
prompt_text " Camera IP (Enter to disable):" "" CAM2_IP
echo ""
log_info "Camera 3 — Third camera (optional)"
local CAM3_USER="" CAM3_PASS="" CAM3_IP=""
prompt_text " RTSP username [admin]:" "admin" CAM3_USER
prompt_text " RTSP password [changeme]:" "changeme" CAM3_PASS
prompt_text " Camera IP (Enter to disable):" "" CAM3_IP
# ── MQTT password ──────────────────────────────────────────────────────────
echo ""
log_info "MQTT credentials (Frigate ↔ Mosquitto ↔ frigate-notify)"
local MQTT_PASS=""
prompt_text " MQTT username [frigate]:" "frigate" MQTT_USER
if [ -z "${MQTT_USER:-}" ]; then MQTT_USER="frigate"; fi
MQTT_PASS=$(generate_password 24)
log_info " Generated MQTT password: $MQTT_PASS"
# ── ntfy server ─────────────────────────────────────────────────────────
echo ""
log_info "ntfy push notifications"
echo " frigate-notify sends alerts via ntfy. Set to your ntfy server URL."
local NTFY_SERVER="" NTFY_TOPIC="frigate"
prompt_text " ntfy server URL [https://ntfy.yourdomain.com]:" "https://ntfy.yourdomain.com" NTFY_SERVER
prompt_text " ntfy topic [frigate]:" "frigate" NTFY_TOPIC
# ── Frigate public URL ─────────────────────────────────────────────────────
echo ""
local BASE_DOMAIN="${SITE_DOMAIN:-}"
local FRIGATE_PUBLIC_URL=""
if [ -n "$BASE_DOMAIN" ]; then
local _PFX=""
prompt_text " Subdomain prefix for Frigate [cam].${BASE_DOMAIN}:" "cam" _PFX
FRIGATE_PUBLIC_URL="https://${_PFX:-cam}.${BASE_DOMAIN}"
else
prompt_text " Frigate public URL [https://cam.yourdomain.com]:" "https://cam.yourdomain.com" FRIGATE_PUBLIC_URL
fi
# ── Detector choice ────────────────────────────────────────────────────────
echo ""
log_info "Object detector"
echo " 1) CPU (works everywhere, higher CPU usage)"
echo " 2) USB Coral TPU (faster detection, lower CPU — requires USB Coral stick)"
echo " 3) PCIe Coral TPU"
local DET_CHOICE=""
prompt_text "Detector [1]:" "1" DET_CHOICE
local DETECTOR_BLOCK HWA_COMMENT
case "${DET_CHOICE:-1}" in
2) DETECTOR_BLOCK="detectors:\n coral:\n type: edgetpu\n device: usb"
HWA_COMMENT=" devices:\n - /dev/bus/usb:/dev/bus/usb # USB Coral" ;;
3) DETECTOR_BLOCK="detectors:\n coral:\n type: edgetpu\n device: pci"
HWA_COMMENT=" devices:\n - /dev/apex_0:/dev/apex_0 # PCIe Coral" ;;
*) DETECTOR_BLOCK="detectors:\n cpu:\n type: cpu\n num_threads: 3"
HWA_COMMENT="" ;;
esac
# ── Hardware acceleration for re-encoding ──────────────────────────────────
echo ""
local HWA=""
prompt_yn " Enable hardware video decode (Intel/AMD /dev/dri/renderD128)? (y/n) [n]:" "n" HWA
local DRI_LINE=""
[[ ${HWA:-n} =~ ^[Yy]$ ]] && DRI_LINE=" - /dev/dri/renderD128 # Intel/AMD hwaccel"
# ── Create directory structure ─────────────────────────────────────────────
mkdir -p "$DIR"/{frigate_config,mosquitto/config,mosquitto/data,mosquitto/log,"frigate-notify"}
mkdir -p "$FRIGATE_MEDIA_DIR"
ensure_docker_dir_ownership "$DIR"
cd "$DIR" || return 1
# ── .env ──────────────────────────────────────────────────────────────────
log_info "Writing .env..."
cat > "$DIR/.env" << ENVEOF
# Frigate audio stack — generated by setup.sh
# DO NOT commit this file — it contains credentials.
# ---- Camera 1: Front Door ----
FRIGATE_RTSP_USER=${CAM1_USER:-admin}
FRIGATE_RTSP_PASSWORD=${CAM1_PASS:-changeme}
FRIGATE_FRONT_DOOR_IP=${CAM1_IP:-192.168.1.100}
# ---- Camera 2: Back Door ----
FRIGATE_RTSP_USER1=${CAM2_USER:-admin}
FRIGATE_RTSP_PASSWORD1=${CAM2_PASS:-changeme}
FRIGATE_BACK_DOOR_IP=${CAM2_IP:-192.168.1.101}
# ---- Camera 3 (optional) ----
FRIGATE_RTSP_USER2=${CAM3_USER:-admin}
FRIGATE_RTSP_PASSWORD2=${CAM3_PASS:-changeme}
FRIGATE_SQUIRREL_IP=${CAM3_IP:-192.168.1.102}
# ---- MQTT ----
FRIGATE_MQTT_USER=${MQTT_USER:-frigate}
FRIGATE_MQTT_PASSWORD=${MQTT_PASS}
# ---- frigate-notify ----
FN_FRIGATE__MQTT__PASSWORD=${MQTT_PASS}
FN_FRIGATE__SERVER=http://frigate:5000
FN_FRIGATE__PUBLIC_URL=${FRIGATE_PUBLIC_URL}
FN_ALERTS__NTFY__SERVER=${NTFY_SERVER}
ENVEOF
chmod 600 "$DIR/.env"
log_success ".env written"
# ── docker-compose.yml ─────────────────────────────────────────────────────
log_info "Writing docker-compose.yml..."
local DEVICES_BLOCK=""
[ -n "$HWA_COMMENT" ] && DEVICES_BLOCK=" devices:\n${HWA_COMMENT}"
[ -n "$DRI_LINE" ] && DEVICES_BLOCK="${DEVICES_BLOCK}\n ${DRI_LINE}"
if [ -n "$DET_CHOICE" ] && [ "$DET_CHOICE" = "2" ]; then
DEVICES_BLOCK=" devices:\n${HWA_COMMENT}"
[ -n "$DRI_LINE" ] && DEVICES_BLOCK="${DEVICES_BLOCK}\n ${DRI_LINE}"
fi
cat > "$DIR/docker-compose.yml" << 'COMPOSEEOF'
# Frigate NVR + Mosquitto MQTT + frigate-notify
# Generated by ubuntu-post-install setup.sh
name: frigate-audio
services:
frigate:
container_name: frigate-audio
image: ghcr.io/blakeblackshear/frigate:0.17.1
restart: unless-stopped
stop_grace_period: 30s
privileged: true
shm_size: "512mb"
env_file: .env
depends_on:
- mosquitto
COMPOSEEOF
# Inject devices block if hardware acceleration chosen
if [ -n "$HWA_COMMENT" ] || [ -n "$DRI_LINE" ]; then
echo " devices:" >> "$DIR/docker-compose.yml"
[ -n "$HWA_COMMENT" ] && printf " %s\n" "$HWA_COMMENT" | sed 's|^ *||' >> "$DIR/docker-compose.yml"
[ -n "$DRI_LINE" ] && echo " $DRI_LINE" >> "$DIR/docker-compose.yml"
fi
cat >> "$DIR/docker-compose.yml" << COMPOSEEOF
volumes:
- /etc/localtime:/etc/localtime:ro
- ./frigate_config:/config
- ${FRIGATE_MEDIA_DIR}:/media/frigate
- type: tmpfs
target: /tmp/cache
tmpfs:
size: 1000000000
ports:
- "8971:8971"
- "5001:5000"
- "8554:8554"
- "8555:8555/tcp"
- "8555:8555/udp"
healthcheck:
test: ["CMD", "curl", "-f", "http://127.0.0.1:5000/api/version"]
interval: 10s
timeout: 5s
retries: 12
start_period: 60s
mosquitto:
container_name: frigate-audio-mqtt
hostname: mosquitto
image: eclipse-mosquitto:2
restart: unless-stopped
ports:
- "1883:1883"
volumes:
- ./mosquitto/config:/mosquitto/config
- ./mosquitto/data:/mosquitto/data
- ./mosquitto/log:/mosquitto/log
frigate-notify:
container_name: frigate-audio-notify
hostname: frigate-notify
image: ghcr.io/0x2142/frigate-notify:latest
restart: unless-stopped
env_file: .env
depends_on:
mosquitto:
condition: service_started
frigate:
condition: service_healthy
volumes:
- ./frigate-notify/config.yml:/app/config.yml:ro
COMPOSEEOF
log_success "docker-compose.yml written"
# ── Mosquitto config ───────────────────────────────────────────────────────
log_info "Writing Mosquitto config..."
cat > "$DIR/mosquitto/config/mosquitto.conf" << 'MQTTEOF'
listener 1883 0.0.0.0
protocol mqtt
persistence true
persistence_location /mosquitto/data/
log_dest stdout
log_dest file /mosquitto/log/mosquitto.log
allow_anonymous false
password_file /mosquitto/config/passwd
MQTTEOF
# Bootstrap the Mosquitto password file
log_info "Bootstrapping Mosquitto password file..."
if docker run --rm -i eclipse-mosquitto:2 \
mosquitto_passwd -b -c /dev/stdout "$MQTT_USER" "$MQTT_PASS" \
> "$DIR/mosquitto/config/passwd" 2>/dev/null; then
log_success "Mosquitto passwd file created"
else
log_warning "Could not bootstrap Mosquitto passwd — do it manually:"
log_warning " docker run --rm eclipse-mosquitto:2 mosquitto_passwd -b -c /passwd ${MQTT_USER} '${MQTT_PASS}'"
log_warning " Then copy the output to ${DIR}/mosquitto/config/passwd"
fi
# ── Frigate config.yml ─────────────────────────────────────────────────────
log_info "Writing Frigate config..."
local CAM2_ENABLED="false"; [ -n "$CAM2_IP" ] && CAM2_ENABLED="true"
local CAM3_ENABLED="false"; [ -n "$CAM3_IP" ] && CAM3_ENABLED="true"
local DETECTOR_YAML
case "${DET_CHOICE:-1}" in
2) DETECTOR_YAML="detectors:\n coral:\n type: edgetpu\n device: usb" ;;
3) DETECTOR_YAML="detectors:\n coral:\n type: edgetpu\n device: pci" ;;
*) DETECTOR_YAML="detectors:\n cpu:\n type: cpu\n num_threads: 3" ;;
esac
cat > "$DIR/frigate_config/config.yml" << FRIGCFGEOF
version: 0.17-0
mqtt:
enabled: true
host: mosquitto
port: 1883
user: "{FRIGATE_MQTT_USER}"
password: "{FRIGATE_MQTT_PASSWORD}"
topic_prefix: frigate
client_id: frigate
stats_interval: 60
tls:
enabled: false
# Audio detection — set true when you have a camera with a working mic.
# See the HOW TO ADD A CAMERA WITH A MIC section at the bottom of this file.
audio:
enabled: false
$(printf "$DETECTOR_YAML")
birdseye:
mode: continuous
semantic_search:
enabled: false
model_size: small
face_recognition:
enabled: true
model_size: small
lpr:
enabled: true
model_size: small
objects:
track:
- person
record:
enabled: true
continuous:
days: 0
motion:
days: 10
go2rtc:
streams:
front_door:
- rtsp://{FRIGATE_RTSP_USER}:{FRIGATE_RTSP_PASSWORD}@{FRIGATE_FRONT_DOOR_IP}:554/Streaming/Channels/101
back_door:
- rtsp://{FRIGATE_RTSP_USER1}:{FRIGATE_RTSP_PASSWORD1}@{FRIGATE_BACK_DOOR_IP}:554/Streaming/Channels/101
squirrel:
- rtsp://{FRIGATE_RTSP_USER2}:{FRIGATE_RTSP_PASSWORD2}@{FRIGATE_SQUIRREL_IP}:554/Streaming/Channels/101
cameras:
front_door:
enabled: true
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/front_door
input_args: preset-rtsp-restream
roles:
- detect
- record
detect:
enabled: true
width: 2688
height: 1520
fps: 5
back_door:
enabled: ${CAM2_ENABLED}
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/back_door
input_args: preset-rtsp-restream
roles:
- detect
- record
detect:
enabled: true
width: 2688
height: 1520
fps: 5
squirrel:
enabled: ${CAM3_ENABLED}
ffmpeg:
inputs:
- path: rtsp://127.0.0.1:8554/squirrel
input_args: preset-rtsp-restream
roles:
- detect
- record
detect:
enabled: true
width: 2688
height: 1520
fps: 5
##############################################################################
# HOW TO ADD A CAMERA WITH A MIC
#
# 1. Set audio.enabled: true at the top of this file.
#
# 2. In go2rtc.streams, add the audio transcode line:
# your_cam:
# - rtsp://{FRIGATE_RTSP_USER3}:{FRIGATE_RTSP_PASSWORD3}@{IP}:554/path#backchannel=0
# - "ffmpeg:your_cam#audio=aac#audio=opus"
#
# 3. In cameras, add the 'audio' role and audio-aware record preset:
# your_cam:
# enabled: true
# ffmpeg:
# output_args:
# record: preset-record-generic-audio-aac
# inputs:
# - path: rtsp://127.0.0.1:8554/your_cam
# input_args: preset-rtsp-restream
# roles:
# - detect
# - record
# - audio
#
# 4. Add credentials to .env:
# FRIGATE_RTSP_USER3=admin
# FRIGATE_RTSP_PASSWORD3=yourpass
#
# 5. RTSP paths by vendor:
# Hikvision / Hikvision OEM: /Streaming/Channels/101 (main), /102 (sub)
# Dahua / Dahua OEM: /cam/realmonitor?channel=1&subtype=0 (main)
##############################################################################
FRIGCFGEOF
log_success "Frigate config.yml written"
# ── frigate-notify config.yml ─────────────────────────────────────────────
log_info "Writing frigate-notify config..."
cat > "$DIR/frigate-notify/config.yml" << FNEOF
## frigate-notify config
## Docs: https://frigate-notify.0x2142.com
## Secrets come from .env via FN_* environment variables.
frigate:
server: # FN_FRIGATE__SERVER
ignoressl: true
public_url: # FN_FRIGATE__PUBLIC_URL
startup_check:
attempts: 5
interval: 30
mqtt:
enabled: true
server: mosquitto
port: 1883
clientid: frigate-notify
username: ${MQTT_USER:-frigate}
password: # FN_FRIGATE__MQTT__PASSWORD
topic_prefix: frigate
alerts:
general:
title: 'Frigate - {{ if .SubLabel }}{{ .SubLabel }}{{ else }}{{ .Label }}{{ end }} at {{ .Camera }}'
nosnap: allow
recheck_delay: 10
ntfy:
enabled: true
server: # FN_ALERTS__NTFY__SERVER
topic: "${NTFY_TOPIC:-frigate}"
ignoressl: false
headers:
- X-Priority: '{{ if .SubLabel }}3{{ else }}4{{ end }}'
- X-Tags: '{{ if .SubLabel }}wave{{ else }}rotating_light{{ end }}'
template: |
{{ if .SubLabel -}}{{ .SubLabel }}{{ else }}{{ .Label }}{{ end }} at {{ .Camera }}
{{- if gt (len .CurrentZones) 0 }}
Zone: {{ range \$i, \$z := .CurrentZones }}{{ if \$i }}, {{ end }}{{ \$z }}{{ end }}{{ end }}
Score: {{ printf "%.0f" (mul .TopScore 100) }}%
Time: {{ .StartTime.Format "Mon 3:04 PM" }}
monitor:
enabled: false
discord:
enabled: false
gotify:
enabled: false
smtp:
enabled: false
telegram:
enabled: false
pushover:
enabled: false
webhook:
enabled: false
FNEOF
log_success "frigate-notify config.yml written"
# ── Caddy snippet ──────────────────────────────────────────────────────────
if [ -n "$FRIGATE_PUBLIC_URL" ] && [ "$FRIGATE_PUBLIC_URL" != "https://cam.yourdomain.com" ]; then
local _DOM="${FRIGATE_PUBLIC_URL#https://}"
configure_caddy_for_service "Frigate" "8971" "frigate-audio" || true
fi
ensure_docker_dir_ownership "$DIR"
# ── Summary ────────────────────────────────────────────────────────────────
echo ""
echo "═══════════════════════════════════════════════════════"
echo " Frigate Audio Stack — Setup Complete"
echo "═══════════════════════════════════════════════════════"
echo ""
echo " Directory: $DIR"
echo " Media: $FRIGATE_MEDIA_DIR"
echo " Public URL: $FRIGATE_PUBLIC_URL"
echo " MQTT user: ${MQTT_USER:-frigate}"
echo " ntfy server: $NTFY_SERVER topic: ${NTFY_TOPIC:-frigate}"
echo ""
echo " Before starting:"
echo " 1. Edit frigate_config/config.yml — adjust RTSP paths for your cameras"
echo " (paths vary by vendor; check your camera's manual)"
echo " 2. Edit frigate_config/config.yml — remove/adjust motion masks"
echo " (the masks are blanks — add yours via the Frigate UI after first run)"
echo " 3. Verify .env credentials are correct"
echo ""
echo " Start:"
echo " cd $DIR && docker compose up -d"
echo ""
echo " Face recognition training (after Frigate is running):"
echo " — Go to Frigate UI → Faces → add face photos for household members"
echo " → In frigate-notify/config.yml, add names to alerts.sublabels.block"
echo " to silence push notifications for recognized family members."
echo ""
local START_NOW=""
prompt_yn "Start the stack now? (y/n) [n]:" "n" START_NOW
if [[ ${START_NOW:-n} =~ ^[Yy]$ ]]; then
log_info "Starting frigate-audio stack..."
if ( cd "$DIR" && docker compose up -d ); then
log_success "Stack started — Frigate UI: http://localhost:8971"
else
log_warning "Start failed — check: cd $DIR && docker compose logs"
fi
else
echo ""
log_info "When ready: cd $DIR && docker compose up -d"
fi
echo ""
}
+1 -1
View File
@@ -33,7 +33,7 @@ install_frigate() {
ensure_docker_dir_ownership "$FRIGATE_DIR"
cd "$FRIGATE_DIR" || return 1
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
# Hardware detection: include /dev/dri only when a render node exists
local DEVICE_BLOCK=""
+1 -1
View File
@@ -50,7 +50,7 @@ services:
restart: unless-stopped
privileged: true
environment:
- TZ=$(cat /etc/timezone 2>/dev/null || echo "UTC")
- TZ=${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}
volumes:
- ./config:/config
- /run/dbus:/run/dbus:ro
+3 -3
View File
@@ -112,7 +112,7 @@ install_immich() {
# ── Generate DB password ────────────────────────────────────────────────
local DB_PASS TZ_VAL
DB_PASS=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | head -c 32)
TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
# ── Write docker-compose.yml ────────────────────────────────────────────
if [ -n "$EXTERNAL_LIBRARY" ]; then
@@ -492,9 +492,9 @@ fi
if [ "$NODE_OK" = false ]; then
echo " Immich CLI requires Node.js >= 20 (found: $(node -v 2>/dev/null || echo 'none'))."
read -r -p " Install Node.js 22 LTS now? (y/n): " INSTALL_NODE_YN
read -r -p " Install Node.js 24 LTS now? (y/n): " INSTALL_NODE_YN
if [ "$INSTALL_NODE_YN" = "y" ] || [ "$INSTALL_NODE_YN" = "Y" ]; then
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash - 2>/dev/null
curl -fsSL https://deb.nodesource.com/setup_24.x | sudo -E bash - 2>/dev/null
sudo apt-get install -y -qq nodejs 2>/dev/null
NODE_MAJOR=$(node -v 2>/dev/null | sed 's/^v//' | cut -d. -f1)
if [ "$NODE_MAJOR" -ge 20 ] 2>/dev/null; then
+1 -1
View File
@@ -33,7 +33,7 @@ install_jellyfin() {
ensure_docker_dir_ownership "$JELLYFIN_DIR"
cd "$JELLYFIN_DIR" || return 1
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
# Hardware acceleration: only wire /dev/dri through if a render node exists,
# otherwise the container would fail to start on a GPU-less host.
+56 -14
View File
@@ -18,6 +18,21 @@ install_linux-to-sync() {
return 0
fi
# ── Re-run: already cloned → offer pull ──────────────────────────────────
if [ -d "$SYNC_DIR/.git" ]; then
log_info "linux-to-sync already cloned at $SYNC_DIR"
local DO_PULL=""
prompt_yn "Pull latest changes? (y/n) [y]:" "y" DO_PULL
if [[ ${DO_PULL:-y} =~ ^[Yy]$ ]]; then
if sudo -u "$ACTUAL_USER" git -C "$SYNC_DIR" pull; then
log_success "linux-to-sync updated"
else
log_warning "git pull failed — check connectivity and credentials"
fi
fi
return 0
fi
echo ""
echo " Requires access to github.com/outis1one/linux-to-sync"
echo " Authenticate with ONE of:"
@@ -41,31 +56,58 @@ install_linux-to-sync() {
return 0
fi
if git clone "https://$GH_TOKEN@github.com/outis1one/linux-to-sync.git" "$SYNC_DIR" 2>/dev/null; then
cd "$SYNC_DIR" || return 1
log_info "Cloning via HTTPS + PAT..."
if sudo -u "$ACTUAL_USER" \
git clone "https://$GH_TOKEN@github.com/outis1one/linux-to-sync.git" "$SYNC_DIR"; then
# Remove token from remote URL so it isn't stored in plain text
git remote set-url origin "https://github.com/outis1one/linux-to-sync.git"
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$SYNC_DIR"
sudo -u "$ACTUAL_USER" git -C "$SYNC_DIR" remote set-url origin \
"https://github.com/outis1one/linux-to-sync.git"
log_success "linux-to-sync cloned to $SYNC_DIR"
echo " Note: re-enter your token for future push/pull, or:"
echo " git config credential.helper store"
echo " Token stripped from remote URL. For future pulls use:"
echo " git -C $SYNC_DIR pull (will prompt for credentials)"
echo " Or set up a credential helper:"
echo " git config --global credential.helper store"
else
log_error "Clone failed — check your token and try again."
log_error "Clone failed — check your PAT and network, then retry."
return 1
fi
else
# SSH auth — git must run as the actual user to use their SSH keys.
echo ""
echo " Attempting SSH clone (your SSH key must be added to GitHub)..."
if git clone git@github.com:outis1one/linux-to-sync.git "$SYNC_DIR" 2>/dev/null; then
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$SYNC_DIR"
echo " Checking for SSH key in $ACTUAL_HOME/.ssh/ ..."
local SSH_KEY_FOUND=false
for _k in id_ed25519 id_rsa id_ecdsa; do
if [ -f "$ACTUAL_HOME/.ssh/$_k" ]; then
log_info " Found: $ACTUAL_HOME/.ssh/$_k"
SSH_KEY_FOUND=true
break
fi
done
if [ "$SSH_KEY_FOUND" = false ]; then
log_warning "No SSH key found in $ACTUAL_HOME/.ssh/"
echo ""
echo " To generate one:"
echo " ssh-keygen -t ed25519 -C 'your@email.com'"
echo " cat $ACTUAL_HOME/.ssh/id_ed25519.pub"
echo " → Add the public key at: github.com/settings/keys"
echo ""
local CONTINUE=""
prompt_yn "Continue anyway (will fail if no key on GitHub)? (y/n) [n]:" "n" CONTINUE
[[ ${CONTINUE:-n} =~ ^[Yy]$ ]] || return 0
fi
log_info "Cloning via SSH (running as $ACTUAL_USER)..."
if sudo -u "$ACTUAL_USER" \
git clone git@github.com:outis1one/linux-to-sync.git "$SYNC_DIR"; then
log_success "linux-to-sync cloned to $SYNC_DIR"
else
log_error "SSH clone failed."
echo ""
echo " To add your SSH key to GitHub:"
echo " 1. cat ~/.ssh/id_rsa.pub (or id_ed25519.pub)"
echo " 2. github.com/settings/keys → New SSH key → paste"
echo " Then retry: sudo ./setup.sh linux-to-sync"
echo " Common causes:"
echo " • SSH key not added to GitHub — go to github.com/settings/keys"
echo " • Key not accepted by ssh-agent — try: ssh-add $ACTUAL_HOME/.ssh/id_ed25519"
echo " • Test with: sudo -u $ACTUAL_USER ssh -T git@github.com"
echo " Then retry: sudo ./setup.sh linux-to-sync"
return 1
fi
fi
+1 -1
View File
@@ -33,7 +33,7 @@ install_lyrion() {
cd "$LYRION_DIR" || return 1
local TZ_VAL UID_VAL GID_VAL
TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
UID_VAL=$(id -u "$ACTUAL_USER"); GID_VAL=$(id -g "$ACTUAL_USER")
cat > docker-compose.yml << LYRION_COMPOSE
+1 -1
View File
@@ -33,7 +33,7 @@ install_magicmirror() {
mkdir -p "$MM_BASE"
chown "$ACTUAL_USER:$ACTUAL_USER" "$MM_BASE"
local TZ_VAL; TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
local TZ_VAL; TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
local i MM_PORT MM_DIR
for i in $(seq 1 "$MM_COUNT"); do
+1 -1
View File
@@ -26,7 +26,7 @@ install_mealie() {
cd "$MEALIE_DIR" || return 1
local TZ_VAL UID_VAL GID_VAL
TZ_VAL=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
UID_VAL=$(id -u "$ACTUAL_USER"); GID_VAL=$(id -g "$ACTUAL_USER")
cat > docker-compose.yml << MEALIE_COMPOSE
+127 -36
View File
@@ -145,11 +145,68 @@ print(snaps[0] if snaps else '')
[[ $WHITELIST =~ ^[Yy]$ ]] && WHITELIST_ENABLED=true || WHITELIST_ENABLED=false
local WHITELIST_PLAYERS=()
declare -A WHITELIST_PRELOADED # name → uuid, already resolved from existing file
if [ "$WHITELIST_ENABLED" = true ] && [ "$UNATTENDED" != true ]; then
echo ""
log_info "Whitelist Players"
echo " Enter player gamertags to pre-populate the whitelist."
echo " UUIDs are looked up automatically. Press Enter alone when done."
# Import from existing whitelist.json when re-running against an existing instance
local _EXISTING_WL="$MC_DIR/data/whitelist.json"
if [ -f "$_EXISTING_WL" ]; then
local -a _EX_NAMES _EX_UUIDS
mapfile -t _EX_NAMES < <(python3 -c "
import json, sys
try:
data = json.load(open(sys.argv[1]))
for p in data:
if p.get('name'): print(p['name'])
except: pass
" "$_EXISTING_WL" 2>/dev/null)
mapfile -t _EX_UUIDS < <(python3 -c "
import json, sys
try:
data = json.load(open(sys.argv[1]))
for p in data:
if p.get('uuid'): print(p['uuid'])
except: pass
" "$_EXISTING_WL" 2>/dev/null)
if [ ${#_EX_NAMES[@]} -gt 0 ]; then
echo ""
echo " Existing whitelist found (${#_EX_NAMES[@]} player(s)):"
local _i
for _i in "${!_EX_NAMES[@]}"; do
printf " %d) %s\n" "$((_i+1))" "${_EX_NAMES[$_i]}"
done
echo ""
echo " Import from existing? Enter numbers (e.g. 1,3,4), 0=all, Enter=skip:"
local _WL_IMPORT=""
read -p " Selection: " _WL_IMPORT
if [ -n "$_WL_IMPORT" ]; then
if [ "$_WL_IMPORT" = "0" ]; then
for _i in "${!_EX_NAMES[@]}"; do
WHITELIST_PRELOADED["${_EX_NAMES[$_i]}"]="${_EX_UUIDS[$_i]}"
done
log_success " Imported all ${#_EX_NAMES[@]} existing player(s)"
else
local -a _SEL_NUMS
IFS=',' read -ra _SEL_NUMS <<< "$_WL_IMPORT"
local _n
for _n in "${_SEL_NUMS[@]}"; do
_n="${_n// /}"
if [[ "$_n" =~ ^[0-9]+$ ]] && [ "$_n" -ge 1 ] && \
[ "$_n" -le "${#_EX_NAMES[@]}" ]; then
WHITELIST_PRELOADED["${_EX_NAMES[$((_n-1))]}"]="${_EX_UUIDS[$((_n-1))]}"
log_info " Imported: ${_EX_NAMES[$((_n-1))]}"
fi
done
fi
fi
fi
fi
echo ""
echo " Enter additional gamertags to add. UUIDs looked up automatically."
echo " Press Enter alone when done."
echo ""
while true; do
local _GT=""
@@ -158,8 +215,9 @@ print(snaps[0] if snaps else '')
WHITELIST_PLAYERS+=("$_GT")
log_info " Added: $_GT"
done
if [ ${#WHITELIST_PLAYERS[@]} -gt 0 ]; then
log_success " ${#WHITELIST_PLAYERS[@]} player(s) queued for whitelist"
local _WL_TOTAL=$(( ${#WHITELIST_PLAYERS[@]} + ${#WHITELIST_PRELOADED[@]} ))
if [ "$_WL_TOTAL" -gt 0 ]; then
log_success " $_WL_TOTAL player(s) queued for whitelist"
else
log_info " No players entered — whitelist will be empty until you add players manually"
fi
@@ -895,8 +953,7 @@ print(snaps[0] if snaps else '')
esac
local MC_DOMAIN=""
local BASE_DOMAIN=""
[ -f "$DOCKER_DIR/.config" ] && BASE_DOMAIN=$(grep '^BASE_DOMAIN=' "$DOCKER_DIR/.config" 2>/dev/null | cut -d= -f2-)
local BASE_DOMAIN="${SITE_DOMAIN:-}"
if [ "$USE_PLAYIT" = true ] || [ "$USE_PORTFORWARD" = true ]; then
if [ -n "$BASE_DOMAIN" ]; then
local _PREFIX=""
@@ -918,38 +975,61 @@ print(snaps[0] if snaps else '')
cd "$MC_DIR" || return 1
# ── Whitelist pre-population ────────────────────────────────────────────────
if [ "$WHITELIST_ENABLED" = true ] && [ ${#WHITELIST_PLAYERS[@]} -gt 0 ]; then
log_info "Looking up UUIDs for whitelist players..."
local _WL_NEED_WRITE=false
[ "$WHITELIST_ENABLED" = true ] && \
[ $(( ${#WHITELIST_PLAYERS[@]} + ${#WHITELIST_PRELOADED[@]} )) -gt 0 ] && \
_WL_NEED_WRITE=true
if [ "$_WL_NEED_WRITE" = true ]; then
log_info "Building whitelist.json..."
local _WL_JSON="["
local _WL_FIRST=true
local _WL_COUNT=0
local _player _resp _uuid _name
for _player in "${WHITELIST_PLAYERS[@]}"; do
_resp=$(curl -sf --max-time 10 \
"https://api.mojang.com/users/profiles/minecraft/${_player}" 2>/dev/null || echo "")
if [ -z "$_resp" ]; then
log_warning " '$_player' not found — skipping (account may not exist)"
continue
fi
_uuid=$(echo "$_resp" | python3 -c "
# Preloaded entries — UUIDs already known, no API call needed
local _wl_name _uuid
for _wl_name in "${!WHITELIST_PRELOADED[@]}"; do
_uuid="${WHITELIST_PRELOADED[$_wl_name]}"
log_success " $_wl_name$_uuid (from existing whitelist)"
[ "$_WL_FIRST" = true ] || _WL_JSON+=","
_WL_FIRST=false
_WL_COUNT=$((_WL_COUNT + 1))
_WL_JSON+="
{\"uuid\": \"$_uuid\", \"name\": \"$_wl_name\"}"
done
# New gamertags — look up via Mojang API
if [ ${#WHITELIST_PLAYERS[@]} -gt 0 ]; then
log_info " Looking up UUIDs via Mojang API..."
local _player _resp _name
for _player in "${WHITELIST_PLAYERS[@]}"; do
_resp=$(curl -sf --max-time 10 \
"https://api.mojang.com/users/profiles/minecraft/${_player}" 2>/dev/null || echo "")
if [ -z "$_resp" ]; then
log_warning " '$_player' not found — skipping (account may not exist)"
continue
fi
_uuid=$(echo "$_resp" | python3 -c "
import sys, json
d = json.load(sys.stdin)
uid = d['id']
print(f'{uid[:8]}-{uid[8:12]}-{uid[12:16]}-{uid[16:20]}-{uid[20:]}')
" 2>/dev/null || echo "")
_name=$(echo "$_resp" | python3 -c "
_name=$(echo "$_resp" | python3 -c "
import sys, json; d=json.load(sys.stdin); print(d.get('name',''))" 2>/dev/null || echo "$_player")
if [ -z "$_uuid" ]; then
log_warning " Could not parse UUID for '$_player' — skipping"
continue
fi
log_success " $_name$_uuid"
[ "$_WL_FIRST" = true ] || _WL_JSON+=","
_WL_FIRST=false
_WL_COUNT=$((_WL_COUNT + 1))
_WL_JSON+="
if [ -z "$_uuid" ]; then
log_warning " Could not parse UUID for '$_player' — skipping"
continue
fi
log_success " $_name$_uuid"
[ "$_WL_FIRST" = true ] || _WL_JSON+=","
_WL_FIRST=false
_WL_COUNT=$((_WL_COUNT + 1))
_WL_JSON+="
{\"uuid\": \"$_uuid\", \"name\": \"$_name\"}"
done
done
fi
_WL_JSON+="
]"
echo "$_WL_JSON" > "$MC_DIR/data/whitelist.json"
@@ -1012,9 +1092,13 @@ for v in versions:
echo ""
log_info "Vanilla Tweaks — download your selected packs manually:"
echo ""
echo " 1. Go to: https://vanillatweaks.net/picker/datapacks/"
echo " 2. Select Minecraft version ${VT_VERSION} in the version dropdown"
echo " 3. Enable these packs (your selections from the toggle menu):"
echo " ┌─ Quick start: pre-configured share links (opens VT pre-selected) ─┐"
echo " │ Datapacks: https://vanillatweaks.net/share#B3QqSd │"
echo " │ Crafting tweaks: https://vanillatweaks.net/share#SqzGkO │"
echo " └───────────────────────────────────────────────────────────────────-┘"
echo ""
echo " Or pick manually — go to https://vanillatweaks.net/picker/datapacks/"
echo " and select version ${VT_VERSION}, then enable your chosen packs:"
echo ""
local _LAST_CAT="" _cat dp
for dp in "${DPACK_ORDER[@]}"; do
@@ -1027,13 +1111,20 @@ for v in versions:
echo "${DPACKS[$dp]}"
done
echo ""
echo " 4. Click Download and save the .zip file"
echo " 5. Place the .zip in: ${MC_DIR}/datapacks-download/"
echo " 6. Rebuild: cd ${MC_DIR} && docker compose build"
echo " 7. Restart: cd ${MC_DIR} && docker compose up -d"
echo ""
echo " ── How to install ────────────────────────────────────────────────────"
echo " 1. Download the ZIP from vanillatweaks.net (use share link or pick)"
echo " 2. SCP it to this server (run on your local machine):"
echo " scp ~/Downloads/VanillaTweaks*.zip $(whoami)@$(hostname -I | awk '{print $1}'):${MC_DIR}/datapacks-download/"
echo " 3. On this server:"
echo " cd ${MC_DIR}/datapacks-download"
echo " unzip 'VanillaTweaks*.zip' && rm VanillaTweaks*.zip"
echo " 4. Rebuild: cd ${MC_DIR} && docker compose build"
echo " 5. Restart: cd ${MC_DIR} && docker compose up -d"
echo " ──────────────────────────────────────────────────────────────────────"
echo " The itzg image extracts .zip files from /datapacks/ on startup."
echo " Datapacks land in ${MC_NAME}/data/datapacks/ and persist across restarts."
echo ""
read -p " Press Enter when datapacks are in datapacks-download/ (or Enter to skip): "
fi
# ── LuckPerms bootstrap script ──────────────────────────────────────────────
+1 -1
View File
@@ -38,7 +38,7 @@ services:
NTFY_COMPOSE
cat > .env << NTFY_ENV
TZ=$(cat /etc/timezone 2>/dev/null || echo "UTC")
TZ=${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}
NTFY_ENV
mkdir -p cache config
+3 -3
View File
@@ -65,10 +65,10 @@ EOF
if ! [ "$NODE_MAJOR" -ge 18 ] 2>/dev/null; then
log_warning "Node.js >= 18 required for building/signing (found: $(node -v 2>/dev/null || echo none))."
local INSTALL_NODE=""
prompt_yn " Install Node.js 22 LTS from NodeSource now? (y/n):" "y" INSTALL_NODE
prompt_yn " Install Node.js 24 LTS from NodeSource now? (y/n):" "y" INSTALL_NODE
if [ "$INSTALL_NODE" = "y" ] || [ "$INSTALL_NODE" = "Y" ]; then
log_info "Installing Node.js 22 LTS..."
curl -fsSL https://deb.nodesource.com/setup_22.x | bash - >/dev/null 2>&1
log_info "Installing Node.js 24 LTS..."
curl -fsSL https://deb.nodesource.com/setup_24.x | bash - >/dev/null 2>&1
apt-get install -y nodejs >/dev/null 2>&1
NODE_MAJOR=$(node -v 2>/dev/null | sed 's/^v//' | cut -d. -f1)
fi
+183
View File
@@ -0,0 +1,183 @@
#!/bin/bash
# services/sky-cam.sh — Automated sky / timelapse camera scripts.
# Part of the modular post-install system (sourced by setup.sh).
#
# NON-DOCKER module. sky-cam produces:
# • Daily sunrise clip — speed-adjusted video, uploaded to Mattermost
# • Four Seasons timelapse — daily clips sized to Vivaldi movements' music
# • Full-day timelapse — fixed-fps timelapse of every captured image
# • Moon-track timelapse — moon tracked & cropped each visible night
# • Monthly moon-phase close-ups — NASA Dial-a-Moon images posted to MM
#
# Source: https://github.com/outis1one/sky-cam (cloned via bootstrap.sh)
# Installs systemd user timers via sky-cam's install.sh.
register_service sky-cam cameras "Automated sky / timelapse camera scripts (sky-cam)"
install_sky-cam() {
local SKYCAM_DIR="$ACTUAL_HOME/sky-cam"
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] sky-cam would:"
echo " - Install: ffmpeg bc fonts-dejavu curl python3-pip"
echo " - pip install: suntime pytz requests skyfield Pillow numpy scipy"
echo " - Clone sky-cam to $SKYCAM_DIR via bootstrap.sh"
echo " - Edit sky-cam.conf with your location and camera names"
echo " - Copy .env.example → .env and set Mattermost credentials"
echo " - Run ./install.sh to register systemd user timers"
return 0
fi
echo ""
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ sky-cam — Automated Sky & Timelapse Camera System ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
# ── System packages ──────────────────────────────────────────────────────
log_info "Installing system dependencies..."
run_cmd apt-get update -qq
run_cmd apt-get install -y --no-install-recommends \
ffmpeg bc fonts-dejavu curl python3-pip git
log_success "System packages installed"
# ── Python packages ──────────────────────────────────────────────────────
log_info "Installing Python packages..."
pip_user_install suntime pytz requests skyfield Pillow numpy scipy \
|| log_warning "Some pip packages may have failed — check output above"
log_success "Python packages installed"
# ── Clone sky-cam ────────────────────────────────────────────────────────
if [ -d "$SKYCAM_DIR/.git" ]; then
log_info "sky-cam already cloned at $SKYCAM_DIR — pulling latest..."
sudo -u "$ACTUAL_USER" git -C "$SKYCAM_DIR" pull --ff-only \
|| log_warning "git pull failed — continuing with existing version"
else
log_info "Cloning sky-cam from GitHub..."
sudo -u "$ACTUAL_USER" bash -c "
curl -fsSL https://raw.githubusercontent.com/outis1one/sky-cam/main/bootstrap.sh \
| bash -s -- '$SKYCAM_DIR'
" || { log_error "Failed to clone sky-cam — check internet connection"; return 1; }
log_success "sky-cam cloned to $SKYCAM_DIR"
fi
# ── Essential configuration ──────────────────────────────────────────────
echo ""
log_info "Location and camera configuration"
echo " sky-cam needs your GPS coordinates and timezone to calculate"
echo " sunrise times accurately. Use decimal degrees (e.g. 40.7128, -74.0060)."
echo ""
local LATITUDE="" LONGITUDE="" TIMEZONE="" BASE_DIR="" CAMERAS_LIST="" SUNRISE_CAM=""
prompt_text " Latitude (decimal degrees) [0.0000]:" "0.0000" LATITUDE
prompt_text " Longitude (decimal degrees) [0.0000]:" "0.0000" LONGITUDE
prompt_text " Timezone [${SITE_TZ:-America/New_York}]:" "${SITE_TZ:-America/New_York}" TIMEZONE
echo ""
echo " Camera names are short identifiers, e.g.: east north south west"
echo " These names must match the directories where your camera images are saved."
echo ""
prompt_text " Camera names (space-separated) [east]:" "east" CAMERAS_LIST
prompt_text " Sunrise camera (faces east) [east]:" "east" SUNRISE_CAM
echo ""
echo " BASE_DIR is where your camera images live."
echo " Each camera should have a sub-folder: BASE_DIR/<camera-name>/"
local DEFAULT_BASE="$ACTUAL_HOME/sky-cam/data"
prompt_text " Image base directory [$DEFAULT_BASE]:" "$DEFAULT_BASE" BASE_DIR
[ -z "$BASE_DIR" ] && BASE_DIR="$DEFAULT_BASE"
# Prompt for Mattermost credentials
echo ""
log_info "Mattermost webhook (for automated uploads)"
echo " sky-cam posts sunrise clips and moon photos to a Mattermost channel."
echo " Create an incoming webhook in Mattermost: Settings → Integrations → Webhooks"
echo " (Leave blank to skip — add to $SKYCAM_DIR/.env later)"
echo ""
local MM_WEBHOOK="" MM_CHANNEL=""
if [ "$UNATTENDED" != true ]; then
read -p " Mattermost webhook URL [Enter to skip]: " MM_WEBHOOK
if [ -n "$MM_WEBHOOK" ]; then
prompt_text " Mattermost channel name [sky-cam]:" "sky-cam" MM_CHANNEL
fi
fi
# ── Write .env ───────────────────────────────────────────────────────────
log_info "Writing sky-cam.conf overrides to $SKYCAM_DIR/.env..."
{
echo "# sky-cam site configuration — generated by ubuntu-post-install"
echo "# Edit sky-cam.conf for full settings."
echo ""
echo "LATITUDE=${LATITUDE:-0.0000}"
echo "LONGITUDE=${LONGITUDE:-0.0000}"
echo "TIMEZONE=${TIMEZONE:-America/New_York}"
echo "BASE_DIR=${BASE_DIR}"
if [ -n "$MM_WEBHOOK" ]; then
echo "MM_WEBHOOK_URL=${MM_WEBHOOK}"
echo "MM_CHANNEL=${MM_CHANNEL:-sky-cam}"
else
echo "# MM_WEBHOOK_URL=https://mattermost.yourdomain.com/hooks/your-webhook-id"
echo "# MM_CHANNEL=sky-cam"
fi
} > "$SKYCAM_DIR/.env"
chmod 600 "$SKYCAM_DIR/.env"
# ── Patch sky-cam.conf with cameras and basic settings ───────────────────
local CONF="$SKYCAM_DIR/sky-cam.conf"
if [ -f "$CONF" ]; then
log_info "Patching sky-cam.conf with location and camera names..."
# Build CAMERAS=(...) line
local CAM_ARRAY="(${CAMERAS_LIST})"
sed -i "s|^CAMERAS=.*|CAMERAS=${CAM_ARRAY}|" "$CONF"
sed -i "s|^SUNRISE_CAM=.*|SUNRISE_CAM=${SUNRISE_CAM:-east}|" "$CONF"
log_success "sky-cam.conf updated"
else
log_warning "sky-cam.conf not found — check $SKYCAM_DIR"
fi
# ── Create image directories ─────────────────────────────────────────────
mkdir -p "$BASE_DIR"
for _cam in $CAMERAS_LIST; do
mkdir -p "$BASE_DIR/$_cam"
done
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$SKYCAM_DIR" "$BASE_DIR" 2>/dev/null || true
log_success "Image directories created under $BASE_DIR"
# ── Install systemd timers ────────────────────────────────────────────────
if [ -f "$SKYCAM_DIR/install.sh" ]; then
log_info "Installing systemd user timers via install.sh..."
( cd "$SKYCAM_DIR" && sudo -u "$ACTUAL_USER" bash install.sh ) \
&& log_success "Systemd timers installed" \
|| log_warning "install.sh failed — run manually: cd $SKYCAM_DIR && ./install.sh"
else
log_warning "install.sh not found in $SKYCAM_DIR — run it manually after review"
fi
# ── Summary ───────────────────────────────────────────────────────────────
echo ""
echo "═══════════════════════════════════════════════════════"
echo " sky-cam installed"
echo "═══════════════════════════════════════════════════════"
echo ""
echo " Location: $SKYCAM_DIR"
echo " Data: $BASE_DIR"
echo " Cameras: $CAMERAS_LIST"
echo " Timezone: ${TIMEZONE:-America/New_York}"
echo ""
echo " Next steps:"
echo " 1. Review $SKYCAM_DIR/sky-cam.conf"
echo " — SCRIPT_DIR, MUSIC_DIR, schedules, encoding settings"
echo " 2. Put your Vivaldi Four Seasons audio files in:"
echo " $SKYCAM_DIR/music/"
echo " (filenames and expected MUSIC_DIR path are in sky-cam.conf)"
echo " 3. Verify systemd timers:"
echo " systemctl --user list-timers 'sky-cam-*'"
echo " 4. Credentials → $SKYCAM_DIR/.env"
echo ""
echo " To test the sunrise script manually:"
echo " cd $SKYCAM_DIR && ./daily_sunrise_video.sh"
echo ""
echo " Logs:"
echo " journalctl --user -u sky-cam-sunrise.service -f"
echo ""
}
+128
View File
@@ -0,0 +1,128 @@
#!/bin/bash
# services/sync-cc.sh — Subtitle sync & generation tool (sync_cc).
# Part of the modular post-install system (sourced by setup.sh).
#
# NON-DOCKER module. sync_cc is a Python CLI tool that:
# - GENERATE: Whisper AI transcribes video audio → SRT
# - SYNC: ffsubsync aligns an existing SRT to the video
# - BATCH: process all video+SRT pairs in a directory
# - RENAME: look up episode titles on TMDB, rename to Plex format
# - EXTRACT: pull embedded subtitle / CC tracks out of MKV/MP4/TS
# - REMUX: MP4 → MKV stream-copy (no re-encode)
# - EMBED: soft-mux an SRT into a container via mkvmerge
# - BURNSUBS: OCR burnt-in subs → SRT (and optionally erase from video)
#
# GPU is used automatically when CUDA or MPS is detected.
# Heavy deps (easyocr, pgsreader) are installed on first use by the script
# itself. This module installs the always-needed system + pip packages.
#
# Source script: extras/sync_cc.py in this repo.
register_service sync-cc extras "Subtitle sync/generate tool — Whisper + ffsubsync (sync_cc)"
install_sync-cc() {
local SYNCCC_DIR="$ACTUAL_HOME/sync-cc"
if [ "$DRY_RUN" = true ]; then
echo "[DRY-RUN] sync-cc would:"
echo " - Install: python3-pip ffmpeg mkvtoolnix ccextractor"
echo " - pip install: openai-whisper ffsubsync"
echo " - Copy extras/sync_cc.py → $SYNCCC_DIR/sync_cc.py"
echo " - Write $SYNCCC_DIR/.env with TMDB_API_KEY"
echo " - Create /usr/local/bin/sync-cc wrapper"
return 0
fi
echo ""
echo "╔═══════════════════════════════════════════════════════╗"
echo "║ Subtitle Sync & Generation — sync_cc ║"
echo "║ Whisper AI · ffsubsync · TMDB rename · OCR subs ║"
echo "╚═══════════════════════════════════════════════════════╝"
echo ""
# ── System packages ──────────────────────────────────────────────────────
log_info "Installing system dependencies..."
run_cmd apt-get update -qq
run_cmd apt-get install -y --no-install-recommends \
python3 python3-pip ffmpeg mkvtoolnix ccextractor
log_success "System packages installed"
# ── pip packages ─────────────────────────────────────────────────────────
log_info "Installing Python packages (openai-whisper, ffsubsync)..."
if pip_user_install openai-whisper ffsubsync; then
log_success "Python packages installed"
else
log_warning "pip install reported errors — the tool may still work if packages were partially installed"
fi
# ── Install script ───────────────────────────────────────────────────────
mkdir -p "$SYNCCC_DIR"
cp "$HERE/extras/sync_cc.py" "$SYNCCC_DIR/sync_cc.py"
chmod +x "$SYNCCC_DIR/sync_cc.py"
chown -R "$ACTUAL_USER:$ACTUAL_USER" "$SYNCCC_DIR"
log_success "sync_cc.py installed to $SYNCCC_DIR/"
# ── TMDB API key ─────────────────────────────────────────────────────────
echo ""
log_info "TMDB API Key (optional — needed for episode rename mode)"
echo " The rename feature looks up episode titles via The Movie Database."
echo " Get a free key at https://www.themoviedb.org/settings/api"
echo " (Leave blank to skip — you can add it later to $SYNCCC_DIR/.env)"
echo ""
local TMDB_KEY=""
if [ "$UNATTENDED" != true ]; then
read -p " TMDB API key [Enter to skip]: " TMDB_KEY
fi
# Write .env (creates or replaces)
{
echo "# sync_cc configuration"
echo "# Get a free TMDB key at https://www.themoviedb.org/settings/api"
if [ -n "$TMDB_KEY" ]; then
echo "TMDB_API_KEY=${TMDB_KEY}"
else
echo "# TMDB_API_KEY=your_key_here"
fi
} > "$SYNCCC_DIR/.env"
chown "$ACTUAL_USER:$ACTUAL_USER" "$SYNCCC_DIR/.env"
chmod 600 "$SYNCCC_DIR/.env"
log_success ".env written to $SYNCCC_DIR/.env"
# ── Wrapper in PATH ───────────────────────────────────────────────────────
# cd into the user's current dir first so .env from cwd is preferred;
# falls back to the one next to sync_cc.py.
cat > /usr/local/bin/sync-cc << WRAPEOF
#!/bin/bash
exec python3 "$SYNCCC_DIR/sync_cc.py" "\$@"
WRAPEOF
chmod +x /usr/local/bin/sync-cc
log_success "wrapper created: /usr/local/bin/sync-cc"
# ── Summary ───────────────────────────────────────────────────────────────
echo ""
echo "═══════════════════════════════════════════════════════"
echo " sync_cc installed"
echo "═══════════════════════════════════════════════════════"
echo ""
echo " Run from any directory containing video / SRT files:"
echo " sync-cc"
echo ""
echo " Modes:"
echo " 1 SYNC — align an existing SRT to the video"
echo " 2 GENERATE — Whisper AI transcribes video → SRT"
echo " 3 BATCH — sync all video+SRT pairs in directory"
echo " 4 RENAME — TMDB episode lookup + rename to Plex format"
echo " 5 EXTRACT — pull embedded subtitle tracks from MKV/MP4/TS"
echo " 6 REMUX — MP4 → MKV stream copy (no re-encode)"
echo " 7 EMBED — soft-mux an SRT into a container"
echo " 8 BURNSUBS — OCR burnt-in subs → SRT"
echo ""
echo " Config: $SYNCCC_DIR/.env"
if [ -z "$TMDB_KEY" ]; then
echo " → Set TMDB_API_KEY in .env to enable episode rename mode"
fi
echo ""
echo " Whisper models download automatically on first use."
echo " First run may take a few minutes while the model downloads."
echo ""
}
+91 -25
View File
@@ -81,6 +81,8 @@ is_installed() {
crowdsec) command -v cscli >/dev/null 2>&1 ;;
silent-send) [ -d "$ACTUAL_HOME/silent-send/.git" ] ;;
linux-to-sync) [ -d "$ACTUAL_HOME/linux-to-sync/.git" ] ;;
sync-cc) [ -f "$ACTUAL_HOME/sync-cc/sync_cc.py" ] ;;
sky-cam) [ -d "$ACTUAL_HOME/sky-cam/.git" ] ;;
*) [ -e "$DOCKER_DIR/$1" ] ;;
esac
}
@@ -104,9 +106,42 @@ list_services() {
echo ""
}
# ── Site defaults wizard ──────────────────────────────────────────────────────
# Prompts for timezone, base domain, and Caddy network name; saves to .config.
# Run directly: sudo ./setup.sh configure
run_site_configure() {
local _sys_tz; _sys_tz=$(cat /etc/timezone 2>/dev/null || echo "UTC")
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Site defaults · pre-filled into every service prompt ║"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo " These become the default answer each time a service asks for"
echo " timezone, domain, etc. Press Enter to keep the shown value."
echo ""
local _cur_tz="${SITE_TZ:-$_sys_tz}"
local _cur_dom="${SITE_DOMAIN:-}"
local _cur_net="${SITE_CADDY_NET:-caddy_net}"
prompt_text " Timezone [${_cur_tz}]:" "$_cur_tz" SITE_TZ
prompt_text " Base domain (e.g., example.com) [${_cur_dom:-<not set>}]:" "$_cur_dom" SITE_DOMAIN
prompt_text " Caddy Docker network [${_cur_net}]:" "$_cur_net" SITE_CADDY_NET
export SITE_TZ SITE_DOMAIN SITE_CADDY_NET
mkdir -p "$DOCKER_DIR"
save_site_config
log_success "Saved to $DOCKER_DIR/.config"
echo ""
}
# ── --list ───────────────────────────────────────────────────────────────────
if [ "$DO_LIST" = true ]; then list_services; exit 0; fi
# ── configure: show/update site-wide defaults ────────────────────────────────
if [ "${REQUESTED[*]:-}" = "configure" ]; then
require_root
run_site_configure
exit 0
fi
# ── Direct install: ./setup.sh caddy homeassistant ──────────────────────────
if [ "${#REQUESTED[@]}" -gt 0 ]; then
require_root
@@ -117,34 +152,65 @@ fi
# ── Guided interactive flow ──────────────────────────────────────────────────
require_root
# 1) Show the REQUIRED set and let the user cancel before anything happens.
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Ubuntu Post-Install · v$(cat "$HERE/VERSION" 2>/dev/null || echo '?')"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "REQUIRED (installed/verified first):"
echo " • Essential CLI packages: net-tools, git, curl, wget, htop, tree,"
echo " ncdu, zip/unzip, jq, rsync, and glow (markdown reader)"
echo " • Docker presence check (needed by all containerized services)"
echo ""
echo "Then you'll get a category menu to pick optional services."
echo ""
PROCEED=""
prompt_yn "Proceed with the required setup? (y/n):" "y" PROCEED
if [ "$PROCEED" != "y" ] && [ "$PROCEED" != "Y" ]; then
echo "Cancelled. Nothing was changed."
exit 0
_VER="$(cat "$HERE/VERSION" 2>/dev/null || echo '?')"
_OS_LINE="${OS_DISTRO^} ${OS_VERSION} (${OS_CODENAME})"
if is_installed base; then
# ── Re-run: base already present — skip required step ────────────────────
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Ubuntu Post-Install · v${_VER} · ${_OS_LINE}"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo " Base packages already installed — skipping required setup."
echo " Use 'sudo ./setup.sh base' to force a reinstall."
echo ""
else
# ── First run: show required banner, confirm, install ────────────────────
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Ubuntu Post-Install · v${_VER} · ${_OS_LINE}"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
if [ "$OS_DISTRO" != "ubuntu" ]; then
log_warning "Detected OS: ${_OS_LINE} — this script targets Ubuntu. Proceed with caution."
echo ""
elif ! ubuntu_version_ge "24.04"; then
log_warning "Ubuntu ${OS_VERSION} detected — tested on 24.04+. Some packages may differ."
echo ""
fi
echo "REQUIRED (installed/verified first):"
echo " • Essential CLI packages: net-tools, git, curl, wget, htop, tree,"
echo " ncdu, zip/unzip, jq, rsync, and glow (markdown reader)"
echo " • Docker presence check (needed by all containerized services)"
echo ""
echo "Then you'll get a category menu to pick optional services."
echo ""
PROCEED=""
prompt_yn "Proceed with the required setup? (y/n):" "y" PROCEED
if [ "$PROCEED" != "y" ] && [ "$PROCEED" != "Y" ]; then
echo "Cancelled. Nothing was changed."
exit 0
fi
run_service base
if ! command -v docker >/dev/null 2>&1; then
log_warning "Docker is not installed. Containerized services need it."
echo " Install with: curl -fsSL https://get.docker.com | sh"
fi
fi
# 2) Run required.
run_service base
if ! command -v docker >/dev/null 2>&1; then
log_warning "Docker is not installed. Containerized services need it."
echo " Install with: curl -fsSL https://get.docker.com | sh"
# 3) Offer site defaults wizard if .config has no SITE_TZ yet (first run).
if ! grep -q '^SITE_TZ=' "$DOCKER_DIR/.config" 2>/dev/null; then
echo ""
echo " No site defaults found. Setting them now pre-fills timezone, domain,"
echo " and Caddy network for every service — you type them once, not every time."
OFFER_CONFIG=""
prompt_yn "Configure site defaults now? (y/n):" "y" OFFER_CONFIG
[ "$OFFER_CONFIG" = "y" ] || [ "$OFFER_CONFIG" = "Y" ] && run_site_configure
fi
# 3) Offer Caddy first (most services proxy through it).
# 4) Offer Caddy first (most services proxy through it).
if [ -n "${SERVICE_GROUP[caddy]:-}" ] && ! is_installed caddy; then
echo ""
OFFER_CADDY=""
@@ -152,7 +218,7 @@ if [ -n "${SERVICE_GROUP[caddy]:-}" ] && ! is_installed caddy; then
[ "$OFFER_CADDY" = "y" ] || [ "$OFFER_CADDY" = "Y" ] && run_service caddy
fi
# 4) Category menu loop: pick a category → checklist → install → back to menu.
# 5) Category menu loop: pick a category → checklist → install → back to menu.
have_whiptail=false
command -v whiptail >/dev/null 2>&1 && have_whiptail=true
+209
View File
@@ -0,0 +1,209 @@
#!/bin/bash
# setup.sh — modular post-install dispatcher.
#
# One source of truth, multiple ways to run it:
# sudo ./setup.sh guided install: required packages, then a
# category menu you loop through
# sudo ./setup.sh <service> ... install one or more services directly
# ./setup.sh --list list available services (grouped)
# ./setup.sh --version print version
#
# Flags:
# --dry-run preview actions without making changes
# --unattended use defaults, no prompts (pair with explicit service names)
#
# Every service lives in services/<name>.sh, registers itself with
# register_service, and defines install_<name>. Adding a service = adding one
# file; it appears in the menu automatically. Nothing is generated.
set -uo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Category display order (groups not listed here are appended alphabetically).
CATEGORY_ORDER=(base homelab utilities media cameras gaming extras backup)
# Service ordering hint within a category (lower = earlier). Default 50.
declare -A SERVICE_PRIORITY=( [caddy]=1 [crowdsec]=2 [authelia]=3 )
# ── Parse flags / collect service names ──────────────────────────────────────
DRY_RUN=false; UNATTENDED=false; DO_LIST=false
REQUESTED=()
for arg in "$@"; do
case "$arg" in
--dry-run) DRY_RUN=true ;;
--unattended) UNATTENDED=true ;;
--list|-l) DO_LIST=true ;;
--version|-V) cat "$HERE/VERSION" 2>/dev/null || echo "unknown"; exit 0 ;;
-h|--help) sed -n '2,18p' "${BASH_SOURCE[0]}" | sed 's/^# \{0,1\}//'; exit 0 ;;
-*) echo "Unknown flag: $arg" >&2; exit 1 ;;
*) REQUESTED+=("$arg") ;;
esac
done
export DRY_RUN UNATTENDED
# ── Load helpers + all service modules (they self-register) ──────────────────
# shellcheck source=lib/common.sh
source "$HERE/lib/common.sh"
shopt -s nullglob
for _mod in "$HERE"/services/*.sh; do source "$_mod"; done
shopt -u nullglob
# ── Helpers over the registry ────────────────────────────────────────────────
# Groups present, in CATEGORY_ORDER first, then any extras alphabetically.
groups_present() {
local g present=() seen=" "
for name in "${SERVICE_ORDER[@]}"; do
g="${SERVICE_GROUP[$name]}"
case "$seen" in *" $g "*) : ;; *) present+=("$g"); seen="$seen$g " ;; esac
done
local out=()
for g in "${CATEGORY_ORDER[@]}"; do
printf '%s\n' "${present[@]}" | grep -qx "$g" && out+=("$g")
done
for g in "${present[@]}"; do
printf '%s\n' "${CATEGORY_ORDER[@]}" | grep -qx "$g" || out+=("$g")
done
printf '%s\n' "${out[@]}"
}
# Services in a group, ordered by SERVICE_PRIORITY then name.
services_in_group() {
local group="$1" name
for name in "${SERVICE_ORDER[@]}"; do
[ "${SERVICE_GROUP[$name]}" = "$group" ] && echo "${SERVICE_PRIORITY[$name]:-50} $name"
done | sort -n -k1 | awk '{print $2}'
}
# Best-effort "is it already installed?" for the [installed] marker.
is_installed() {
case "$1" in
base) command -v ncdu >/dev/null 2>&1 ;;
glow) command -v glow >/dev/null 2>&1 ;;
crowdsec) command -v cscli >/dev/null 2>&1 ;;
silent-send) [ -d "$ACTUAL_HOME/silent-send/.git" ] ;;
linux-to-sync) [ -d "$ACTUAL_HOME/linux-to-sync/.git" ] ;;
*) [ -e "$DOCKER_DIR/$1" ] ;;
esac
}
run_service() {
local name="$1"
if [ -z "${SERVICE_GROUP[$name]:-}" ]; then log_error "Unknown service: $name (try --list)"; return 1; fi
declare -F "install_${name}" >/dev/null || { log_error "Service '$name' has no install_${name}"; return 1; }
log_info "=== ${name} (${SERVICE_DESC[$name]}) ==="
"install_${name}"
}
list_services() {
local g name
while IFS= read -r g; do
echo ""; echo "── ${g^^} ──"
while IFS= read -r name; do
printf " %-16s %s\n" "$name" "${SERVICE_DESC[$name]}"
done < <(services_in_group "$g")
done < <(groups_present)
echo ""
}
# ── --list ───────────────────────────────────────────────────────────────────
if [ "$DO_LIST" = true ]; then list_services; exit 0; fi
# ── Direct install: ./setup.sh caddy homeassistant ──────────────────────────
if [ "${#REQUESTED[@]}" -gt 0 ]; then
require_root
rc=0; for name in "${REQUESTED[@]}"; do run_service "$name" || rc=1; done
exit "$rc"
fi
# ── Guided interactive flow ──────────────────────────────────────────────────
require_root
# 1) Show the REQUIRED set and let the user cancel before anything happens.
echo ""
echo "╔══════════════════════════════════════════════════════════════╗"
echo "║ Ubuntu Post-Install · v$(cat "$HERE/VERSION" 2>/dev/null || echo '?')"
echo "╚══════════════════════════════════════════════════════════════╝"
echo ""
echo "REQUIRED (installed/verified first):"
echo " • Essential CLI packages: net-tools, git, curl, wget, htop, tree,"
echo " ncdu, zip/unzip, jq, rsync, and glow (markdown reader)"
echo " • Docker presence check (needed by all containerized services)"
echo ""
echo "Then you'll get a category menu to pick optional services."
echo ""
PROCEED=""
prompt_yn "Proceed with the required setup? (y/n):" "y" PROCEED
if [ "$PROCEED" != "y" ] && [ "$PROCEED" != "Y" ]; then
echo "Cancelled. Nothing was changed."
exit 0
fi
# 2) Run required.
run_service base
if ! command -v docker >/dev/null 2>&1; then
log_warning "Docker is not installed. Containerized services need it."
echo " Install with: curl -fsSL https://get.docker.com | sh"
fi
# 3) Offer Caddy first (most services proxy through it).
if [ -n "${SERVICE_GROUP[caddy]:-}" ] && ! is_installed caddy; then
echo ""
OFFER_CADDY=""
prompt_yn "Install Caddy now? It's the reverse proxy most services use. (y/n):" "y" OFFER_CADDY
[ "$OFFER_CADDY" = "y" ] || [ "$OFFER_CADDY" = "Y" ] && run_service caddy
fi
# 4) Category menu loop: pick a category → checklist → install → back to menu.
have_whiptail=false
command -v whiptail >/dev/null 2>&1 && have_whiptail=true
while true; do
mapfile -t CATS < <(groups_present)
if [ "$have_whiptail" = true ]; then
cat_items=()
for g in "${CATS[@]}"; do
n=$(services_in_group "$g" | wc -l)
cat_items+=("$g" "$n service(s)")
done
cat_items+=("DONE" "Finish and exit")
CHOSEN_CAT=$(whiptail --title "Service Categories" --menu \
"Pick a category (services you install come back here):" 22 70 14 \
"${cat_items[@]}" 3>&1 1>&2 2>&3) || break
else
echo ""; echo "Categories:"; i=1
for g in "${CATS[@]}"; do echo " $i) $g"; i=$((i+1)); done
echo " d) Done"
read -rp "Pick a category [d]: " pick
[ "$pick" = "d" ] || [ -z "$pick" ] && break
CHOSEN_CAT="${CATS[$((pick-1))]:-}"
[ -z "$CHOSEN_CAT" ] && { echo "Invalid."; continue; }
fi
[ "$CHOSEN_CAT" = "DONE" ] && break
mapfile -t SVCS < <(services_in_group "$CHOSEN_CAT")
SELECTED=()
if [ "$have_whiptail" = true ]; then
svc_items=()
for name in "${SVCS[@]}"; do
tag="${SERVICE_DESC[$name]}"
is_installed "$name" && tag="$tag [installed]"
svc_items+=("$name" "$tag" "OFF")
done
CHOICE=$(whiptail --title "${CHOSEN_CAT^^}" --checklist \
"Space to select, Enter to install. Already-installed are marked:" 22 78 14 \
"${svc_items[@]}" 3>&1 1>&2 2>&3) || continue
eval "SELECTED=($CHOICE)"
else
echo ""; echo "${CHOSEN_CAT^^}:"
for name in "${SVCS[@]}"; do
m=""; is_installed "$name" && m=" [installed]"
printf " %-16s %s%s\n" "$name" "${SERVICE_DESC[$name]}" "$m"
done
read -rp "Enter service names to install (space-separated, blank to go back): " -a SELECTED
fi
for name in "${SELECTED[@]}"; do run_service "$name"; done
done
echo ""
log_success "Done. Re-run 'sudo ./setup.sh' any time to add more."