Skip to content

The open-source AI receptionist for businesses. Answers every call, books the appointment and hands over to a person when needed. You own the code and the data.

Security updates on Debian and on servers without calls (PR 2016)

Janik1dbec967cb51
diff --git a/ops/server/README.md b/ops/server/README.md
index 36c6e325..80090e7f 100644
--- a/ops/server/README.md
+++ b/ops/server/README.md
@@ -25,9 +25,10 @@ sudo ops/server/setup.sh --dry-run # shows every file it would change, touche
| With separate voice servers, where a voice link runs: starts it again once WireGuard is up or restarted (`PartOf=wg-quick@<interface>`); only with an active voice-link firewall | `systemd/[email protected]` | when `wg-quick@<interface>` starts |
| On a voice server (an `agent` and no `api` among the compose services): its agent worker is healthy (registered with voice server 1's LiveKit) and not idle; email after 2 failures in a row and when back, with `--push-url` also a phone push. The main server's `/v1/health` does not see one voice server fail while another worker checks in | `bin/linedesk-agent-check` | every 2 minutes |
| With SIP over TLS (`docker-compose.sip-tls.yml` among the compose files): LiveKit SIP reads a renewed certificate (`scripts/deploy.sh --sip-cert`: a restart at a moment without calls, at most 10 minutes of waiting, else the next day); email when the certificate is missing or ends within 14 days | `systemd/linedesk-sip-cert.service` | daily |
-| Security updates: unattended-upgrades installs what Ubuntu's security pocket (and ESM's, with Ubuntu Pro) offers, every day; nothing from `-updates` or other repositories (Docker's own packages, Tailscale: by hand). Dependencies an upgrade leaves unused and old kernels are removed. `docker.io`, `containerd` and `runc` from Ubuntu are never upgraded automatically (that restarts Docker and ends every call). needrestart then restarts the services that still use an old library, without asking, except Docker, containerd and WireGuard. apt never reboots by itself | `etc/unattended-upgrades.conf` (`/etc/apt/apt.conf.d/52linedesk-unattended-upgrades`), `etc/needrestart.conf` (`/etc/needrestart/conf.d/linedesk.conf`), `apt-daily*.timer` | daily (Ubuntu's apt timers) |
+| Security updates: unattended-upgrades installs what Ubuntu's security pocket (and ESM's, with Ubuntu Pro; on Debian its security archive) offers, every day; nothing from `-updates` or other repositories (Docker's own packages, Tailscale: by hand). Dependencies an upgrade leaves unused and old kernels are removed. `docker.io`, `containerd` and `runc` from Ubuntu are never upgraded automatically (that restarts Docker and ends every call). needrestart then restarts the services that still use an old library, without asking, except Docker, containerd and WireGuard. apt never reboots by itself | `etc/unattended-upgrades.conf` (`/etc/apt/apt.conf.d/52linedesk-unattended-upgrades`), `etc/needrestart.conf` (`/etc/needrestart/conf.d/linedesk.conf`), `apt-daily*.timer` | daily (Ubuntu's apt timers) |
| Reboot after an update that needs it (`/var/run/reboot-required`: a new kernel, libc, systemd): only inside the window (`--reboot-window 03:30-05:00`, the default, in the server's time zone, usually UTC; `--reboot-tz America/New_York` for another; a window may cross midnight; `off`: never), only when no call is live and no deploy or apt/dpkg run is going on; else it tries again 10 minutes later, inside the window. Live calls (`linedesk-live-calls`, the same signal `scripts/deploy.sh` waits on): the database's live calls where Postgres runs; on a voice server LiveKit's rooms with a caller (on a further voice server: voice server 1's LiveKit, so it waits until no call runs on any voice server); when it cannot tell, it waits. Every decision is in the journal (`journalctl -u linedesk-reboot-if-needed`). After 7 days without a chance, one alert a day until it rebooted | `bin/linedesk-reboot-if-needed`, `bin/linedesk-live-calls`, `systemd/linedesk-reboot-if-needed.*` | every 10 minutes |
| The update state as one JSON line: `sudo linedesk-updates` (`{"host", "security_upgradable", "upgradable", "reboot_required", "reboot_required_since", "unattended_last_run", "kernel_running", "kernel_newest_installed", "uptime_s"}`), from apt's cache and files only (it fetches and changes nothing) | `bin/linedesk-updates` | by hand |
+| `--no-calls`: a server without calls (the intranet, a monitor; `LINEDESK_NO_CALLS=1` in ops.env): `linedesk-live-calls` reports 0, so a reboot after updates does not wait for a call count that never comes | `bin/linedesk-live-calls` | with the reboot check |
| `--harden-ssh`: keys only, no root login, 3 tries (refuses unless a sudo user with a full SSH key exists; checks `sshd -t` first and `sshd -T` after) | `etc/sshd-hardening.conf` | |
| `--ufw`: only SSH reaches the host's own services (Docker's published ports go past ufw; the firewalls above cover them) | | |
diff --git a/ops/server/bin/linedesk-live-calls b/ops/server/bin/linedesk-live-calls
index 86e4e1b4..8f96b2b5 100755
--- a/ops/server/bin/linedesk-live-calls
+++ b/ops/server/bin/linedesk-live-calls
@@ -12,6 +12,8 @@
# hours and rooms made before the running LiveKit started are leftovers (deploy.sh, LIN-413) and do not count.
set -u
[ -r /etc/linedesk/ops.env ] && . /etc/linedesk/ops.env
+# A server without calls (setup.sh --no-calls: the intranet, a monitor): none can be live, whatever Docker runs there.
+[ "${LINEDESK_NO_CALLS:-}" != 1 ] || { echo 0; exit 0; }
app=${LINEDESK_APP_DIR:?set LINEDESK_APP_DIR in /etc/linedesk/ops.env}
cd "$app" || exit 1
diff --git a/ops/server/etc/unattended-upgrades.conf b/ops/server/etc/unattended-upgrades.conf
index ef867bcd..164b9726 100644
--- a/ops/server/etc/unattended-upgrades.conf
+++ b/ops/server/etc/unattended-upgrades.conf
@@ -1,6 +1,7 @@
// Linedesk (ops/server/setup.sh installs this as /etc/apt/apt.conf.d/52linedesk-unattended-upgrades; edits there are
// overwritten by the next run). Read after Ubuntu's 50unattended-upgrades, so these settings win.
-// Security updates only: Ubuntu's security pocket and, where the server has Ubuntu Pro, ESM's security pockets.
+// Security updates only: Ubuntu's security pocket and, where the server has Ubuntu Pro, ESM's security pockets; on Debian
+// its security archive (archive stable-security, so it needs the pattern by codename and label).
#clear Unattended-Upgrade::Allowed-Origins;
#clear Unattended-Upgrade::Origins-Pattern;
Unattended-Upgrade::Allowed-Origins {
@@ -8,6 +9,9 @@ Unattended-Upgrade::Allowed-Origins {
"${distro_id}ESMApps:${distro_codename}-apps-security";
"${distro_id}ESM:${distro_codename}-infra-security";
};
+Unattended-Upgrade::Origins-Pattern {
+ "origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
+};
// Upgrading these restarts Docker, which ends every call: by hand, at a quiet moment (Docker's own packages from
// download.docker.com are not in the origins above anyway).
Unattended-Upgrade::Package-Blacklist {
diff --git a/ops/server/setup.sh b/ops/server/setup.sh
index c6dc1a14..e082de92 100755
--- a/ops/server/setup.sh
+++ b/ops/server/setup.sh
@@ -14,6 +14,7 @@
# --capacity-push <user@host> send the capacity samples (linedesk-capacity) there over SSH every 5 minutes
# --reboot-window <HH:MM-HH:MM|off> when a reboot after updates may happen (default 03:30-05:00), off: never
# --reboot-tz <Area/City> the window's time zone (default: the server's own, usually UTC)
+# --no-calls a server without calls (the intranet, a monitor): reboots for updates do not wait for calls
# A server with a voice link (the app server with docker-compose.voice-link.yml, voice server 1 with
# docker-compose.voice-media.yml) also gets the voice-link firewall (only the addresses in /etc/linedesk/voice-nodes.txt);
# a voice server (an agent and no API) the agent check.
@@ -21,7 +22,7 @@ set -eu
here=$(cd "$(dirname "$0")" && pwd)
app_dir=${LINEDESK_APP_DIR:-$(cd "$here/../.." && pwd)}
dry=0 cloudflare=0 harden_ssh=0 ufw=0 alert_to='' label='' monitor='' monitor_sip='' push_url='' capacity_push=''
-reboot_window='' reboot_tz=''
+reboot_window='' reboot_tz='' no_calls=''
while [ $# -gt 0 ]; do
case $1 in
--dry-run) dry=1 ;;
@@ -36,6 +37,7 @@ while [ $# -gt 0 ]; do
--capacity-push) capacity_push=${2:?--capacity-push needs user@host}; shift ;;
--reboot-window) reboot_window=${2:?--reboot-window needs HH:MM-HH:MM or off}; shift ;;
--reboot-tz) reboot_tz=${2:?--reboot-tz needs a time zone, e.g. America/New_York}; shift ;;
+ --no-calls) no_calls=1 ;;
*) sed -n '2,19p' "$0" >&2; exit 2 ;;
esac
shift
@@ -76,6 +78,7 @@ capacity_push=${capacity_push:-$(current LINEDESK_CAPACITY_PUSH)}
reboot_window=${reboot_window:-$(current LINEDESK_REBOOT_WINDOW)}
reboot_window=${reboot_window:-03:30-05:00}
reboot_tz=${reboot_tz:-$(current LINEDESK_REBOOT_TZ)}
+no_calls=${no_calls:-$(current LINEDESK_NO_CALLS)}
label=${label:-$(hostname)}
# ops.env is sourced by scripts that run as root: only plain values go in.
valid() { printf '%s\n' "$2" | grep -Eq "$3" || { echo "not a valid $1: $2" >&2; exit 1; }; }
@@ -101,6 +104,7 @@ valid "reboot window (HH:MM-HH:MM or off)" "$reboot_window" '^(off|([01][0-9]|2[
[ -z "$capacity_push" ] || echo "LINEDESK_CAPACITY_PUSH=$capacity_push"
echo "LINEDESK_REBOOT_WINDOW=$reboot_window"
[ -z "$reboot_tz" ] || echo "LINEDESK_REBOOT_TZ=$reboot_tz"
+ [ "$no_calls" != 1 ] || echo "LINEDESK_NO_CALLS=1"
} > "$tmp/ops.env"
put "$tmp/ops.env" "$ops_env" 644
diff --git a/scripts/server-updates.test.sh b/scripts/server-updates.test.sh
index 00aed370..7d9a7361 100644
--- a/scripts/server-updates.test.sh
+++ b/scripts/server-updates.test.sh
@@ -102,6 +102,12 @@ rm -f "$flag"
check "rebooted: done" none "2026-11-28 13:00"
[ ! -e "$tmp/state/alerted" ] && pass "the alert state is reset" || fail "the alert state is reset"
+echo "linedesk-live-calls"
+out=$(env -i PATH="$PATH" LINEDESK_NO_CALLS=1 LINEDESK_APP_DIR="$tmp/none" bash "$bin/linedesk-live-calls"); status=$?
+[ "$status" = 0 ] && [ "$out" = 0 ] && pass "no calls on this server: 0" || fail "no calls on this server: exit $status, '$out'"
+env -i PATH="$PATH" LINEDESK_APP_DIR="$tmp/none" bash "$bin/linedesk-live-calls" >/dev/null 2>&1
+[ "$?" = 1 ] && pass "a stack it cannot ask: cannot tell" || fail "a stack it cannot ask: cannot tell"
+
echo "linedesk-updates"
mkdir -p "$tmp/boot"
touch "$tmp/boot/vmlinuz-6.8.0-99-generic" "$tmp/boot/vmlinuz-6.8.0-151-generic" "$tmp/boot/vmlinuz-6.8.0-149-generic"