#!/bin/bash
# /etc/rc.d/booyp-services

. /etc/init.d/functions

update_bootsplash() {
	case "$1" in
		network)
			progressbar 60
			;;
		apmd)
			;;
		acpid)
			;;
		xfs)
			progressbar 80
			;;
		messagebus)
			;;
		haldaemon)
			progressbar 90
			;;
	esac	
	return 0
}

SERVICES="network apmd acpid xfs messagebus haldaemon"
CMDLINE="$(cat /proc/cmdline)"
RHGB=""
SPLASH_SILENT=""
strstr "$CMDLINE" "rhgb" && RHGB="yes"
strstr "$CMDLINE" "splash=silent" && SPLASH_SILENT="yes"

for subsys in $SERVICES ; do
        [ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
                && continue

        # If we're in confirmation mode, get user confirmation
        if [ -f /var/run/confirm ]; then
                confirm $subsys
                test $? = 1 && continue
        fi
        [ -n "$RHGB" ] && update_boot_stage "$subsys"
	[ -n "$SPLASH_SILENT" ] && update_bootsplash "$subsys"
	if egrep -q "(daemon |action |success |failure )" /etc/init.d/$i 2>/dev/null \
                || [ "$subsys" = "single" -o "$subsys" = "local" ]; then
		/etc/init.d/$subsys start
	else
        	action $"Starting $subsys: " /etc/init.d/$subsys start
	fi
done
rm -f /var/run/confirm
[ -n "$SPLASH_SILENT" ] && progressbar 100 && echo "verbose" > /proc/splash
