From cfabb85924f35c636550609b332d088aaae9941f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20B=C3=A4chler?= Date: Tue, 25 Aug 2009 12:57:02 +0200 Subject: Implement a hook-system that allows to add custom code to the initscripts at certain places A function add_hook can be called from functions.d to register a hook function. The existing hooks are based on suggestions from Michael Towers (larch) and on the implementation of initscripts-extras-fbsplash which currently uses the strings passed to stat_busy and stat_done for this. More hooks can be added if requested. The implementation uses associative arrays and will thus only work with bash 4 or later --- rc.single | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'rc.single') diff --git a/rc.single b/rc.single index 50b7cfb..d72e95b 100755 --- a/rc.single +++ b/rc.single @@ -6,6 +6,8 @@ . /etc/rc.conf . /etc/rc.d/functions +run_hook start rc.single + if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then # Find daemons NOT in the DAEMONS array. Shut these down first if [ -d /var/run/daemons ]; then @@ -26,6 +28,8 @@ if [ "$PREVLEVEL" = "3" -o "$PREVLEVEL" = "5" ]; then fi if [ "$PREVLEVEL" != "N" ]; then + run_hook prekillall rc.single + # Terminate all processes stat_busy "Sending SIGTERM To Processes" /sbin/killall5 -15 &> /dev/null @@ -37,10 +41,14 @@ if [ "$PREVLEVEL" != "N" ]; then /bin/sleep 1 stat_done + run_hook postkillall rc.single + stat_busy "Starting UDev Daemon" /sbin/udevd --daemon stat_done + run_hook udevlaunched rc.single + # Trigger udev uevents if /bin/pidof -o %PPID /sbin/udevd >/dev/null; then stat_busy "Triggering UDev uevents" @@ -55,6 +63,8 @@ if [ "$PREVLEVEL" != "N" ]; then stat_done fi + run_hook udevsettled rc.single + # try syslog-NG first, then fall back to good ol' syslogd if [ -x /etc/rc.d/syslog-ng ]; then /etc/rc.d/syslog-ng start @@ -64,6 +74,8 @@ if [ "$PREVLEVEL" != "N" ]; then fi fi +run_hook end rc.single + if [ "$RUNLEVEL" = "1" ]; then printsep printhl "Entering single-user mode..." -- cgit v1.2.3