Line 0
Link Here
|
|
|
1 |
#!/bin/bash |
2 |
# |
3 |
# splash - script to paint progress bar during |
4 |
# system startup/shutdown. This script is solely run |
5 |
# by the init scripts (shell function splash_update) |
6 |
# |
7 |
# (w) 2002-2003 Stefan Reinauer, <stephan@suse.de> |
8 |
# It's licensed under GPL, of course. |
9 |
# |
10 |
# modified by Michael Aichler, <micha at aichler dot net> |
11 |
# |
12 |
# this script expects the following environment variables: |
13 |
# pb_init = the current status of the progress bar |
14 |
# pb_count = number of currently executed start/stop script |
15 |
# pb_scripts = number of scripts to be executed for runlevel change |
16 |
# pb_rate = the progress bar rate of the current boot process |
17 |
# RUNLEVEL = runlevel to be reached |
18 |
# |
19 |
# execute splash binary utility because we are a wrapper |
20 |
# |
21 |
if [ "$1" == "-s" -o "$1" == "-u" -o "$1" == "-n" -o "$1" == "-f" ]; then |
22 |
exec /sbin/splash.bin $* |
23 |
fi |
24 |
|
25 |
function box() { true; } |
26 |
|
27 |
# |
28 |
# assertions |
29 |
# |
30 |
test -r /proc/splash || exit 1 |
31 |
test -z "`cat /proc/splash 2>/dev/null | grep on`" && exit 1 |
32 |
test -z "$pb_count" -a -z "$pb_scripts" && DBZ="yes" |
33 |
test "$RUNLEVEL" == "6" -o "$RUNLEVEL" == "0" && SHUTDOWN="yes" |
34 |
# |
35 |
# Source bootsplash config file |
36 |
# |
37 |
test -f /etc/conf.d/bootsplash.conf && . /etc/conf.d/bootsplash.conf |
38 |
test -z "$BOOTSPLASH_THEME" && BOOTSPLASH_THEME="default" |
39 |
test -z "${BOOTSPLASH_TTYS}" && BOOTSPLASH_TTYS="0" |
40 |
# |
41 |
# Get theme name from kernel command line |
42 |
# |
43 |
for param in `grep "theme=" /proc/cmdline`; do |
44 |
if [ "${param%=*}" == "theme" ]; then |
45 |
BOOTSPLASH_THEME="${param#*=}" |
46 |
fi |
47 |
done |
48 |
# |
49 |
# Source theme config file |
50 |
# |
51 |
if [ ! -x /sbin/fbresolution ]; then |
52 |
echo "$0: '/sbin/fbresolution' does not exist on your system... aborting !" |
53 |
else |
54 |
res="$(/sbin/fbresolution)" |
55 |
fi |
56 |
|
57 |
config="/etc/bootsplash/${BOOTSPLASH_THEME}/config/bootsplash-${res}.cfg" |
58 |
|
59 |
if [ ! -f "$config" ]; then |
60 |
echo "$0: Can't find config file '$config'... aborting !" |
61 |
exit 1 |
62 |
else |
63 |
source "$config" |
64 |
fi |
65 |
|
66 |
# |
67 |
# void splash_start (const char* config_path) |
68 |
# |
69 |
splash_start() { |
70 |
/sbin/splash -s -u 0 "$1" |
71 |
echo "silent" > /proc/splash |
72 |
/usr/bin/chvt 1 |
73 |
} |
74 |
# |
75 |
# void splash_stop (const char* config_path) |
76 |
# |
77 |
splash_stop() { |
78 |
/sbin/bootanim kill |
79 |
/sbin/splash -s -u 0 -n "$1" |
80 |
exit 0 |
81 |
} |
82 |
# |
83 |
# void print_text (void) |
84 |
# |
85 |
print_text() { |
86 |
text="Booting the system... Press F2 for verbose mode" |
87 |
[ -n "${PROGRESS_BOOT_MESSAGE}" ] && text="${PROGRESS_BOOT_MESSAGE}" |
88 |
|
89 |
if [ "${SHUTDOWN}" == "yes" ]; then |
90 |
text="Shutting down the system... Press F2 for verbose mode" |
91 |
[ -n "${PROGRESS_SHUTDOWN_MESSAGE}" ] && text="${PROGRESS_SHUTDOWN_MESSAGE}" |
92 |
|
93 |
if [ "${RUNLEVEL}" == "6" ]; then |
94 |
text="Rebooting the system... Press F2 for verbose mode" |
95 |
[ -n "${PROGRESS_REBOOT_MESSAGE}" ] && text="${PROGRESS_REBOOT_MESSAGE}" |
96 |
fi |
97 |
fi |
98 |
|
99 |
if [ -n "$text_x" -a -n "$text_y" -a -n "$text_color" -a -n "$text_size" ] |
100 |
then |
101 |
options="-x $text_x -y $text_y -t $text_color -s $text_size" |
102 |
if [ -n "${BOOTSPLASH_FONT}" -a -f "/etc/bootsplash/${BOOTSPLASH_FONT}" ] |
103 |
then |
104 |
options="$options -f \"/etc/bootsplash/${BOOTSPLASH_FONT}\"" |
105 |
fi |
106 |
|
107 |
eval "/sbin/fbtruetype.static $options \"$text\"" |
108 |
fi |
109 |
} |
110 |
# |
111 |
# void paint_progress (void) |
112 |
# |
113 |
paint_progress() { |
114 |
if [ "$DBZ" != "yes" -a -n "$progress_enable" ]; then |
115 |
progress=$(($pb_init + ($pb_count + 1) * ($pb_rate - $pb_init) / $pb_scripts)) |
116 |
echo "show $progress" > /proc/splash |
117 |
fi |
118 |
} |
119 |
|
120 |
|
121 |
# |
122 |
# Start silent splash on system shutdown/reboot |
123 |
# |
124 |
if [ "$*" == "start" ]; then |
125 |
if [ -n "`grep \"splash=silent\" /proc/cmdline 2>/dev/null`" ]; then |
126 |
splash_start "$config" |
127 |
paint_progress |
128 |
print_text |
129 |
fi |
130 |
# |
131 |
# Stop on errors |
132 |
# |
133 |
elif [ "$*" == "stop" ]; then |
134 |
if [ "${BOOTSPLASH_STOP_ON_ERROR}" == "yes" ]; then |
135 |
splash_stop "$config" |
136 |
fi |
137 |
# |
138 |
# Print the currently used theme |
139 |
# |
140 |
elif [ "$*" == "theme" ]; then |
141 |
echo "$BOOTSPLASH_THEME" |
142 |
# |
143 |
# Print the currently used config file |
144 |
# |
145 |
elif [ "$*" == "config" ]; then |
146 |
echo "$config" |
147 |
# |
148 |
# Show boot/shutdown/reboot message |
149 |
# |
150 |
elif [ "$*" == "text" ]; then |
151 |
print_text |
152 |
# |
153 |
# Set verbose splash and fade out animations |
154 |
# if booting has finished |
155 |
# |
156 |
elif [ "$*" == "master" ]; then |
157 |
echo "show $pb_rate" > /proc/splash |
158 |
/sbin/bootanim stop && sleep 1 |
159 |
for tty in ${BOOTSPLASH_TTYS}; do |
160 |
/sbin/splash -s -u $tty -n $config |
161 |
done |
162 |
else |
163 |
# |
164 |
# Do not display anything if F2 was pressed. |
165 |
# |
166 |
if [ -z "`grep \"silent\" /proc/splash 2> /dev/null`" ]; then |
167 |
if [ -n "`/bin/ps ax | grep fbmngplay | grep -v grep`" ]; then |
168 |
splash_stop |
169 |
fi |
170 |
exit 0 |
171 |
fi |
172 |
# |
173 |
# Start animations here, if there's any config |
174 |
# (because of a hard coded path in splash.c) |
175 |
# |
176 |
if [ -f /etc/bootsplash/${BOOTSPLASH_THEME}/config/animations.cfg ]; then |
177 |
while read line; do |
178 |
if [ "${line%:*}" == "$*" ]; then |
179 |
eval "${line#*:}" |
180 |
fi |
181 |
done < /etc/bootsplash/${BOOTSPLASH_THEME}/config/animations.cfg |
182 |
fi |
183 |
# |
184 |
# Print text string and paint progress bar |
185 |
# |
186 |
paint_progress |
187 |
fi |
188 |
|
189 |
exit 0 |