Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/issue 548 #667

Merged
merged 3 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the story behind this todo comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the default behavior for this shard of debhelper code, so commented out for now. Per previous discussions, service restart should be handled via some other mechanism, like debconf in the future. OpenZiti might transport config management tooling, and automatic restarts can potentially break transport during a config management operation.

# if [ -n "$2" ]; then
# deb-systemd-invoke try-restart @SYSTEMD_UNIT_FILE_NAME@ >/dev/null || true
# fi
fi
fi
# End copied section
Comment on lines +72 to 82
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the only real change. The rest was normalizing tabs to spaces for copied sections to avoid weird visual artifacts in spacing.


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