summaryrefslogtreecommitdiff
path: root/functions
diff options
context:
space:
mode:
authorThomas Bächler <thomas@archlinux.org>2009-08-26 23:26:54 +0200
committerThomas Bächler <thomas@archlinux.org>2009-08-26 23:26:54 +0200
commit58fc27aaeb6d7d67cdf93997a33e0cbe4b5d7ada (patch)
tree05e9c2df6176d3f679739b7a25d047478ee6de32 /functions
parentcfabb85924f35c636550609b332d088aaae9941f (diff)
Make the hook-system a bit more usable
This patch makes the hook names unique, prefixing them all with the script name (without the 'rc.') It also removes the explicit declarations of all elements of the array, bash assumes "" if they are uninitialized
Diffstat (limited to 'functions')
-rw-r--r--functions35
1 files changed, 20 insertions, 15 deletions
diff --git a/functions b/functions
index 56b78be..5c1e6f8 100644
--- a/functions
+++ b/functions
@@ -239,26 +239,31 @@ ck_status() {
# ...
# }
# add_hook hook_name function_name
-# It's allowed to register several hook functions for the same hook
-#
-# The function takes the filename of the script that launched it as an argument
+# It is allowed to register several hook functions for the same hook
+# Is is also allowed to register the same hook function for several hooks
#
# Currently, the following hooks exist:
-# start: at the beginning of rc.{multi,shutdown,single,sysinit}
-# end: at the end of rc.{multi,single,sysinit}
-# udevlaunched: after udev has been launched in rc.sysinit and rc.single
-# udevsettled: after uevents have settled in rc.sysinit and rc.single
-# premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit
-# prekillall: before all processes are being killed in rc.shutdown and rc.single
-# postkillall: after all processes have been killed in rc.shutdown and rc.single
-# poweroff: directly before powering off in rc.shutdown
+# sysinit_start: at the beginning of rc.sysinit
+# multi_start: at the beginning of rc.multi
+# single_start: at the beginning of rc.single
+# shutdown_start: at the beginning of rc.shutdown
+# sysinit_end: at the end of rc.sysinit
+# multi_end: at the end of rc.multi
+# single_end: at the end of rc.single
+# sysinit_udevlaunched: after udev has been launched in rc.sysinit
+# single_udevlaunched: after udev has been launched in rc.single
+# sysinit_udevsettled: after uevents have settled in rc.sysinit
+# single_udevsettled: after uevents have settled in rc.single
+# sysinit_premount: before local filesystems are mounted, but after root is mounted read-write in rc.sysinit
+# shutdown_prekillall: before all processes are being killed in rc.shutdown
+# single_prekillall: before all processes are being killed in rc.single
+# shutdown_postkillall: after all processes have been killed in rc.shutdown
+# single_postkillall: after all processes have been killed in rc.single
+# shutdown_poweroff: directly before powering off in rc.shutdown
#
# Make sure to never override the add_hook and run_hook functions via functions.d
declare -A hook_funcs
-for hook in start end udevlaunched udevsettled premount prekillall postkillall poweroff; do
- hook_funcs["${hook}"]=""
-done
add_hook() {
[ -z "$1" -o -z "$2" ] && return 1
@@ -270,7 +275,7 @@ run_hook() {
[ -z "$1" ] && return 1
for func in ${hook_funcs["$1"]}; do
- ${func} "$2"
+ ${func}
done
}