mirror of
https://github.com/juanfont/headscale.git
synced 2026-11-19 11:57:07 +09:00
packaging: start headscale only with a configuration it accepts
postinst starts or restarts headscale only when check config passes. Updates #1926
This commit is contained in:
1 parent
e37bb3f3a5
commit
73ef19c0ab
1 file changed
+21
-3
+21
-3
@@ -40,10 +40,28 @@ case "$1" in
|
||||
# Bounce service
|
||||
if [ -d /run/systemd/system ]; then
|
||||
systemctl --system daemon-reload >/dev/null || true
|
||||
if [ -n "$2" ]; then
|
||||
deb-systemd-invoke restart "$HEADSCALE_SERVICE" >/dev/null || true
|
||||
# Check what the unit would load: its user, working directory and
|
||||
# HOME, and no HEADSCALE_* variables from this shell. A rejected
|
||||
# configuration is not restarted, so an upgraded headscale keeps the
|
||||
# previous version until something else restarts it.
|
||||
if (cd "$HEADSCALE_HOME_DIR" && setpriv --reuid="$HEADSCALE_USER" --regid="$HEADSCALE_GROUP" --init-groups env -i HOME="$HEADSCALE_HOME_DIR" /usr/bin/headscale check config) >/dev/null; then
|
||||
if [ -n "$2" ]; then
|
||||
deb-systemd-invoke restart "$HEADSCALE_SERVICE" >/dev/null || true
|
||||
else
|
||||
deb-systemd-invoke start "$HEADSCALE_SERVICE" >/dev/null || true
|
||||
fi
|
||||
else
|
||||
deb-systemd-invoke start "$HEADSCALE_SERVICE" >/dev/null || true
|
||||
if [ -n "$2" ]; then
|
||||
echo 'headscale was not restarted after the upgrade: its configuration does not pass "headscale check config" (errors above).' >&2
|
||||
echo 'A running headscale keeps the previous version only until it restarts: needrestart after apt, a reboot or a crash starts this version, which refuses the configuration.' >&2
|
||||
else
|
||||
echo 'headscale was not started: its configuration does not pass "headscale check config" (errors above).' >&2
|
||||
fi
|
||||
echo 'Fix what it names in /etc/headscale/config.yaml; a new install needs server_url.' >&2
|
||||
echo '"headscale generate config --minimal" prints the keys every server must set.' >&2
|
||||
echo 'Then run: sudo systemctl restart headscale' >&2
|
||||
echo 'The check does not see "systemctl edit" drop-ins (variables, an EnvironmentFile, or an ExecStart that points at another config);' >&2
|
||||
echo "if headscale's configuration is set there, start it yourself." >&2
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
|
||||
Reference in new issue
Block a user