updated on Thu Jan 19 00:16:31 UTC 2012
[aur-mirror.git] / fbsplash / fbsplash-basic.sh
blob4403b8628f00dac8f356ca3c219861896faf26e9
2 # /etc/rc.d/functions.d/fbsplash-basic.sh #
4 # Basic Fbsplash script for Arch Linux initscripts #
5 # #
6 # Author: Kurt J. Bosch <kjb-temp-2009 at alpenjodel.de> #
7 # Based on the work of Greg Helton <gt at fallendusk.org> #
8 # Thomas Baechler <thomas at archlinux.org> #
9 # and others #
10 # #
11 # Distributed under the terms of the GNU General Public License (GPL) #
13 [[ $PREVLEVEL && $RUNLEVEL ]] || return 0
15 # Do nothing if advanced script is installed
16 [[ -r /etc/rc.d/functions.d/fbsplash-extras.sh ]] && return
18 # Only do this where needed
19 # Since we use BASH, all important functions and variables are exported
20 case ${0#/etc/rc.} in sysinit | multi | shutdown )
21 # splash-functions.sh will run splash_setup which needs /proc
22 # code line copied from /etc/rc.sysinit
23 /bin/mountpoint -q /proc || /bin/mount -n -t proc proc /proc -o nosuid,noexec,nodev
24 export SPLASH_PUSH_MESSAGES SPLASH_VERBOSE_ON_ERRORS
25 . /sbin/splash-functions.sh # /etc/conf.d/splash is also sourced by this
26 unset options opt i # eliminate splash_setup non local vars ## FIX ME ##
27 SPLASH_STEPS=3 # sysinit steps
28 SPLASH_STEPS_DONE=0
29 esac
31 # Verbose mode is handled by fbcondecor kernel patch and daemon script
32 [[ $SPLASH_MODE_REQ = silent ]] || return 0
34 # Override - Don't try to use /usr/bin/basename
35 splash_comm_send() {
36 [[ $( /bin/pidof -o %PPID $spl_daemon ) ]] && echo "$@" >$spl_fifo &
39 case $0 in /etc/rc.sysinit )
40 # Prevent splash destruction
41 CONSOLEFONT=""
42 # Continue to use a splash daamon started in initcpio
43 if /bin/mountpoint -q /run/.splash-cache; then
44 /bin/mount --move /run/.splash-cache $spl_cachedir || return
45 splash_comm_send set message "$SPLASH_BOOT_MESSAGE"
46 # Mount a tmpfs
47 else
48 ( splash_cache_prep ) || return
50 add_hook sysinit_udevsettled splash_sysinit_udevsettled
51 add_hook sysinit_postfsck splash_sysinit_postfsck
52 add_hook sysinit_postfsckloop splash_sysinit_postfsck
53 add_hook sysinit_premount splash_sysinit_premount
54 add_hook sysinit_end splash_sysinit_end
55 splash_sysinit_udevsettled() {
56 splash_begin
57 splash_progress_init
58 splash_progress
60 splash_sysinit_premount() {
61 splash_progress
63 splash_sysinit_postfsck() { # fsck failure emergency exit
64 (( fsckret > 1 && fsckret != 32 )) && chvt 1
66 splash_sysinit_end() {
67 splash_progress
69 ;; /etc/rc.multi )
70 add_hook multi_start splash_multi_start
71 add_hook multi_end splash_multi_end
72 splash_multi_start() {
73 SPLASH_STEPS_DONE=$SPLASH_STEPS
74 splash_progress_init
76 start_daemon() {
77 [[ $1 = $SPLASH_XSERVICE ]] && SPLASH_EXIT_TYPE=staysilent splash_stop
78 /etc/rc.d/$1 start
79 splash_progress
81 start_daemon_bkgd() {
82 [[ $1 = $SPLASH_XSERVICE ]] && SPLASH_EXIT_TYPE=staysilent splash_stop
83 stat_bkgd "Starting $1"
84 ( SPLASH_PUSH_MESSAGES="no" SPLASH_VERBOSE_ON_ERRORS="no" \
85 /etc/rc.d/$1 start ) &>/dev/null &
87 splash_multi_end() {
88 if [[ $PREVLEVEL = N ]]; then
89 if ! in_array "$SPLASH_XSERVICE" "${DAEMONS[@]}"; then
90 if [[ $RUNLEVEL = 5 ]]; then
91 SPLASH_EXIT_TYPE=staysilent splash_stop
92 else
93 splash_stop
94 [[ $( $spl_bindir/fgconsole ) = $SPLASH_TTY ]] && chvt 1
97 # Now do setfont
98 set_consolefont
99 # Umount the tmpfs
100 splash_cache_cleanup
103 ;; /etc/rc.shutdown )
104 ( splash_cache_prep ) || return
105 # Not using XSERVICE here to avoid missing errors - X should chvt back to SPLASH_TTY
106 add_hook shutdown_start splash_shutdown_start
107 add_hook shutdown_prekillall splash_shutdown_prekillall
108 add_hook shutdown_postkillall splash_shutdown_postkillall
109 add_hook shutdown_poweroff splash_shutdown_poweroff
110 splash_shutdown_start() {
111 splash_begin
113 splash_shutdown_prekillall() {
114 splash_comm_send progress $(( 65535*1/3 )); splash_comm_send paint
115 [[ -r $spl_pidfile ]] && add_omit_pids $( <$spl_pidfile )
117 splash_shutdown_postkillall() {
118 splash_comm_send progress $(( 65535*2/3 )); splash_comm_send paint
120 splash_shutdown_poweroff() {
121 SPLASH_EXIT_TYPE=staysilent splash_stop
123 esac
125 splash_progress_init() {
126 for daemon in "${DAEMONS[@]}"; do
127 case $daemon in $SPLASH_XSERVICE | @$SPLASH_XSERVICE ) break
128 ;; \!* |@* ) continue
129 esac
130 (( SPLASH_STEPS++ ))
131 done
134 splash_progress() {
135 splash_comm_send progress $(( 65535*++SPLASH_STEPS_DONE/SPLASH_STEPS ))
136 splash_comm_send paint
139 # Start the splash daemon - using upstream function
140 splash_begin() {
141 if ! [[ $( /bin/pidof -o %PPID $spl_daemon ) ]]; then
142 stat_busy "Starting Fbsplash daemon"
143 if [ -x /etc/splash/$SPLASH_THEME/scripts/rc_init-pre ]; then
144 /etc/splash/$SPLASH_THEME/scripts/rc_init-pre ${0#/etc/rc.d} $RUNLEVEL
145 fi &&
146 splash_start &&
147 stat_done || stat_fail
151 # Stop the splash daemon - if any
152 splash_stop() {
153 if [[ $( /bin/pidof -o %PPID $spl_daemon ) ]]; then
154 SPLASH_PUSH_MESSAGES="no" stat_busy "Stopping Fbsplash daemon"
155 splash_comm_send progress 65535; splash_comm_send paint; /bin/sleep .1
156 splash_comm_send exit $SPLASH_EXIT_TYPE
157 # Wait for painting/fadeout
158 local -i i=0
159 while [[ i++ -lt 100 && $( /bin/pidof -o %PPID $spl_daemon ) ]]; do
160 /bin/sleep .1
161 done
162 stat_done
166 stat_busy() {
167 printf "${C_OTHER}${PREFIX_REG} ${C_MAIN}${1}${C_CLEAR} "
168 printf "${SAVE_POSITION}"
169 deltext
170 printf " ${C_OTHER}[${C_BUSY}BUSY${C_OTHER}]${C_CLEAR} "
171 SPLASH_BUSY_MSG=$1
172 if [[ $SPLASH_PUSH_MESSAGES = yes ]]; then
173 splash_comm_send set message "${1}"
174 splash_comm_send paint
178 stat_fail() {
179 deltext
180 printf " ${C_OTHER}[${C_FAIL}FAIL${C_OTHER}]${C_CLEAR} \n"
181 local event=stop_failed; [[ $PREVLEVEL = N ]] && event=start_failed
182 # Provide a general failure status event and write to msglog textbox
183 splash_comm_send update_svc fbsplash-dummy svc_${event}
184 splash_comm_send log "Error $SPLASH_BUSY_MSG"
185 splash_comm_send paint
186 # Save for daemon restart ## FIX ME ##
187 if /bin/mountpoint -q $spl_cachedir; then
188 : >|$spl_cachedir/${event}-fbsplash-dummy
190 # Upstream way of error handling
191 if [[ $SPLASH_VERBOSE_ON_ERRORS = yes ]]; then
192 chvt 1
196 # EOF #