Browse files

Use systemd helpers to honor system wide preferences on service enabl…


Also fix services being started after upgrade even if they were disabled but config existed
  • Loading branch information...
emanuele-f committed Dec 31, 2018
1 parent 1e8b618 commit a96237f83d143591fa7abe832ead0a8b1ca995fd
Showing with 26 additions and 30 deletions.
  1. +12 −8 packages/debian/debian/postinst
  2. +6 −4 packages/debian/debian/prerm
  3. +8 −18 packages/rpm/
@@ -27,17 +27,21 @@ systemctl daemon-reload
systemctl reset-failed

# Enable edge
if [ -f /etc/n2n/edge.conf ]; then
echo "Enabling n2n edge..."
systemctl enable edge
systemctl restart edge
if systemctl -q is-active edge; then
# only restart edge if it's already running
echo "Restarting n2n edge..."
deb-systemd-invoke restart edge

# Restart specific services if already running
deb-systemd-invoke enable 'edge@*.service' 'edge-ntopng@*.service'
deb-systemd-invoke restart 'edge@*.service' 'edge-ntopng@*.service'

# Enable supernode
if [ -f /etc/n2n/supernode.conf ]; then
echo "Enabling n2n supernode..."
systemctl enable supernode
systemctl restart supernode
if systemctl -q is-active supernode; then
# only restart supernode if it's already running
echo "Restarting n2n supernode..."
deb-systemd-invoke restart supernode

exit 0
@@ -7,12 +7,14 @@ if [ -f /.dockerenv ]; then exit 0; fi
. /usr/share/debconf/confmodule

case "$1" in

systemctl stop edge
systemctl disable edge
systemctl stop supernode
systemctl disable supernode
deb-systemd-invoke stop edge.service 'edge@*.service' 'edge-ntopng@*.service'
deb-systemd-invoke disable edge.service 'edge@*.service' 'edge-ntopng@*.service'
deb-systemd-invoke stop supernode.service
deb-systemd-invoke disable supernode.service
systemctl daemon-reload
systemctl reset-failed
@@ -70,29 +70,19 @@ rm -fr $RPM_BUILD_ROOT


if [ ! -f /.dockerenv ]; then
/bin/systemctl daemon-reload
if [ -f /etc/n2n/edge.conf ]; then
/bin/systemctl enable edge.service
/bin/systemctl restart edge.service

if [ -f /etc/n2n/supernode.conf ]; then
/bin/systemctl enable supernode.service
/bin/systemctl restart supernode.service
/bin/systemctl daemon-reload
# NOTE: do not enable any services during first installation

if [ ! -f /.dockerenv ]; then
if [ -f /etc/n2n/edge.conf ]; then
/bin/systemctl disable edge.service
/bin/systemctl stop edge.service
# possibly remove the installed services
%systemd_preun supernode.service edge.service 'edge-ntopng@*.service' 'edge@*.service'

if [ -f /etc/n2n/supernode.conf ]; then
/bin/systemctl disable supernode.service
/bin/systemctl stop supernode.service
if [ ! -f /.dockerenv ]; then
# possibly restart the running services
%systemd_postun_with_restart supernode.service edge.service 'edge-ntopng@*.service' 'edge@*.service'

0 comments on commit a96237f

Please sign in to comment.