# Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: /root/magellan-cvs/src/splashutils-magellan/splash-functions,v 1.2 2005-03-04 21:02:42 niro Exp $ # Author: Michal Januszewski # Maintainer: Michal Januszewski # This is file is a part of splashutils. # This is the main function that handles all events. # Accepted parameters: # svc_start # svc_stop # svc_started # svc_stopped # svc_input_begin # svc_input_end # rc_init - used to distinguish between 'boot' and 'sysinit' # rc_exit # critical splash() { local event="$1" splash_setup if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-pre" ]; then /etc/splash/${SPLASH_THEME}/scripts/${event}-pre "$2" "$3" fi case "$event" in svc_start) splash_svc_start "$2";; svc_stop) splash_svc_stop "$2";; svc_started) splash_svc "$2" "$3" "start";; svc_stopped) splash_svc "$2" "$3" "stop";; svc_input_begin) splash_input_begin "$2";; svc_input_end) splash_input_end "$2";; rc_init) splash_init "$2";; rc_exit) splash_exit;; critical) /sbin/splash "verbose";; esac if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-post" ]; then /etc/splash/${SPLASH_THEME}/scripts/${event}-post "$2" "$3" fi return 0 } splash_setup() { # if it's already setup, let's not waste time on parsing the config files again if [ "${SPLASH_THEME}" != "" ]; then return 0 fi export SPLASH_THEME="default" if [ -f /etc/conf.d/splash ]; then . /etc/conf.d/splash fi if [ -f /proc/cmdline ]; then # kernel command line override for the splash theme for param in `grep "theme:" /proc/cmdline`; do t=${param%:*} if [ "${t#*,}" == "theme" ]; then SPLASH_THEME="${param#*:}" fi done else echo "PROC NOT MOUNTED!!!" fi } splash_svc_start() { local svc="$1" splash_load_vars SPL_SVC_START="${SPL_SVC_START}${svc} " SPL_SVC_INACTIVE_START="${SPL_SVC_INACTIVE_START// $svc / }" splash_save_vars /sbin/splash "$svc" } splash_svc_stop() { local svc="$1" splash_load_vars SPL_SVC_STOP="${SPL_SVC_STOP}${svc} " SPL_SVC_INACTIVE_STOP="${SPL_SVC_INACTIVE_STOP// $svc / }" splash_save_vars /sbin/splash "$svc" } splash_init() { arg="$1" spl_init=0 spl_count=0 spl_scripts=0 spl_rate=0 spl_execed="" if [ "${RUNLEVEL}" == "S" ] && [ "${arg}" == "sysinit" ] then #temp=($CRITICAL_SERVICES) #spl_scripts=${#temp[*]} spl_scripts=6 spl_rate=16383 fi if [ "${RUNLEVEL}" == "S" -a "${arg}" == "sysinit" ] || [ "${RUNLEVEL}" == "6" -o "${RUNLEVEL}" == "0" ] then /sbin/splash "start" fi export spl_init spl_count spl_scripts spl_rate spl_execed splash_save_vars # if [ "${arg}" != "sysinit" ] # then splash_calc # fi } # ---------------------------------------------------------------------- # RUNLEVEL SOFTLEVEL INTERNAL SVCS # ---------------------------------------------------------------------- # System boot-up: # S sysinit CRITICAL_SERVICES # S boot boot_serv - CRITICAL_SERVICES # 3 default std # # System restart/shutdown: # 0/6 reboot/shutdown all splash_calc() { #spl_runs=($(dolisting "/etc/runlevels/${SOFTLEVEL}/")) #spl_runb=($(dolisting "/etc/runlevels/${BOOTLEVEL}/")) local my_runlevel my_runlevel="$(grep -i initdefault /etc/inittab | cut -d: -f2)" spl_runs=($(ls /etc/rc.d/rcsysinit.d/S*)) spl_runb=($(ls /etc/rc.d/rc${my_runlevel}.d/S*)) spl_scripts=$((${#spl_runs[*]} + ${#spl_runb[*]})) #spl_boot=${#spl_runb[*]} # In runlevel boot we already have some services started # if [ "${RUNLEVEL}" = "S" -a "${SOFTLEVEL}" = "boot" ] # if [ "${RUNLEVEL}" = "S" ] # then # spl_started=($(dolisting "${svcdir}/started/")) # spl_scripts=$((${spl_boot} - ${#spl_started[*]})) # spl_init=16383 # spl_rate=26213 # elif [ "${SOFTLEVEL}" = "reboot" -o "${SOFTLEVEL}" = "shutdown" ] # elif [ "${RUNLEVEL}" = "6" -o "${RUNLEVEL}" = "0" ] # then # spl_started=($(dolisting "${svcdir}/started/")) # spl_scripts=${#spl_started[*]} # spl_rate=65535 # else #spl_init=26213 spl_rate=65535 # fi splash_save_vars } splash_svc() { local srv="$1" local err="$2" splash_load_vars [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash # we ignore consolefont errors because it fails when the console is in KD_GRAPHICS mode if [ "${err}" -ne 0 -a "${SPLASH_VERBOSE_ON_ERRORS}" = "yes" -a "${srv}" != "consolefont" ]; then /sbin/splash "verbose" return 1 fi for i in ${spl_execed} do [ "${i}" = "${srv}" ] && return done spl_execed="${spl_execed} ${srv}" spl_count=$((${spl_count} + 1)) /sbin/splash "$srv" splash_save_vars } splash_exit() { if [ "${RUNLEVEL}" = "S" ]; then return 0 fi if splash_is_silent ; then /sbin/splash "verbose" # we need to restart consolefont because fonts don't get set when the vc # is in KD_GRAPHICS mode if [ -L "${svcdir}/started/consolefont" ]; then /etc/init.d/consolefont restart 2>/dev/null >/dev/null fi fi } splash_is_silent() { if [ -n "`/sbin/splash_util -c getmode 2>/dev/null | grep silent`" ]; then return 0 else return 1 fi } splash_load_vars() { # In sysinit we don't have the variables, bacause: # 1) it's not necessary # 2) the root fs is mounted ro # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then # return 0 # fi [ -e ${svcdir}/progress ] && source ${svcdir}/progress #added export spl_execed spl_count spl_scripts spl_rate spl_init } splash_save_vars() { # In sysinit we don't have the variables, bacause: # 1) it's not necessary # 2) the root fs is mounted ro # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then # return 0 # fi t="spl_execed=\"${spl_execed}\"\n" t="${t}spl_count=${spl_count}\n" t="${t}spl_scripts=${spl_scripts}\n" t="${t}spl_rate=${spl_rate}\n" t="${t}spl_init=${spl_init}\n" (echo -e "$t" > ${svcdir}/progress) 2>/dev/null } # vim:ts=4