# Diff of /trunk/sbin/rc-services.sh

Revision 388 Revision 389
192 fi 192 fi
193 193
194 return 0 194 return 0
195} 195}
196 196
197# bool is_fake_service(service, runlevel)
198#
199# Returns ture if 'service' is a fake service in 'runlevel'.
200#
201is_fake_service() {
202 local x=
203 local fake_services=
204
205 [ -z "\$1" -o -z "\$2" ] && return 1
206
207 if [ "\$2" != "\${BOOTLEVEL}" -a \
208 -e "/etc/runlevels/\${BOOTLEVEL}/.fake" ]
209 then
210 fake_services="\$(< /etc/runlevels/\${BOOTLEVEL}/.fake)"
211 fi
212
213 if [ -e "/etc/runlevels/\$2/.fake" ]
214 then
215 fake_services="\${fake_services} \$(< /etc/runlevels/\$2/.fake)"
216 fi
217
218 for x in \${fake_services}
219 do
220 if [ "\$1" = "\${x##*/}" ]
221 then
222 return 0
223 fi
224 done
225
226 return 1
227}
228
197# bool in_runlevel(service, runlevel) 229# bool in_runlevel(service, runlevel)
198# 230#
199# Returns true if 'service' is in runlevel 'runlevel'. 231# Returns true if 'service' is in runlevel 'runlevel'.
200# 232#
201in_runlevel() { 233in_runlevel() {
204 [ -L "/etc/runlevels/\$2/\$1" ] && return 0 236 [ -L "/etc/runlevels/\$2/\$1" ] && return 0
205 237
206 return 1 238 return 1
207} 239}
208 240
209# bool runlevel_start() 241# bool is_runlevel_start()
210# 242#
211# Returns true if it is a runlevel change, and we are busy 243# Returns true if it is a runlevel change, and we are busy
212# starting services. 244# starting services.
213# 245#
214runlevel_start() { 246is_runlevel_start() {
215 [ -d "\${svcdir}/softscripts.old" ] && return 0 247 [ -d "\${svcdir}/softscripts.old" ] && return 0
216 248
217 return 1 249 return 1
218} 250}
219 251
220# bool runlevel_stop() 252# bool is_runlevel_stop()
221# 253#
222# Returns true if it is a runlevel change, and we are busy 254# Returns true if it is a runlevel change, and we are busy
223# stopping services. 255# stopping services.
224# 256#
225runlevel_stop() { 257is_runlevel_stop() {
226 [ -d "\${svcdir}/softscripts.new" ] && return 0 258 [ -d "\${svcdir}/softscripts.new" ] && return 0
227 259
228 return 1 260 return 1
229} 261}
230 262
263# void filter_environ()
264#
265# Tries to filter most of the dependency stuff from the environment
266#
267filter_environ() {
268 for x in \$(declare -F)
269 do
270 if [ "\${x/depinfo_}" != "\${x}" ]
271 then
272 unset \${x/declare -f /}
273 fi
274 done
275
276 return 0
277}
278
231# int start_service(service) 279# int start_service(service)
232# 280#
233# Start 'service' if it is not already running. 281# Start 'service' if it is not already running.
234# 282#
235start_service() { 283start_service() {
236 [ -z "\$1" ] && return 1 284 [ -z "\$1" ] && return 1
237 285
238 if ! service_started "\$1" 286 if ! service_started "\$1"
239 then 287 then
288 if is_fake_service "\$1" "\${SOFTLEVEL}"
289 then
290 mark_service_started "\$1"
291 else
240 (. /sbin/runscript.sh "/etc/init.d/\$1" start) 292 (. /sbin/runscript.sh "/etc/init.d/\$1" start)
241 293
242 return \$? 294 return \$?
295 fi
243 fi 296 fi
244 297
245 return 0 298 return 0
246} 299}
247 300
252stop_service() { 305stop_service() {
253 [ -z "\$1" ] && return 1 306 [ -z "\$1" ] && return 1
254 307
255 if service_started "\$1" 308 if service_started "\$1"
256 then 309 then
310 if is_runlevel_stop
311 then
312 if is_fake_service "\$1" "\${OLDSOFTLEVEL}"
313 then
314 mark_service_stopped "\$1"
315
316 return 0
317 fi
318 else
319 if is_fake_service "\$1" "\${SOFTLEVEL}"
320 then
321 mark_service_stopped "\$1"
322
323 return 0
324 fi
325 fi
326
257 (. /sbin/runscript.sh "/etc/init.d/\$1" stop) 327 (. /sbin/runscript.sh "/etc/init.d/\$1" stop)
258 328
259 return \$? 329 return \$?
260 fi 330 fi
261 331
262 return 0 332 return 0
263} 333}
531 local list= 601 local list=
532 local netservice="no" 602 local netservice="no"
533 603
534 [ -z "\$1" -o -z "\$2" ] && return 1 604 [ -z "\$1" -o -z "\$2" ] && return 1
535 605
536 for x in ineed iuse iafter
537 do
538 trace_depend "\${x}" "\$1" "list" 606 trace_depend "ineed" "\$1" "list"
607
608 for x in \$1 \${list}
609 do
610 trace_depend "iuse" "\${x}" "list"
611 done
612
613 for x in \$1 \${list}
614 do
615 trace_depend "iafter" "\${x}" "list"
539 done 616 done
540 617
541 net_service "\$2" && netservice="yes" 618 net_service "\$2" && netservice="yes"
542 619
543 for x in \${list} 620 for x in \${list}
561 local list= 638 local list=
562 local netservice="no" 639 local netservice="no"
563 640
564 [ -z "\$1" -o -z "\$2" ] && return 1 641 [ -z "\$1" -o -z "\$2" ] && return 1
565 642
566 for x in needsme usesme ibefore
567 do
568 trace_depend "\${x}" "\$1" "list" 643 trace_depend "needsme" "\$1" "list"
644
645 for x in \$1 \${list}
646 do
647 trace_depend "usesme" "\${x}" "list"
648 done
649
650 for x in \$1 \${list}
651 do
652 trace_depend "ibefore" "\${x}" "list"
569 done 653 done
570 654
571 net_service "\$2" && netservice="yes" 655 net_service "\$2" && netservice="yes"
572 656
573 for x in \${list} 657 for x in \${list}

Legend:
 Removed from v.388 changed lines Added in v.389