Skip to content

Commit

Permalink
Merge pull request #667 from openziti/bugfix/issue-548
Browse files Browse the repository at this point in the history
reload services in debian post script
  • Loading branch information
scareything committed May 24, 2023
2 parents 67f75f1 + 50d7183 commit de17032
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
35 changes: 23 additions & 12 deletions programs/ziti-edge-tunnel/package/deb/postinst.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ if [ "$1" = "configure" ]; then
override_dir="@SYSTEMD_UNIT_DIR@/@[email protected]"
mkdir -p "${override_dir}/"
( echo '[Service]'; echo "User=root" ) > "${override_dir}/10-run-as-root.conf"
# todo ok to `systemctl daemon-reload` here?
fi
fi

Expand All @@ -54,19 +53,31 @@ fi

# Copied from https://github.com/Debian/debhelper/blob/master/autoscripts/postinst-systemd-dont-enable
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if deb-systemd-helper debian-installed @SYSTEMD_UNIT_FILE_NAME@; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
if deb-systemd-helper debian-installed @SYSTEMD_UNIT_FILE_NAME@; then
# This will only remove masks created by d-s-h on package removal.
deb-systemd-helper unmask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true

if deb-systemd-helper --quiet was-enabled @SYSTEMD_UNIT_FILE_NAME@; then
# Create new symlinks, if any.
deb-systemd-helper enable @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
fi
if deb-systemd-helper --quiet was-enabled @SYSTEMD_UNIT_FILE_NAME@; then
# Create new symlinks, if any.
deb-systemd-helper enable @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
fi

# Update the statefile to add new symlinks (if any), which need to be cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
# End copied section

# Update the statefile to add new symlinks (if any), which need to be cleaned
# up on purge. Also remove old symlinks.
deb-systemd-helper update-state @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
# Copied from https://github.com/Debian/debhelper/blob/master/autoscripts/postinst-systemd-restartnostart
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
# TODO: Handle service restart
# if [ -n "$2" ]; then
# deb-systemd-invoke try-restart @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
# fi
fi
fi
# End copied section

Expand Down
18 changes: 9 additions & 9 deletions programs/ziti-edge-tunnel/package/deb/postrm.in
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# Copied from https://github.com/Debian/debhelper/blob/master/autoscripts/postrm-systemd
if [ "$1" = "remove" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper mask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
fi

if [ "$1" = "purge" ]; then
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
deb-systemd-helper unmask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
if [ -x "/usr/bin/deb-systemd-helper" ]; then
deb-systemd-helper purge @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
deb-systemd-helper unmask @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
fi
# End copied seciton

if [ -L @SYSTEMD_UNIT_DIR@/@SYSTEMD_UNIT_FILE_NAME@ ]; then
unlink @SYSTEMD_UNIT_DIR@/@SYSTEMD_UNIT_FILE_NAME@
fi

# Copied from https://github.com/Debian/debhelper/blob/master/autoscripts/postrm-systemd-restart-only
# Copied from https://github.com/Debian/debhelper/blob/master/autoscripts/postrm-systemd-reload-only
if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload >/dev/null || true
systemctl --system daemon-reload >/dev/null || true
fi
# End copied section

Expand Down
2 changes: 1 addition & 1 deletion programs/ziti-edge-tunnel/package/deb/prerm.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Coped from https://github.com/Debian/debhelper/blob/master/autoscripts/prerm-systemd
if [ -d /run/systemd/system ] && [ "$1" = "remove" ]; then
deb-systemd-invoke stop @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
deb-systemd-invoke stop @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
fi
# End copied section

0 comments on commit de17032

Please sign in to comment.