Annotation of /trunk/splashutils-magellan/splash-functions
Parent Directory | Revision Log
Revision 9 -
(hide annotations)
(download)
Fri Mar 4 21:02:46 2005 UTC (19 years, 6 months ago) by niro
File size: 6107 byte(s)
Fri Mar 4 21:02:46 2005 UTC (19 years, 6 months ago) by niro
File size: 6107 byte(s)
updated to gentoo ver-0.1.4
1 | niro | 5 | # Copyright 1999-2004 Gentoo Foundation |
2 | # Distributed under the terms of the GNU General Public License v2 | ||
3 | niro | 9 | # $Header: /root/magellan-cvs/src/splashutils-magellan/splash-functions,v 1.2 2005-03-04 21:02:42 niro Exp $ |
4 | niro | 5 | |
5 | # Author: Michal Januszewski <spock@gentoo.org> | ||
6 | # Maintainer: Michal Januszewski <spock@gentoo.org> | ||
7 | |||
8 | # This is file is a part of splashutils. | ||
9 | |||
10 | # This is the main function that handles all events. | ||
11 | # Accepted parameters: | ||
12 | # svc_start <name> | ||
13 | # svc_stop <name> | ||
14 | # svc_started <name> <errcode> | ||
15 | # svc_stopped <name> <errcode> | ||
16 | niro | 9 | # svc_input_begin <name> |
17 | # svc_input_end <name> | ||
18 | niro | 5 | # rc_init <internal_runlevel> - used to distinguish between 'boot' and 'sysinit' |
19 | # rc_exit | ||
20 | # critical | ||
21 | |||
22 | splash() | ||
23 | { | ||
24 | niro | 9 | local event="$1" |
25 | splash_setup | ||
26 | |||
27 | if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-pre" ]; then | ||
28 | /etc/splash/${SPLASH_THEME}/scripts/${event}-pre "$2" "$3" | ||
29 | fi | ||
30 | |||
31 | case "$event" in | ||
32 | svc_start) splash_svc_start "$2";; | ||
33 | svc_stop) splash_svc_stop "$2";; | ||
34 | niro | 5 | svc_started) splash_svc "$2" "$3" "start";; |
35 | svc_stopped) splash_svc "$2" "$3" "stop";; | ||
36 | niro | 9 | svc_input_begin) splash_input_begin "$2";; |
37 | svc_input_end) splash_input_end "$2";; | ||
38 | niro | 5 | rc_init) splash_init "$2";; |
39 | rc_exit) splash_exit;; | ||
40 | critical) /sbin/splash "verbose";; | ||
41 | esac | ||
42 | niro | 9 | |
43 | if [ -x "/etc/splash/${SPLASH_THEME}/scripts/${event}-post" ]; then | ||
44 | /etc/splash/${SPLASH_THEME}/scripts/${event}-post "$2" "$3" | ||
45 | fi | ||
46 | |||
47 | niro | 5 | return 0 |
48 | } | ||
49 | |||
50 | niro | 9 | splash_setup() |
51 | { | ||
52 | # if it's already setup, let's not waste time on parsing the config files again | ||
53 | if [ "${SPLASH_THEME}" != "" ]; then | ||
54 | return 0 | ||
55 | fi | ||
56 | |||
57 | export SPLASH_THEME="default" | ||
58 | |||
59 | if [ -f /etc/conf.d/splash ]; then | ||
60 | . /etc/conf.d/splash | ||
61 | fi | ||
62 | |||
63 | if [ -f /proc/cmdline ]; then | ||
64 | # kernel command line override for the splash theme | ||
65 | for param in `grep "theme:" /proc/cmdline`; do | ||
66 | t=${param%:*} | ||
67 | if [ "${t#*,}" == "theme" ]; then | ||
68 | SPLASH_THEME="${param#*:}" | ||
69 | fi | ||
70 | done | ||
71 | else | ||
72 | echo "PROC NOT MOUNTED!!!" | ||
73 | fi | ||
74 | } | ||
75 | |||
76 | splash_svc_start() | ||
77 | { | ||
78 | local svc="$1" | ||
79 | |||
80 | splash_load_vars | ||
81 | SPL_SVC_START="${SPL_SVC_START}${svc} " | ||
82 | SPL_SVC_INACTIVE_START="${SPL_SVC_INACTIVE_START// $svc / }" | ||
83 | splash_save_vars | ||
84 | |||
85 | /sbin/splash "$svc" | ||
86 | } | ||
87 | |||
88 | splash_svc_stop() | ||
89 | { | ||
90 | local svc="$1" | ||
91 | |||
92 | splash_load_vars | ||
93 | SPL_SVC_STOP="${SPL_SVC_STOP}${svc} " | ||
94 | SPL_SVC_INACTIVE_STOP="${SPL_SVC_INACTIVE_STOP// $svc / }" | ||
95 | splash_save_vars | ||
96 | |||
97 | /sbin/splash "$svc" | ||
98 | } | ||
99 | |||
100 | niro | 5 | splash_init() |
101 | { | ||
102 | arg="$1" | ||
103 | spl_init=0 | ||
104 | spl_count=0 | ||
105 | spl_scripts=0 | ||
106 | spl_rate=0 | ||
107 | spl_execed="" | ||
108 | |||
109 | if [ "${RUNLEVEL}" == "S" ] && [ "${arg}" == "sysinit" ] | ||
110 | then | ||
111 | #temp=($CRITICAL_SERVICES) | ||
112 | #spl_scripts=${#temp[*]} | ||
113 | spl_scripts=6 | ||
114 | spl_rate=16383 | ||
115 | fi | ||
116 | |||
117 | if [ "${RUNLEVEL}" == "S" -a "${arg}" == "sysinit" ] || | ||
118 | [ "${RUNLEVEL}" == "6" -o "${RUNLEVEL}" == "0" ] | ||
119 | then | ||
120 | /sbin/splash "start" | ||
121 | fi | ||
122 | |||
123 | export spl_init spl_count spl_scripts spl_rate spl_execed | ||
124 | splash_save_vars | ||
125 | |||
126 | # if [ "${arg}" != "sysinit" ] | ||
127 | # then | ||
128 | splash_calc | ||
129 | # fi | ||
130 | } | ||
131 | |||
132 | # ---------------------------------------------------------------------- | ||
133 | # RUNLEVEL SOFTLEVEL INTERNAL SVCS | ||
134 | # ---------------------------------------------------------------------- | ||
135 | # System boot-up: | ||
136 | # S <none> sysinit CRITICAL_SERVICES | ||
137 | # S boot <none> boot_serv - CRITICAL_SERVICES | ||
138 | # 3 default <none> std | ||
139 | # | ||
140 | # System restart/shutdown: | ||
141 | # 0/6 reboot/shutdown <none> all | ||
142 | |||
143 | splash_calc() | ||
144 | { | ||
145 | #spl_runs=($(dolisting "/etc/runlevels/${SOFTLEVEL}/")) | ||
146 | #spl_runb=($(dolisting "/etc/runlevels/${BOOTLEVEL}/")) | ||
147 | |||
148 | local my_runlevel | ||
149 | my_runlevel="$(grep -i initdefault /etc/inittab | cut -d: -f2)" | ||
150 | |||
151 | spl_runs=($(ls /etc/rc.d/rcsysinit.d/S*)) | ||
152 | spl_runb=($(ls /etc/rc.d/rc${my_runlevel}.d/S*)) | ||
153 | |||
154 | spl_scripts=$((${#spl_runs[*]} + ${#spl_runb[*]})) | ||
155 | #spl_boot=${#spl_runb[*]} | ||
156 | |||
157 | # In runlevel boot we already have some services started | ||
158 | # if [ "${RUNLEVEL}" = "S" -a "${SOFTLEVEL}" = "boot" ] | ||
159 | # if [ "${RUNLEVEL}" = "S" ] | ||
160 | # then | ||
161 | # spl_started=($(dolisting "${svcdir}/started/")) | ||
162 | # spl_scripts=$((${spl_boot} - ${#spl_started[*]})) | ||
163 | # spl_init=16383 | ||
164 | # spl_rate=26213 | ||
165 | # elif [ "${SOFTLEVEL}" = "reboot" -o "${SOFTLEVEL}" = "shutdown" ] | ||
166 | # elif [ "${RUNLEVEL}" = "6" -o "${RUNLEVEL}" = "0" ] | ||
167 | # then | ||
168 | # spl_started=($(dolisting "${svcdir}/started/")) | ||
169 | # spl_scripts=${#spl_started[*]} | ||
170 | # spl_rate=65535 | ||
171 | # else | ||
172 | #spl_init=26213 | ||
173 | spl_rate=65535 | ||
174 | # fi | ||
175 | |||
176 | splash_save_vars | ||
177 | } | ||
178 | |||
179 | splash_svc() | ||
180 | { | ||
181 | local srv="$1" | ||
182 | local err="$2" | ||
183 | |||
184 | splash_load_vars | ||
185 | |||
186 | [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash | ||
187 | |||
188 | # we ignore consolefont errors because it fails when the console is in KD_GRAPHICS mode | ||
189 | if [ "${err}" -ne 0 -a "${SPLASH_VERBOSE_ON_ERRORS}" = "yes" -a "${srv}" != "consolefont" ]; then | ||
190 | /sbin/splash "verbose" | ||
191 | return 1 | ||
192 | fi | ||
193 | |||
194 | for i in ${spl_execed} | ||
195 | do | ||
196 | [ "${i}" = "${srv}" ] && return | ||
197 | done | ||
198 | |||
199 | spl_execed="${spl_execed} ${srv}" | ||
200 | spl_count=$((${spl_count} + 1)) | ||
201 | /sbin/splash "$srv" | ||
202 | |||
203 | splash_save_vars | ||
204 | } | ||
205 | |||
206 | splash_exit() | ||
207 | { | ||
208 | if [ "${RUNLEVEL}" = "S" ]; then | ||
209 | return 0 | ||
210 | fi | ||
211 | |||
212 | if splash_is_silent ; then | ||
213 | |||
214 | /sbin/splash "verbose" | ||
215 | |||
216 | # we need to restart consolefont because fonts don't get set when the vc | ||
217 | # is in KD_GRAPHICS mode | ||
218 | if [ -L "${svcdir}/started/consolefont" ]; then | ||
219 | /etc/init.d/consolefont restart 2>/dev/null >/dev/null | ||
220 | fi | ||
221 | fi | ||
222 | } | ||
223 | |||
224 | splash_is_silent() | ||
225 | { | ||
226 | if [ -n "`/sbin/splash_util -c getmode 2>/dev/null | grep silent`" ]; then | ||
227 | return 0 | ||
228 | else | ||
229 | return 1 | ||
230 | fi | ||
231 | } | ||
232 | |||
233 | splash_load_vars() | ||
234 | { | ||
235 | # In sysinit we don't have the variables, bacause: | ||
236 | # 1) it's not necessary | ||
237 | # 2) the root fs is mounted ro | ||
238 | # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then | ||
239 | # return 0 | ||
240 | # fi | ||
241 | |||
242 | [ -e ${svcdir}/progress ] && source ${svcdir}/progress | ||
243 | |||
244 | #added | ||
245 | export spl_execed spl_count spl_scripts spl_rate spl_init | ||
246 | } | ||
247 | |||
248 | splash_save_vars() | ||
249 | { | ||
250 | # In sysinit we don't have the variables, bacause: | ||
251 | # 1) it's not necessary | ||
252 | # 2) the root fs is mounted ro | ||
253 | # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then | ||
254 | # return 0 | ||
255 | # fi | ||
256 | |||
257 | t="spl_execed=\"${spl_execed}\"\n" | ||
258 | t="${t}spl_count=${spl_count}\n" | ||
259 | t="${t}spl_scripts=${spl_scripts}\n" | ||
260 | t="${t}spl_rate=${spl_rate}\n" | ||
261 | t="${t}spl_init=${spl_init}\n" | ||
262 | (echo -e "$t" > ${svcdir}/progress) 2>/dev/null | ||
263 | } | ||
264 | |||
265 | # vim:ts=4 |
Properties
Name | Value |
---|---|
svn:executable | * |