Rework policy-rc.d handling.
authorMichael Prokop <mika@grml.org>
Thu, 23 Dec 2010 14:53:36 +0000 (15:53 +0100)
committerMichael Prokop <mika@grml.org>
Thu, 23 Dec 2010 14:53:36 +0000 (15:53 +0100)
debian/rules
grml-policy-rc.d.8 [deleted file]
policy-rc.d [moved from grml-policy-rc.d with 50% similarity]
policy-rc.d.8 [new file with mode: 0644]
policy-rc.d.conf
zg-policy-rc.d.conf [deleted file]

index b9e4020..9a59981 100755 (executable)
@@ -15,17 +15,16 @@ build:
 clean:
        dh_testdir
        dh_testroot
-       dh_clean 
+       dh_clean
 
 install: build
        dh_testdir
        dh_testroot
-       dh_clean -k 
+       dh_clean -k
        dh_installdirs usr/sbin/ etc
 
-       install -m 755 grml-policy-rc.d    debian/grml-policyrcd/usr/sbin/grml-policy-rc.d
-       install -m 644 policy-rc.d.conf    debian/grml-policyrcd/etc/policy-rc.d.conf
-       install -m 644 zg-policy-rc.d.conf debian/grml-policyrcd/etc/zg-policy-rc.d.conf
+       install -m 755 policy-rc.d      debian/grml-policyrcd/usr/sbin/policy-rc.d
+       install -m 644 policy-rc.d.conf debian/grml-policyrcd/etc/policy-rc.d.conf
 
 # Build architecture-dependent files here.
 binary-arch: build install
@@ -35,11 +34,13 @@ binary-arch: build install
 binary-indep: build install
        dh_testdir
        dh_testroot
-       dh_installchangelogs 
+       dh_installchangelogs
        dh_installdocs
        dh_installexamples
-       dh_installman grml-policy-rc.d.8
-       dh_link
+       dh_installman policy-rc.d.8
+       # for backwards compatibility:
+       dh_link /usr/sbin/policy-rc.d /usr/sbin/grml-policy-rc.d
+       dh_link /usr/share/man/man8/policy-rc.d.8.gz /usr/share/man/man8/grml-policy-rc.d.8.gz
        dh_strip
        dh_compress
        dh_fixperms
