From b1abc6f7e81372ec407a271b5e259ab476e3f00f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sun, 13 Mar 2016 11:38:16 +0100 Subject: [PATCH] [deb] Move yunohost-firewall restart to a separate and improved function --- debian/postinst | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/debian/postinst b/debian/postinst index 4113f7661..513d9bf35 100644 --- a/debian/postinst +++ b/debian/postinst @@ -15,22 +15,39 @@ do_configure() { yunohost service regenconf # restart yunohost-firewall if it's running - if service yunohost-firewall status >/dev/null; then - update-rc.d yunohost-firewall defaults >/dev/null - [ -d /run/systemd/system ] \ - && systemctl --system daemon-reload >/dev/null || true - echo "Restarting yunohost-firewall..." - invoke-rc.d yunohost-firewall restart || true - else - echo "Service yunohost-firewall is not running, you should " \ - "consider to start it by doing 'service yunohost-firewall start'." - fi + service yunohost-firewall status >/dev/null \ + && restart_yunohost_firewall \ + || echo "Service yunohost-firewall is not running, you should " \ + "consider to start it by doing 'service yunohost-firewall start'." fi # update PAM configs pam-auth-update --package } +restart_yunohost_firewall() { + echo "Restarting YunoHost firewall..." + + if [ -x /etc/init.d/yunohost-firewall ]; then + update-rc.d yunohost-firewall defaults >/dev/null || true + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + else + invoke-rc.d yunohost-firewall start >/dev/null || true + fi + fi + + deb-systemd-helper unmask yunohost-firewall.service >/dev/null || true + if deb-systemd-helper --quiet was-enabled yunohost-firewall.service; then + deb-systemd-helper enable yunohost-firewall.service >/dev/null || true + fi + deb-systemd-helper update-state yunohost-firewall.service >/dev/null || true + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + deb-systemd-invoke try-restart yunohost-firewall.service >/dev/null || true + fi +} + # summary of how this script can be called: # * `configure' # * `abort-upgrade'