mirror of
https://github.com/ntop/n2n.git
synced 2024-10-18 15:42:49 +05:30
Use systemd helpers to honor system wide preferences on service enable/start
Also fix services being started after upgrade even if they were disabled but config existed
This commit is contained in:
parent
61887c740d
commit
b034730f19
@ -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
|
||||
fi
|
||||
|
||||
# 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
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
@ -7,12 +7,14 @@ if [ -f /.dockerenv ]; then exit 0; fi
|
||||
. /usr/share/debconf/confmodule
|
||||
|
||||
case "$1" in
|
||||
upgrade)
|
||||
;;
|
||||
|
||||
*)
|
||||
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
|
||||
;;
|
||||
|
@ -68,29 +68,19 @@ rm -fr $RPM_BUILD_ROOT
|
||||
%pre
|
||||
|
||||
%post
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
if [ -f /etc/n2n/supernode.conf ]; then
|
||||
/bin/systemctl enable supernode.service
|
||||
/bin/systemctl restart supernode.service
|
||||
fi
|
||||
/bin/systemctl daemon-reload
|
||||
# NOTE: do not enable any services during first installation
|
||||
fi
|
||||
|
||||
%preun
|
||||
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'
|
||||
fi
|
||||
|
||||
if [ -f /etc/n2n/supernode.conf ]; then
|
||||
/bin/systemctl disable supernode.service
|
||||
/bin/systemctl stop supernode.service
|
||||
fi
|
||||
%postun
|
||||
if [ ! -f /.dockerenv ]; then
|
||||
# possibly restart the running services
|
||||
%systemd_postun_with_restart supernode.service edge.service 'edge-ntopng@*.service' 'edge@*.service'
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user