aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Griffin <aaronmgriffin@gmail.com>2009-07-30 09:49:49 -0700
committerAaron Griffin <aaronmgriffin@gmail.com>2009-07-30 09:49:49 -0700
commit7f1bd75ee6aaffddf47e704c46fbab5396b7dd19 (patch)
treec8ec12a122e5f8102e3d29a627cfac2e111d4e25
parente97ca08b2acabd6b2f327b44aa03670df929b770 (diff)
downloadinitscripts-7f1bd75ee6aaffddf47e704c46fbab5396b7dd19.tar.xz
Shutdown non-rc.conf daemons first
Flip the order in which daemons are shutdown. First we scan for all daemons that are NOT in rc.conf and shut those down (order is based on ls, so it is dependent on LC_COLLATE). Afterwards, we shut down all daemons in rc.conf, in order Signed-off-by: Aaron Griffin <aaronmgriffin@gmail.com>
-rw-r--r--functions14
-rwxr-xr-xrc.shutdown16
2 files changed, 23 insertions, 7 deletions
diff --git a/functions b/functions
index 1d51345..f84fb5e 100644
--- a/functions
+++ b/functions
@@ -130,6 +130,20 @@ status() {
fi
}
+# usage : in_array( $needle, $haystack )
+# return : 0 - found
+# 1 - not found
+# Copied from makepkg
+in_array() {
+ local needle=$1; shift
+ [ -z "$1" ] && return 1 # Not Found
+ local item
+ for item in "$@"; do
+ [ "$item" = "$needle" ] && return 0 # Found
+ done
+ return 1 # Not Found
+}
+
# daemons:
add_daemon() {
diff --git a/rc.shutdown b/rc.shutdown
index 96611b7..1e1c6bf 100755
--- a/rc.shutdown
+++ b/rc.shutdown
@@ -23,7 +23,15 @@ if [ -x /etc/rc.local.shutdown ]; then
fi
if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
- # Shutdown daemons
+ # Find daemons NOT in the DAEMONS array. Shut these down first
+ if [ -d /var/run/daemons ]; then
+ for daemon in $(/bin/ls -1t /var/run/daemons); do
+ if ! in_array $daemon ${DAEMONS}; then
+ stop_daemon $daemon
+ fi
+ done
+ fi
+ # Shutdown daemons in reverse order
let i=${#DAEMONS[@]}-1
while [ $i -ge 0 ]; do
if [ "${DAEMONS[$i]:0:1}" != '!' ]; then
@@ -31,12 +39,6 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then
fi
let i=i-1
done
- # find any leftover daemons and shut them down in reverse order
- if [ -d /var/run/daemons ]; then
- for daemon in $(/bin/ls -1t /var/run/daemons); do
- stop_daemon $daemon
- done
- fi
fi
# Terminate all processes