#!/bin/sh
# Configure boot-time enable/disable posture for n-OS-tr services.
set -eu

# Disable the Debian default site so it doesn't conflict with ours.
rm -f /etc/nginx/sites-enabled/default

# Enable our site symlink only. Runtime nginx startup is user-selected in TUI.
ln -sf /etc/nginx/sites-available/n-os-tr.conf /etc/nginx/sites-enabled/n-os-tr.conf

# TTY handoff: identity TUI owns tty1 before getty.
systemctl disable getty@tty1.service || true

# Always-on boot pipeline.
systemctl enable n-os-tr-firstboot.service
systemctl enable nostr-id.service || true
systemctl enable nostr-id-tui.service

# Explicitly keep optional services disabled at boot.
for unit in \
    c-relay.service \
    ginxsom.service \
    fips.service \
    fips-dns.service \
    nginx.service \
    nostr-config-loader.service \
    nostr-config-writer.service \
    ssh.service \
    tor.service
 do
    systemctl disable "$unit" 2>/dev/null || true
 done

# Apply preset policy for any additional units.
systemctl preset-all --preset-mode=enable-only 2>/dev/null || true