diff --git a/grml-policy-rc.d.8 b/grml-policy-rc.d.8
deleted file mode 100644 (file)
index 13e7d44..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-.\" Filename:      grml-policy-rc.d.1
-.\" Purpose:       man page for grml-policy-rc.d
-.\" Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-.\" Bug-Reports:   see http://grml.org/bugs/
-.\" License:       This file is licensed under the GPL v2.
-.\" Latest change: Die Jul 18 00:38:45 CEST 2006 [mika]
-.\"###############################################################################
-
-.\"###############################################################
-.TH grml\-policy-rc.d 8 "2006-07-18" "grml-policy-rc.d"
-.SH "NAME"
-grml\-policy\-rc.d \- wrapper for invoke-rc.d
-.\"#######################################################
-
-.P
-This is a wrapper script for invoke-rc.d to avoid automatical
-startup of init scripts via invoke-rc.d.  It is designed to be
-used e.g. with policyrcd-script-zg2. To configure it take a look
-at /etc/policy-rc.d.conf and /etc/zg-policy-rc.d.conf.
-
-First of all make sure the package policyrcd-script-zg2
-(which provides the /usr/sbin/policy-rc.d interface) is
-installed.
-
-In policyrcd-script-zg2's configuration file named
-/etc/zg-policy-rc.d.conf the script /usr/sbin/grml-policy-rc.d is
-defined as the interface for handling invoke-rc.d's startup
-policy. grml-policy-rc.d can be configure via
-/etc/policy-rc.d.conf.
-
-By default you won't notice any differences to Debian's default
-behaviour, except that invoke-rc.d won't be executed if a chroot
-has been detected (detection: /proc is missing). If you want to
-disable automatical startup of newly installed packages (done via
-the invoke-rc.d mechanism) just set EXITSTATUS to '101' in
-/etc/policy-rc.d.conf. To restore the default behaviour set
-EXITSTATUS back to '0' in /etc/policy-rc.d.conf.
-
-.SH "BUGS"
-Probably. Please report any bugs you find and report feedback and
-suggestions to the grml-team.  See http://grml.org/bugs/ for
-further information.  Thank you!
-
-.SH "COPYRIGHT"
-Copyright \(co 2006 by the grml-team.
-.\"###### END OF FILE ##########################################################
-.\" vim:tw=60
similarity index 50%
rename from grml-policy-rc.d
rename to policy-rc.d
index 9e4340f..3964dc5 100755 (executable)
@@ -1,10 +1,9 @@
 #!/bin/sh
-# Filename:      grml-policy-rc.d
+# Filename:      policy-rc.d
 # Purpose:       interface script for invoke-rc.d (see /etc/policy-rc.d.conf)
 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
 # Bug-Reports:   see http://grml.org/bugs/
 # License:       This file is licensed under the GPL v2.
-# Latest change: Mit Okt 18 20:43:22 UTC 2006 [mika]
 ################################################################################
 
 # test for chroot
@@ -14,15 +13,35 @@ if test "$(/usr/bin/stat -c "%d/%i" /)" != "$(/usr/bin/stat -Lc "%d/%i" /proc/1/
 fi
 
 # read configuration file
-if [ -r /etc/policy-rc.d.conf ] ; then
-   . /etc/policy-rc.d.conf
+if [ -z "$POLICYRCD" ] ; then
+  if [ -r /etc/policy-rc.d.conf ] ; then
+     . /etc/policy-rc.d.conf
+  fi
 fi
 
-if [ -n "$EXITSTATUS" ]; then
-   exit "$EXITSTATUS"
+if [ -z "$POLICYRCD" ]; then
+  for file in /usr/local/sbin/policy-rc.d /etc/policy-rc.d; do
+    if [ -x "$file" ]; then
+      POLICYRCD="$file"
+      break
+    fi
+  done
+fi
+
+# if $POLICYRCD is set or either /usr/local/sbin/policy-rc.d
+# or /etc/policy-rc.d are present execute them:
+if [ -n "$POLICYRCD" ]; then
+  $POLICYRCD "$@"
+  exit $?
 else
-   # allow it
-   exit 0
+  # otherwise exit with $EXITSTATUS,
+  # being '0' by default
+  if [ -n "$EXITSTATUS" ]; then
+     exit "$EXITSTATUS"
+  else
+     # or if $EXITSTATUS isn't set just allow it
+     exit 0
+  fi
 fi
 
 ## END OF FILE #################################################################
diff --git a/policy-rc.d.8 b/policy-rc.d.8
new file mode 100644 (file)
index 0000000..5325ab8
--- /dev/null
@@ -0,0 +1,36 @@
+.\" Filename:      policy-rc.d.8
+.\" Purpose:       man page for policy-rc.d
+.\" Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
+.\" Bug-Reports:   see http://grml.org/bugs/
+.\" License:       This file is licensed under the GPL v2.
+.\"###############################################################################
+
+.\"###############################################################
+.TH policy-rc.d 8 "2010-12-23" "policy-rc.d"
+.SH "NAME"
+policy\-rc.d \- wrapper for invoke-rc.d
+.\"#######################################################
+
+.P
+This is a wrapper script for invoke-rc.d to avoid automatical
+startup of init scripts via invoke-rc.d. To configure it
+edit /etc/policy-rc.d.conf.
+
+By default you won't notice any differences to Debian's
+default behaviour, except that invoke-rc.d won't be executed
+if a chroot has been detected (detection using /proc). If
+you want to disable automatical startup of newly installed
+packages (done via the invoke-rc.d mechanism) just set
+EXITSTATUS to '101' in /etc/policy-rc.d.conf. To restore the
+default behaviour set EXITSTATUS back to '0' in
+/etc/policy-rc.d.conf.
+
+.SH "BUGS"
+Please report any problems you find and report feedback and
+suggestions to the grml-team.  See http://grml.org/bugs/ for
+further information. Thank you!
+
+.SH "COPYRIGHT"
+Copyright \(co 2006-2010 by the grml-team.
+.\"###### END OF FILE ##########################################################
+.\" vim:tw=60
index 0ab5642..9e449bc 100644 (file)
@@ -20,6 +20,9 @@
 #  106 - action not allowed. Use the returned fallback actions
 #        (which are implied to be "allowed") instead.
 
+# Do you want to execute another script?
+# POLICYRCD=/usr/local/sbin/policy-rc.d
+
 # More information:
 # http://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt
 
diff --git a/zg-policy-rc.d.conf b/zg-policy-rc.d.conf
deleted file mode 100644 (file)
index cc1d328..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-# Filename:      /etc/zg-policy-rc.d.conf
-# Purpose:       configuration file for policyrcd-script-zg2
-# Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
-# Bug-Reports:   see http://grml.org/bugs/
-# License:       This file is licensed under the GPL v2.
-# Latest change: Sam Jul 08 01:27:21 CEST 2006 [mika]
-################################################################################
-
-# We want to run /usr/sbin/grml-policy-rc.d as invoke-rc.d interface:
-POLICYRCD=/usr/sbin/grml-policy-rc.d
-
-## END OF FILE #################################################################