2 # initscripts-splash functions
7 if [ "$SPLASH_DEBUG" = "true" ]; then
8 if ! [ -d /var/log/splash ]; then
9 mkdir -p /var/log/splash
11 if ! [ -f /var/log/splash/splash.log ]; then
12 mount -ns -t tmpfs -o size=1M tmpfs /var/log/splash
13 echo "Hello damned debugger" > /var/log/splash/splash.log
18 [ "$SPLASH_DEBUG" = "true" ] || return 1
20 echo "$1" >> /var/log/splash/splash.log
23 splash_enabled_cmdline() { debug_log "$0 ${FUNCNAME}"
41 [ "${SINGLE}" = "false" ] || return 1
42 [ "${ENABLE}" = "true" ] || return 1
47 splash_enabled_config() { debug_log "$0 ${FUNCNAME}"
48 if [[ -n ${SPLASH} && -f /etc/rc.d/${SPLASH}-functions ]]; then
51 if [[ -f /etc/rc.d/splashy-functions ]]; then
60 if [ -z "$RUNLEVEL" ]; then
64 if ! splash_enabled_cmdline; then
68 if ! splash_enabled_config; then
74 for daemon in "${DAEMONS[@]}"; do
75 if [ "$daemon" = "${daemon#!}" ]; then
84 local COUNT=$(grep -e status -e stat_busy /etc/${1} | grep -c -v \#)
86 if ! [ "$USELVM" = "yes" -o "$USELVM" = "YES" ]; then
89 if ! [ -f /etc/crypttab -a -n "$(/bin/grep -v ^# /etc/crypttab | /bin/grep -v ^$)" ]; then
96 set_sysinit() { debug_log "$0 ${FUNCNAME}"
97 SPLASH_PROGRESS_STATS=$(count_stats rc.sysinit)
98 SPLASH_PROGRESS_DAEMONS=$(count_daemons)
99 SPLASH_PROGRESS_TOTAL=$(($SPLASH_PROGRESS_STATS+$SPLASH_PROGRESS_DAEMONS))
100 SPLASH_PROGRESS_COUNT=0
101 SPLASH_AUTORUN_COMMAND="splash_sysinit"
103 debug_log "SPLASH_PROGRESS_TOTAL=$SPLASH_PROGRESS_TOTAL SPLASH_AUTORUN_COMMAND=$SPLASH_AUTORUN_COMMAND"
106 set_multi() { debug_log "$0 ${FUNCNAME}"
107 SPLASH_PROGRESS_STATS=$(count_stats rc.sysinit)
108 SPLASH_PROGRESS_DAEMONS=$(count_daemons)
109 SPLASH_PROGRESS_TOTAL=$(($SPLASH_PROGRESS_STATS+$SPLASH_PROGRESS_DAEMONS))
110 SPLASH_PROGRESS_COUNT=$(($SPLASH_PROGRESS_STATS-1))
111 SPLASH_AUTORUN_COMMAND="splash_multi"
113 debug_log "SPLASH_PROGRESS_TOTAL=$SPLASH_PROGRESS_TOTAL SPLASH_AUTORUN_COMMAND=$SPLASH_AUTORUN_COMMAND"
116 set_shutdown() { debug_log "$0 ${FUNCNAME}"
117 SPLASH_PROGRESS_STATS=$(count_stats rc.shutdown)
118 SPLASH_RUNNING_DAEMONS=(`/bin/ls /var/run/daemons`)
119 SPLASH_PROGRESS_DAEMONS=${#SPLASH_RUNNING_DAEMONS[*]}
120 SPLASH_PROGRESS_TOTAL=$(($SPLASH_PROGRESS_STATS+$SPLASH_PROGRESS_DAEMONS))
121 SPLASH_PROGRESS_COUNT=0
122 SPLASH_AUTORUN_COMMAND="splash_shutdown"
124 debug_log "SPLASH_PROGRESS_TOTAL=$SPLASH_PROGRESS_TOTAL SPLASH_AUTORUN_COMMAND=$SPLASH_AUTORUN_COMMAND"
127 if [ -z "${SPLASH_INIT_DONE}" ]; then
128 export SPLASH_INIT_DONE="true"
130 debug_log "$0 Running initscript..."
135 SPLASH_STATUS_MESSAGE="Booting Arch Linux..."
139 SPLASH_STATUS_MESSAGE="Loading daemons..."
143 SPLASH_STATUS_MESSAGE="Loading daemons..."
147 SPLASH_STATUS_MESSAGE="Rebooting Arch Linux..."
151 SPLASH_STATUS_MESSAGE="Shutting down Arch Linux..."
156 . /etc/rc.d/${SPLASH}-functions
160 splash_progress() { debug_log "$0 ${FUNCNAME}"
161 if [ -n "$SPLASH_PROGRESS_COUNT" ]; then
162 ${SPLASH}_progress $SPLASH_PROGRESS_COUNT $SPLASH_PROGRESS_TOTAL
163 ((SPLASH_PROGRESS_COUNT++))
167 splash_print() { debug_log "$0 ${FUNCNAME}"
168 ${SPLASH}_print "${1}"
173 splash_exit() { debug_log "$0 ${FUNCNAME}"
174 ${SPLASH}_exit ${DEFAULT_TTY} ${SWITCH_TTY}
177 splash_sysinit() { debug_log "$0 ${FUNCNAME}"
178 ${SPLASH}_sysinit ${DEFAULT_TTY}
181 splash_multi() { debug_log "$0 ${FUNCNAME}"
188 splash_shutdown() { debug_log "$0 ${FUNCNAME}"
189 ${SPLASH}_shutdown ${DEFAULT_TTY}
191 if [ -n "`pidof $SPLASH`" ]; then
192 export KILLALL5_OPTS="-o `pidof $SPLASH`"
196 if [ -n "${SPLASH_AUTORUN_COMMAND}" ]; then
197 $SPLASH_AUTORUN_COMMAND
198 splash_print "${SPLASH_STATUS_MESSAGE}"
204 deltext() { debug_log "$0 ${FUNCNAME}"
205 if [ "$CONSOLE_PRINT" == "true" ]; then
212 printhl() { debug_log "$0 ${FUNCNAME}"
213 if [ "$CONSOLE_PRINT" == "true" ]; then
214 printf "${C_OTHER}${PREFIX_HL} ${C_H1}${1}${C_CLEAR} \n"
220 printsep() { debug_log "$0 ${FUNCNAME}"
221 if [ "$CONSOLE_PRINT" == "true" ]; then
222 printf "\n${C_SEPARATOR} ------------------------------\n"
228 stat_bkgd() { debug_log "$0 ${FUNCNAME}"
229 if [ "$CONSOLE_PRINT" == "true" ]; then
230 printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
232 printf " ${C_OTHER}[${C_BKGD}BKGD${C_OTHER}]${C_CLEAR} "
236 stat_busy() { debug_log "$0 ${FUNCNAME}"
237 if [ "$CONSOLE_PRINT" == "true" ]; then
238 printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
239 printf "${SAVE_POSITION}"
241 printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} "
246 stat_append() { debug_log "$0 ${FUNCNAME}"
247 if [ "$CONSOLE_PRINT" == "true" ]; then
248 printf "${RESTORE_POSITION}"
249 printf "${C_MAIN}${1}${C_CLEAR}"
250 printf "${SAVE_POSITION}"
256 stat_done() { debug_log "$0 ${FUNCNAME}"
257 if [ "$CONSOLE_PRINT" == "true" ]; then
259 printf " ${C_OTHER}[${C_DONE}DONE${C_OTHER}]${C_CLEAR} \n"
264 stat_fail() { debug_log "$0 ${FUNCNAME}"
265 if [ "$CONSOLE_PRINT" == "true" ]; then
266 printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n"
268 splash_print "Something failed, killing splash..."
275 log_daemon() { debug_log "$0 ${FUNCNAME}"
283 start_daemon() { debug_log "$0 ${FUNCNAME}"
289 start_daemon_bkgd() { debug_log "$0 ${FUNCNAME}"
290 if [ "$CONSOLE_PRINT" == "true" ]; then
291 stat_bkgd "Starting $1"
294 (/etc/rc.d/$1 start) &>/dev/null &
298 stop_daemon() { debug_log "$0 ${FUNCNAME}"
301 for daemon in ${SPLASH_RUNNING_DAEMONS[@]}; do
302 if [ "$daemon" = "$1" ]; then
310 # vim: set ts=2 noet: