Initscripts now export their state to an arbitrary boot logging/probing program. This opens up the possibility for advanced boot profiling, among other interesting uses. --- functions | 17 +++++++++++++++++ rc.conf | 1 - rc.multi | 6 ++++++ rc.shutdown | 2 ++ rc.sysinit | 10 ++++++++++ 5 files changed, 35 insertions(+), 1 deletions(-) diff --git a/functions b/functions index 8b5ecf1..ebde3ca 100644 --- a/functions +++ b/functions @@ -3,6 +3,19 @@ # functions # +# source boot monitoring functions and settings +if [ -x "${BOOT_PROBE}" ]; then + source /etc/`basename ${BOOT_PROBE}`.conf &>/dev/null + source /etc/rc.d/`basename ${BOOT_PROBE}`-functions + emit_state() { + ${BOOT_PROBE} $@ + } +else + emit_state() { + : + } +fi + # width: STAT_COL=$(stty size) @@ -81,6 +94,7 @@ stat_bkgd() { echo -ne "$C_OTHER$PREFIX_REG $C_MAIN$1$C_CLEAR " deltext echo -ne " $C_OTHER[${C_BKGD}BKGD$C_OTHER]$C_CLEAR " + emit_state bkgd } stat_busy() { @@ -88,6 +102,7 @@ stat_busy() { echo -ne "${SAVE_POSITION}" deltext echo -ne " $C_OTHER[${C_BUSY}BUSY$C_OTHER]$C_CLEAR " + emit_state busy } stat_append() { @@ -99,11 +114,13 @@ stat_append() { stat_done() { deltext echo -e " $C_OTHER[${C_DONE}DONE$C_OTHER]$C_CLEAR " + emit_state done } stat_fail() { deltext echo -e " $C_OTHER[${C_FAIL}FAIL$C_OTHER]$C_CLEAR " + emit_state fail } stat_die() { diff --git a/rc.conf b/rc.conf index 43a597e..167b65f 100644 --- a/rc.conf +++ b/rc.conf @@ -89,5 +89,4 @@ ROUTES=(!gateway) # DAEMONS=(syslog-ng network netfs crond) - # End of file diff --git a/rc.multi b/rc.multi index 8050e98..5c4a3b3 100755 --- a/rc.multi +++ b/rc.multi @@ -6,6 +6,8 @@ . /etc/rc.conf . /etc/rc.d/functions +emit_state multi_startup + # Load sysctl variables if sysctl.conf is present [ -r /etc/sysctl.conf ] && /sbin/sysctl -q -p &>/dev/null @@ -14,9 +16,11 @@ for daemon in "${DAEMONS[@]}"; do if [ "$daemon" = "${daemon#!}" ]; then if [ "$daemon" = "${daemon#@}" ]; then /etc/rc.d/$daemon start + emit_state multi_progress else stat_bkgd "Starting ${daemon:1}" (/etc/rc.d/${daemon:1} start) &>/dev/null & + emit_state multi_progress_bkgd fi fi done @@ -25,4 +29,6 @@ if [ -x /etc/rc.local ]; then /etc/rc.local fi +emit_state exit + # vim: set ts=2 noet: diff --git a/rc.shutdown b/rc.shutdown index 19cb00f..a1771a8 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -6,6 +6,8 @@ . /etc/rc.conf . /etc/rc.d/functions +emit_state shutdown + # avoid staircase effect /bin/stty onlcr diff --git a/rc.sysinit b/rc.sysinit index f4729bf..6559f3f 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -6,6 +6,8 @@ . /etc/rc.conf . /etc/rc.d/functions +emit_state boot + echo " " printhl "Arch Linux $C_OTHER(${C_H2}Core Dump$C_OTHER)\n" printhl "${C_H2}http://www.archlinux.org" @@ -88,6 +90,9 @@ if [ -d /sys/class/net/lo ]; then fi fi +# tell probing programs to get ready +emit_state init + # If using an encrypted root fs, we should find the root dev in the initrd # FIXME: obsoleted by initramfs and udev if [ -e /initrd/dev/mapper/root ]; then @@ -232,6 +237,8 @@ if [ -x /sbin/fsck ]; then fsckret=$? if [ ${fsckret} -gt 1 ]; then stat_fail + # oh crap. tell probers not to hide anything. + emit_state verbose if [ $((${fsckret}&2)) -eq 2 ]; then echo echo "********************** REBOOT REQUIRED *********************" @@ -399,5 +406,8 @@ fi # Screen blanks after 15 minutes idle time /usr/bin/setterm -blank 15 +# set things up for probing in rc.multi +emit_state multi + # End of file # vim: set ts=2 noet: -- 1.5.3.4