From 5664efad1dd3692ae08cb84cc16eb3d80224d4a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Sat, 12 Mar 2016 22:33:36 +0100 Subject: [PATCH] [fix] Attempt to improve services management in Debian packaging --- debian/postinst | 24 +++++++++++++++++------- debian/postrm | 12 ++++++++++++ debian/prerm | 5 +++-- debian/yunohost-api.init | 0 debian/yunohost-firewall.init | 0 5 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 debian/postrm mode change 100755 => 100644 debian/yunohost-api.init mode change 100755 => 100644 debian/yunohost-firewall.init diff --git a/debian/postinst b/debian/postinst index f3374527..4113f766 100644 --- a/debian/postinst +++ b/debian/postinst @@ -15,10 +15,16 @@ do_configure() { yunohost service regenconf # restart yunohost-firewall if it's running - service yunohost-firewall status > /dev/null \ - && service yunohost-firewall restart \ - || echo "Service yunohost-firewall is not running, you should " \ - "consider to start it by doing 'service yunohost-firewall start'." + 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 fi # update PAM configs @@ -48,10 +54,14 @@ case "$1" in ;; esac -# Enable and start yunohost-api service for non-systemd system -if [ -x /etc/init.d/yunohost-api ] && [ ! -d /run/systemd/system ]; then +# Enable and start yunohost-api sysv service +if [ -x /etc/init.d/yunohost-api ]; then update-rc.d yunohost-api defaults >/dev/null - invoke-rc.d yunohost-api start || exit $? + if [ -d /run/systemd/system ]; then + systemctl --system daemon-reload >/dev/null || true + else + invoke-rc.d yunohost-api start || exit $? + fi fi #DEBHELPER# diff --git a/debian/postrm b/debian/postrm new file mode 100644 index 00000000..2a711b13 --- /dev/null +++ b/debian/postrm @@ -0,0 +1,12 @@ +#!/bin/bash + +set -e + +if [ "$1" = "purge" ]; then + update-rc.d yunohost-api remove >/dev/null + update-rc.d yunohost-firewall remove >/dev/null +fi + +#DEBHELPER# + +exit 0 diff --git a/debian/prerm b/debian/prerm index 01aee685..85f17dde 100644 --- a/debian/prerm +++ b/debian/prerm @@ -2,8 +2,9 @@ set -e -if [ -x "/etc/init.d/yunohost-firewall" ]; then - invoke-rc.d yunohost-firewall stop || exit $? +if [ -x /etc/init.d/yunohost-api ] && ! [ -d /run/systemd/system ]; then + invoke-rc.d yunohost-api stop || exit $? + invoke-rc.d yunohost-firewall stop || true fi #DEBHELPER# diff --git a/debian/yunohost-api.init b/debian/yunohost-api.init old mode 100755 new mode 100644 diff --git a/debian/yunohost-firewall.init b/debian/yunohost-firewall.init old mode 100755 new mode 100644