generated from ztimson/template
Patched installer
This commit is contained in:
+69
-32
@@ -3,7 +3,7 @@ set -Eeuo pipefail
|
||||
|
||||
# OpsBox bootstrap + installer. Keep the Git URL in one place.
|
||||
OPSBOX_GIT_REPO="${OPSBOX_GIT_REPO:-https://git.zakscode.com/ztimson/opsbox.git}"
|
||||
OPSBOX_VERSION="1.1.0"
|
||||
OPSBOX_VERSION="1.1.1"
|
||||
OPSBOX_DIR="${OPSBOX_DIR:-}"
|
||||
CONFIG_DIR="/etc/opsbox"
|
||||
STATE_FILE="$CONFIG_DIR/selections"
|
||||
@@ -1207,41 +1207,85 @@ CONF
|
||||
bash "$TMP_DIR/fallback-ap.sh"
|
||||
}
|
||||
|
||||
install_vnc() {
|
||||
local session="${XDG_SESSION_TYPE:-}"
|
||||
if [[ -z "$session" ]]; then
|
||||
if [[ -n "${WAYLAND_DISPLAY:-}" ]]; then session=wayland
|
||||
elif [[ -n "${DISPLAY:-}" ]]; then session=x11
|
||||
fi
|
||||
force_headless_display() {
|
||||
local res="${VNC_RESOLUTION:-1920x1080}" cmd=/boot/firmware/cmdline.txt
|
||||
[[ -f "$cmd" ]] || cmd=/boot/cmdline.txt
|
||||
if [[ ! -f "$cmd" ]]; then
|
||||
warn "No cmdline.txt found; could not force a virtual display."
|
||||
return 0
|
||||
fi
|
||||
if [[ "$session" == wayland ]] || grep -qi 'wayland\|labwc' /etc/os-release 2>/dev/null; then
|
||||
apt_install wayvnc || return 1
|
||||
mkdir -p /etc/wayvnc
|
||||
if [[ ! -f /etc/wayvnc/config ]]; then
|
||||
cat > /etc/wayvnc/config <<'VNC'
|
||||
if grep -q 'video=HDMI-A-1' "$cmd"; then
|
||||
log "A video=HDMI-A-1 override already exists in $cmd; leaving it alone."
|
||||
return 0
|
||||
fi
|
||||
cp -an "$cmd" "$cmd.opsbox-backup"
|
||||
sed -i "1 s/[[:space:]]*\$/ video=HDMI-A-1:${res}@60D/" "$cmd"
|
||||
log "Forced HDMI-A-1 to ${res} even when disconnected (reboot required)."
|
||||
}
|
||||
|
||||
install_vnc() {
|
||||
apt_install wayvnc || return 1
|
||||
mkdir -p /etc/wayvnc
|
||||
if [[ ! -f /etc/wayvnc/config ]]; then
|
||||
cat > /etc/wayvnc/config <<'VNC'
|
||||
use_relative_paths=true
|
||||
address=127.0.0.1
|
||||
enable_auth=false
|
||||
enable_pam=false
|
||||
relax_encryption=true
|
||||
VNC
|
||||
chmod 0600 /etc/wayvnc/config
|
||||
fi
|
||||
if has_cmd raspi-config; then raspi-config nonint do_vnc 0 || true; fi
|
||||
systemctl enable wayvnc 2>/dev/null || true
|
||||
systemctl restart wayvnc 2>/dev/null || warn "WayVNC package installed, but no system service was found. Configure it for the active desktop session."
|
||||
elif [[ "$session" == x11 ]]; then
|
||||
apt_install tigervnc-standalone-server || return 1
|
||||
warn "TigerVNC installed. Configure a per-user VNC session; no desktop login password was changed."
|
||||
else
|
||||
warn "No active graphical session detected. VNC requires a desktop (Wayland/labwc or X11); nothing was exposed."
|
||||
return 1
|
||||
chmod 0600 /etc/wayvnc/config
|
||||
fi
|
||||
if has_cmd raspi-config; then
|
||||
raspi-config nonint do_vnc 0 || warn "raspi-config could not enable VNC."
|
||||
fi
|
||||
force_headless_display
|
||||
systemctl enable wayvnc 2>/dev/null || true
|
||||
systemctl restart wayvnc 2>/dev/null || warn "WayVNC installed; it will start with the desktop session after a reboot."
|
||||
return 0
|
||||
}
|
||||
|
||||
# ---- Docker (mandatory) ---------------------------------------------------------------
|
||||
register_docker_binfmt() {
|
||||
# Register foreign CPU handlers so explicitly requested non-native images
|
||||
# (for example linux/amd64 on ARM64) can execute through QEMU.
|
||||
local unit=/etc/systemd/system/opsbox-binfmt.service
|
||||
log "Registering Docker QEMU/binfmt handlers (amd64)..."
|
||||
docker run --privileged --rm tonistiigi/binfmt:latest --install amd64 || return 1
|
||||
|
||||
[[ -e /proc/sys/fs/binfmt_misc/qemu-x86_64 ]] || {
|
||||
err "QEMU amd64 handler was not registered by binfmt_misc."
|
||||
return 1
|
||||
}
|
||||
grep -q '^enabled' /proc/sys/fs/binfmt_misc/qemu-x86_64 || {
|
||||
err "QEMU amd64 binfmt handler exists but is not enabled."
|
||||
return 1
|
||||
}
|
||||
|
||||
# Kernel binfmt registrations are lost on reboot; restore them after Docker starts.
|
||||
cat > "$unit" <<'UNIT'
|
||||
[Unit]
|
||||
Description=Register QEMU binfmt handlers for Docker
|
||||
Requires=docker.service
|
||||
After=docker.service
|
||||
Wants=network-online.target
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/docker run --privileged --rm tonistiigi/binfmt:latest --install amd64
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
UNIT
|
||||
systemctl daemon-reload || return 1
|
||||
systemctl enable opsbox-binfmt.service || return 1
|
||||
log "QEMU amd64 emulation is enabled and configured to return after reboot."
|
||||
}
|
||||
|
||||
install_docker_engine() {
|
||||
apt_install ca-certificates curl gnupg qemu-user-static rsync || return 1
|
||||
apt_install ca-certificates curl gnupg qemu-user-static binfmt-support rsync || return 1
|
||||
local existing_root=""
|
||||
if has_cmd docker; then existing_root="$(docker info --format '{{.DockerRootDir}}' 2>/dev/null || true)"; fi
|
||||
if ! has_cmd docker; then
|
||||
@@ -1273,6 +1317,7 @@ os.chmod(tmp, 0o644); os.replace(tmp, path)
|
||||
PY
|
||||
systemctl enable --now docker || return 1
|
||||
systemctl restart docker || return 1
|
||||
register_docker_binfmt || return 1
|
||||
docker network inspect opsbox_proxy >/dev/null 2>&1 || docker network create opsbox_proxy >/dev/null
|
||||
usermod -aG docker "$ADMIN_USER"
|
||||
}
|
||||
@@ -1344,11 +1389,6 @@ install_opentak() {
|
||||
local dir="$DATA_ROOT/opentak" svc
|
||||
mkdir -p "$dir"
|
||||
|
||||
# Retire the old GoATAK stack if present (its data in $DATA_ROOT/atak is left untouched).
|
||||
if [[ -f "$OPSBOX_DIR/docker/atak.yml" ]]; then
|
||||
OPSBOX_DATA_ROOT="$DATA_ROOT" docker compose --env-file "$ENV_FILE" -f "$OPSBOX_DIR/docker/atak.yml" down --remove-orphans 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# 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
|
||||
@@ -1362,9 +1402,6 @@ install_opentak() {
|
||||
env_put "$dir/.env" OPSBOX_DOMAIN "$OPSBOX_DOMAIN"
|
||||
env_put "$dir/.env" OPSBOX_SUB_OPENTAK "${OPSBOX_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" <<OVERRIDE
|
||||
services:
|
||||
${svc}:
|
||||
|
||||
Reference in New Issue
Block a user