3964dc57a1d954400800a75e11bce862c64a00cd
[grml-policyrcd.git] / policy-rc.d
1 #!/bin/sh
2 # Filename:      policy-rc.d
3 # Purpose:       interface script for invoke-rc.d (see /etc/policy-rc.d.conf)
4 # Authors:       grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports:   see http://grml.org/bugs/
6 # License:       This file is licensed under the GPL v2.
7 ################################################################################
8
9 # test for chroot
10 if test "$(/usr/bin/stat -c "%d/%i" /)" != "$(/usr/bin/stat -Lc "%d/%i" /proc/1/root 2>/dev/null)" ; then
11    # notify invoke-rc.d that nothing should be done -- we are in a chroot
12    exit 101
13 fi
14
15 # read configuration file
16 if [ -z "$POLICYRCD" ] ; then
17   if [ -r /etc/policy-rc.d.conf ] ; then
18      . /etc/policy-rc.d.conf
19   fi
20 fi
21
22 if [ -z "$POLICYRCD" ]; then
23   for file in /usr/local/sbin/policy-rc.d /etc/policy-rc.d; do
24     if [ -x "$file" ]; then
25       POLICYRCD="$file"
26       break
27     fi
28   done
29 fi
30
31 # if $POLICYRCD is set or either /usr/local/sbin/policy-rc.d
32 # or /etc/policy-rc.d are present execute them:
33 if [ -n "$POLICYRCD" ]; then
34   $POLICYRCD "$@"
35   exit $?
36 else
37   # otherwise exit with $EXITSTATUS,
38   # being '0' by default
39   if [ -n "$EXITSTATUS" ]; then
40      exit "$EXITSTATUS"
41   else
42      # or if $EXITSTATUS isn't set just allow it
43      exit 0
44   fi
45 fi
46
47 ## END OF FILE #################################################################