Skip to content

Commit

Permalink
Rework check for init/systemd presence
Browse files Browse the repository at this point in the history
  • Loading branch information
cardigliano committed Jun 1, 2023
1 parent 4990455 commit 1abfff5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
6 changes: 5 additions & 1 deletion kernel/pfring-dkms-mkdeb/debian/postinst
Expand Up @@ -46,7 +46,11 @@ service_restart () {

case "$1" in
configure)
if [ -f /.dockerenv ]; then exit 0; fi
CMDLINE=$(tr -d '\0' < /proc/1/cmdline)
if [ ! -z "${CMDLINE##*system*}" ] && [ ! -z "${CMDLINE##*init*}" ]; then
exit 0 # no init/systemd (in a container)
fi

dkms_configure
service_restart
;;
Expand Down
9 changes: 6 additions & 3 deletions package/rpm/pfring.spec.in
Expand Up @@ -175,7 +175,8 @@ case "$1" in
esac

%post
if [ ! -f /.dockerenv ]; then
CMDLINE=$(tr -d '\0' < /proc/1/cmdline)
if [ -z "${CMDLINE##*system*}" ] || [ -z "${CMDLINE##*init*}" ]; then # init/systemd (not a container)
case "$1" in
1)
# install
Expand All @@ -199,7 +200,8 @@ fi
/sbin/ldconfig > /dev/null 2>&1

%postun
if [ ! -f /.dockerenv ]; then
CMDLINE=$(tr -d '\0' < /proc/1/cmdline)
if [ -z "${CMDLINE##*system*}" ] || [ -z "${CMDLINE##*init*}" ]; then # init/systemd (not a container)
%if 0%{?centos_ver} != 6
%systemd_postun_with_restart pf_ring.service cluster.service "cluster@*.service"
%else
Expand All @@ -209,7 +211,8 @@ if [ ! -f /.dockerenv ]; then
fi

%preun
if [ ! -f /.dockerenv ]; then
CMDLINE=$(tr -d '\0' < /proc/1/cmdline)
if [ -z "${CMDLINE##*system*}" ] || [ -z "${CMDLINE##*init*}" ]; then # init/systemd (not a container)
case "$1" in
0)
# un-install
Expand Down
6 changes: 5 additions & 1 deletion package/ubuntu/debian/prerm
Expand Up @@ -5,7 +5,11 @@ case "$1" in
# This is an upgrade, do not disable the services
;;
*)
if [ -f /.dockerenv ]; then exit 0; fi
CMDLINE=$(tr -d '\0' < /proc/1/cmdline)
if [ ! -z "${CMDLINE##*system*}" ] && [ ! -z "${CMDLINE##*init*}" ]; then
exit 0 # no init/systemd (in a container)
fi

echo "Stopping pf_ring.."
if hash systemctl 2>/dev/null; then
if hash deb-systemd-invoke 2>/dev/null; then
Expand Down

0 comments on commit 1abfff5

Please sign in to comment.