Permalink
Browse files

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

…e/start
  • Loading branch information...
emanuele-f committed Dec 31, 2018
1 parent d34ae00 commit 057b308939820f19757a2bc5b350264bcf2de037
Showing with 27 additions and 20 deletions.
  1. +4 −10 package/rpm/pfring.spec.in
  2. +7 −3 package/ubuntu/debian/postinst
  3. +16 −7 package/ubuntu/debian/prerm
@@ -157,8 +157,7 @@ case "$1" in
# install
%if 0%{?centos_ver} == 7
/bin/systemctl daemon-reload
/bin/systemctl enable pf_ring
/bin/systemctl enable cluster
%systemd_post pf_ring.service cluster.service
%else
/sbin/chkconfig --add pf_ring
/sbin/chkconfig --add cluster
@@ -175,10 +174,10 @@ fi

/sbin/ldconfig > /dev/null 2>&1

%postun
if [ ! -f /.dockerenv ]; then
%if 0%{?centos_ver} == 7
/bin/systemctl restart pf_ring
/bin/systemctl restart cluster
%systemd_postun_with_restart pf_ring.service cluster.service "cluster@*.service"
%else
/etc/init.d/pf_ring restart
/etc/init.d/cluster restart
@@ -191,12 +190,7 @@ case "$1" in
0)
# un-install
%if 0%{?centos_ver} == 7
/bin/systemctl disable "cluster"
/bin/systemctl disable "cluster@*"
/bin/systemctl disable pf_ring
/bin/systemctl stop "cluster"
/bin/systemctl stop "cluster@*"
/bin/systemctl stop pf_ring
%systemd_preun pf_ring.service "cluster.service" "cluster@*.service"
%else
/etc/init.d/cluster stop
/etc/init.d/pf_ring stop
@@ -21,15 +21,19 @@ if [ -f /.dockerenv ]; then exit 0; fi

echo "Adding the pf_ring startup script"
if hash systemctl 2>/dev/null; then
/bin/systemctl enable pf_ring.service > /dev/null

# Migration from old-style .start
if ls /etc/pf_ring/pf_ring.start 1> /dev/null 2>&1;
then
/bin/systemctl enable pf_ring
fi

/bin/systemctl restart pf_ring
if hash deb-systemd-invoke 2>/dev/null; then
deb-systemd-invoke enable pf_ring.service > /dev/null
deb-systemd-invoke restart pf_ring
else
/bin/systemctl enable pf_ring.service > /dev/null
/bin/systemctl restart pf_ring
fi
else
update-rc.d pf_ring defaults 30 >/dev/null
update-rc.d cluster defaults 40 >/dev/null
@@ -7,13 +7,22 @@ case "$1" in
*)
if [ -f /.dockerenv ]; then exit 0; fi
echo "Stopping pf_ring.."
if grep -q systemd /proc/1/comm; then
/bin/systemctl stop pf_ring
/bin/systemctl stop "cluster"
/bin/systemctl stop "cluster@*"
/bin/systemctl disable pf_ring
/bin/systemctl disable "cluster"
/bin/systemctl disable "cluster@*"
if hash systemctl 2>/dev/null; then
if hash deb-systemd-invoke 2>/dev/null; then
deb-systemd-invoke stop pf_ring.service
deb-systemd-invoke stop "cluster.service"
deb-systemd-invoke stop "cluster@*.service"
deb-systemd-invoke disable pf_ring.service
deb-systemd-invoke disable "cluster.service"
deb-systemd-invoke disable "cluster@*.service"
else
/bin/systemctl stop pf_ring.service
/bin/systemctl stop "cluster.service"
/bin/systemctl stop "cluster@*.service"
/bin/systemctl disable pf_ring.service
/bin/systemctl disable "cluster.service"
/bin/systemctl disable "cluster@*.service"
fi
else
/etc/init.d/pf_ring stop
/etc/init.d/cluster stop

0 comments on commit 057b308

Please sign in to comment.