Annotation of /trunk/splashutils-magellan/splash-functions
Parent Directory | Revision Log
Revision 5 -
(hide annotations)
(download)
Fri Mar 4 18:09:01 2005 UTC (19 years, 6 months ago) by niro
File size: 4732 byte(s)
Fri Mar 4 18:09:01 2005 UTC (19 years, 6 months ago) by niro
File size: 4732 byte(s)
importet, ver 0.1
1 | niro | 5 | # Copyright 1999-2004 Gentoo Foundation |
2 | # Distributed under the terms of the GNU General Public License v2 | ||
3 | # $Header: /root/magellan-cvs/src/splashutils-magellan/splash-functions,v 1.1 2005-03-04 18:09:01 niro Exp $ | ||
4 | |||
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 | # TODO: add drop-to-verbose-on-error | ||
11 | |||
12 | # This is the main function that handles all events. | ||
13 | # Accepted parameters: | ||
14 | # svc_start <name> | ||
15 | # svc_stop <name> | ||
16 | # svc_started <name> <errcode> | ||
17 | # svc_stopped <name> <errcode> | ||
18 | # rc_init <internal_runlevel> - used to distinguish between 'boot' and 'sysinit' | ||
19 | # rc_exit | ||
20 | # critical | ||
21 | |||
22 | splash() | ||
23 | { | ||
24 | case "$1" in | ||
25 | svc_start) ;; | ||
26 | svc_stop) ;; | ||
27 | svc_started) splash_svc "$2" "$3" "start";; | ||
28 | svc_stopped) splash_svc "$2" "$3" "stop";; | ||
29 | rc_init) splash_init "$2";; | ||
30 | rc_exit) splash_exit;; | ||
31 | critical) /sbin/splash "verbose";; | ||
32 | esac | ||
33 | |||
34 | return 0 | ||
35 | } | ||
36 | |||
37 | splash_init() | ||
38 | { | ||
39 | arg="$1" | ||
40 | spl_init=0 | ||
41 | spl_count=0 | ||
42 | spl_scripts=0 | ||
43 | spl_rate=0 | ||
44 | spl_execed="" | ||
45 | |||
46 | if [ "${RUNLEVEL}" == "S" ] && [ "${arg}" == "sysinit" ] | ||
47 | then | ||
48 | #temp=($CRITICAL_SERVICES) | ||
49 | #spl_scripts=${#temp[*]} | ||
50 | spl_scripts=6 | ||
51 | spl_rate=16383 | ||
52 | fi | ||
53 | |||
54 | if [ "${RUNLEVEL}" == "S" -a "${arg}" == "sysinit" ] || | ||
55 | [ "${RUNLEVEL}" == "6" -o "${RUNLEVEL}" == "0" ] | ||
56 | then | ||
57 | /sbin/splash "start" | ||
58 | fi | ||
59 | |||
60 | export spl_init spl_count spl_scripts spl_rate spl_execed | ||
61 | splash_save_vars | ||
62 | |||
63 | # if [ "${arg}" != "sysinit" ] | ||
64 | # then | ||
65 | splash_calc | ||
66 | # fi | ||
67 | } | ||
68 | |||
69 | # ---------------------------------------------------------------------- | ||
70 | # RUNLEVEL SOFTLEVEL INTERNAL SVCS | ||
71 | # ---------------------------------------------------------------------- | ||
72 | # System boot-up: | ||
73 | # S <none> sysinit CRITICAL_SERVICES | ||
74 | # S boot <none> boot_serv - CRITICAL_SERVICES | ||
75 | # 3 default <none> std | ||
76 | # | ||
77 | # System restart/shutdown: | ||
78 | # 0/6 reboot/shutdown <none> all | ||
79 | |||
80 | splash_calc() | ||
81 | { | ||
82 | #spl_runs=($(dolisting "/etc/runlevels/${SOFTLEVEL}/")) | ||
83 | #spl_runb=($(dolisting "/etc/runlevels/${BOOTLEVEL}/")) | ||
84 | |||
85 | local my_runlevel | ||
86 | my_runlevel="$(grep -i initdefault /etc/inittab | cut -d: -f2)" | ||
87 | |||
88 | spl_runs=($(ls /etc/rc.d/rcsysinit.d/S*)) | ||
89 | spl_runb=($(ls /etc/rc.d/rc${my_runlevel}.d/S*)) | ||
90 | |||
91 | spl_scripts=$((${#spl_runs[*]} + ${#spl_runb[*]})) | ||
92 | #spl_boot=${#spl_runb[*]} | ||
93 | |||
94 | # In runlevel boot we already have some services started | ||
95 | # if [ "${RUNLEVEL}" = "S" -a "${SOFTLEVEL}" = "boot" ] | ||
96 | # if [ "${RUNLEVEL}" = "S" ] | ||
97 | # then | ||
98 | # spl_started=($(dolisting "${svcdir}/started/")) | ||
99 | # spl_scripts=$((${spl_boot} - ${#spl_started[*]})) | ||
100 | # spl_init=16383 | ||
101 | # spl_rate=26213 | ||
102 | # elif [ "${SOFTLEVEL}" = "reboot" -o "${SOFTLEVEL}" = "shutdown" ] | ||
103 | # elif [ "${RUNLEVEL}" = "6" -o "${RUNLEVEL}" = "0" ] | ||
104 | # then | ||
105 | # spl_started=($(dolisting "${svcdir}/started/")) | ||
106 | # spl_scripts=${#spl_started[*]} | ||
107 | # spl_rate=65535 | ||
108 | # else | ||
109 | #spl_init=26213 | ||
110 | spl_rate=65535 | ||
111 | # fi | ||
112 | |||
113 | splash_save_vars | ||
114 | } | ||
115 | |||
116 | splash_svc() | ||
117 | { | ||
118 | local srv="$1" | ||
119 | local err="$2" | ||
120 | |||
121 | splash_load_vars | ||
122 | |||
123 | [ -e /etc/conf.d/splash ] && source /etc/conf.d/splash | ||
124 | |||
125 | # we ignore consolefont errors because it fails when the console is in KD_GRAPHICS mode | ||
126 | if [ "${err}" -ne 0 -a "${SPLASH_VERBOSE_ON_ERRORS}" = "yes" -a "${srv}" != "consolefont" ]; then | ||
127 | /sbin/splash "verbose" | ||
128 | return 1 | ||
129 | fi | ||
130 | |||
131 | for i in ${spl_execed} | ||
132 | do | ||
133 | [ "${i}" = "${srv}" ] && return | ||
134 | done | ||
135 | |||
136 | spl_execed="${spl_execed} ${srv}" | ||
137 | spl_count=$((${spl_count} + 1)) | ||
138 | /sbin/splash "$srv" | ||
139 | |||
140 | splash_save_vars | ||
141 | } | ||
142 | |||
143 | splash_exit() | ||
144 | { | ||
145 | if [ "${RUNLEVEL}" = "S" ]; then | ||
146 | return 0 | ||
147 | fi | ||
148 | |||
149 | if splash_is_silent ; then | ||
150 | |||
151 | /sbin/splash "verbose" | ||
152 | |||
153 | # we need to restart consolefont because fonts don't get set when the vc | ||
154 | # is in KD_GRAPHICS mode | ||
155 | if [ -L "${svcdir}/started/consolefont" ]; then | ||
156 | /etc/init.d/consolefont restart 2>/dev/null >/dev/null | ||
157 | fi | ||
158 | fi | ||
159 | } | ||
160 | |||
161 | splash_is_silent() | ||
162 | { | ||
163 | if [ -n "`/sbin/splash_util -c getmode 2>/dev/null | grep silent`" ]; then | ||
164 | return 0 | ||
165 | else | ||
166 | return 1 | ||
167 | fi | ||
168 | } | ||
169 | |||
170 | splash_load_vars() | ||
171 | { | ||
172 | # In sysinit we don't have the variables, bacause: | ||
173 | # 1) it's not necessary | ||
174 | # 2) the root fs is mounted ro | ||
175 | # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then | ||
176 | # return 0 | ||
177 | # fi | ||
178 | |||
179 | [ -e ${svcdir}/progress ] && source ${svcdir}/progress | ||
180 | |||
181 | #added | ||
182 | export spl_execed spl_count spl_scripts spl_rate spl_init | ||
183 | } | ||
184 | |||
185 | splash_save_vars() | ||
186 | { | ||
187 | # In sysinit we don't have the variables, bacause: | ||
188 | # 1) it's not necessary | ||
189 | # 2) the root fs is mounted ro | ||
190 | # if [ "${RUNLEVEL}" == "S" -a "${SOFTLEVEL}" != "boot" ]; then | ||
191 | # return 0 | ||
192 | # fi | ||
193 | |||
194 | t="spl_execed=\"${spl_execed}\"\n" | ||
195 | t="${t}spl_count=${spl_count}\n" | ||
196 | t="${t}spl_scripts=${spl_scripts}\n" | ||
197 | t="${t}spl_rate=${spl_rate}\n" | ||
198 | t="${t}spl_init=${spl_init}\n" | ||
199 | (echo -e "$t" > ${svcdir}/progress) 2>/dev/null | ||
200 | } | ||
201 | |||
202 | # vim:ts=4 |
Properties
Name | Value |
---|---|
svn:executable | * |