/[vps]/baselayout-vserver/branches/baselayout-1_12/sbin/rc-services.sh
Gentoo

Diff of /baselayout-vserver/branches/baselayout-1_12/sbin/rc-services.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 200 Revision 201
242# 242#
243# 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
244# starting services. 244# starting services.
245# 245#
246is_runlevel_start() { 246is_runlevel_start() {
247 [[ -d "${svcdir}/softscripts.old" && \ 247 [[ -d "${svcdir}/softscripts.old" ]]
248 ${SOFTLEVEL} != "${OLDSOFTLEVEL}" ]] && return 0
249
250 return 1
251} 248}
252 249
253# bool is_runlevel_stop() 250# bool is_runlevel_stop()
254# 251#
255# Returns true if it is a runlevel change, and we are busy 252# Returns true if it is a runlevel change, and we are busy
256# stopping services. 253# stopping services.
257# 254#
258is_runlevel_stop() { 255is_runlevel_stop() {
259 [[ -d "${svcdir}/softscripts.new" && \ 256 [[ -d "${svcdir}/softscripts.new" ]]
260 ${SOFTLEVEL} != "${OLDSOFTLEVEL}" ]] && return 0
261
262 return 1
263} 257}
264 258
265# void sevice_message([char *type] char *message) 259# void sevice_message([char *type] char *message)
266# 260#
267# Print out a service message if we are on parallel 261# Print out a service message if we are on parallel
288# if begin_service service ; then 282# if begin_service service ; then
289# whatever is in here can only be executed by one process 283# whatever is in here can only be executed by one process
290# end_service service 284# end_service service
291# fi 285# fi
292begin_service() { 286begin_service() {
287 local service="$1"
288 [[ -z ${service} ]] && return 1
289
293 [[ {$START_CRITICAL} == "yes" ]] && return 0 290 [[ ${START_CRITICAL} == "yes" ]] && return 0
294 291
295 mkfifo "${svcdir}/exclusive/${service}" 2> /dev/null 292 mkfifo "${svcdir}/exclusive/${service}" 2> /dev/null
296 return $?
297} 293}
298 294
299# void end_service(service, exitcode) 295# void end_service(service, exitcode)
300# 296#
301# stops executing a exclusive region and 297# stops executing a exclusive region and
302# wakes up anybody who is waiting for the exclusive region 298# wakes up anybody who is waiting for the exclusive region
303# 299#
304end_service() { 300end_service() {
305 local service="$1" exitstatus="$2" 301 local service="$1" exitstatus="$2"
302 [[ -z ${service} ]] && return
306 303
307 # if we are doing critical services, there is no fifo 304 # if we are doing critical services, there is no fifo
308 [[ ${START_CRITICAL} == "yes" ]] && return 305 [[ ${START_CRITICAL} == "yes" ]] && return
309 306
310 if [[ -n ${exitstatus} ]] ; then 307 if [[ -n ${exitstatus} ]] ; then
355 352
356 if [[ ! -e "/etc/init.d/${service}" ]] ; then 353 if [[ ! -e "/etc/init.d/${service}" ]] ; then
357 mark_service_stopped "${service}" 354 mark_service_stopped "${service}"
358 return 1 355 return 1
359 fi 356 fi
360 357
361 service_starting "${service}" && return 0 358 service_starting "${service}" && return 0
362 service_started "${service}" && return 0 359 service_started "${service}" && return 0
363 service_inactive "${service}" && return 1 360 service_inactive "${service}" && return 1
364 361
365 if is_fake_service "${service}" "${SOFTLEVEL}" ; then 362 if is_fake_service "${service}" "${SOFTLEVEL}" ; then
437# Mark 'service' as starting. 434# Mark 'service' as starting.
438# 435#
439mark_service_starting() { 436mark_service_starting() {
440 [[ -z $1 ]] && return 1 437 [[ -z $1 ]] && return 1
441 438
442 ln -snf "/etc/init.d/$1" "${svcdir}/starting/$1" 439 ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1
443 local retval=$? 440
444 441 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
445 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" 442 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
446 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" 443 return 0
447 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
448
449 return "${retval}"
450} 444}
451 445
452# bool mark_service_started(service) 446# bool mark_service_started(service)
453# 447#
454# Mark 'service' as started. 448# Mark 'service' as started.
455# 449#
456mark_service_started() { 450mark_service_started() {
457 [[ -z $1 ]] && return 1 451 [[ -z $1 ]] && return 1
458 452
459 ln -snf "/etc/init.d/$1" "${svcdir}/started/$1" 453 ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
460 local retval=$?
461 454
462 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" 455 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
463 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" 456 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
464 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" 457 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
465 458
466 return "${retval}" 459 return 0
467} 460}
468 461
469# bool mark_service_inactive(service) 462# bool mark_service_inactive(service)
470# 463#
471# Mark service as inactive 464# Mark service as inactive
472# 465#
473mark_service_inactive() { 466mark_service_inactive() {
474 [[ -z $1 ]] && return 1 467 [[ -z $1 ]] && return 1
475 468
476 ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1" 469 ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
477 local retval=$? 470
478 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" 471 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
479 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" 472 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
480 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" 473 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
481 474
482 return "${retval}" 475 return 0
483} 476}
484 477
485# bool mark_service_stopping(service) 478# bool mark_service_stopping(service)
486# 479#
487# Mark 'service' as stopping. 480# Mark 'service' as stopping.
488# 481#
489mark_service_stopping() { 482mark_service_stopping() {
490 [[ -z $1 ]] && return 1 483 [[ -z $1 ]] && return 1
491 484
492 ln -snf "/etc/init.d/$1" "${svcdir}/stopping/$1" 485 ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1
493 local retval=$? 486
494
495 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" 487 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
496 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" 488 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
497 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" 489 return 0
498
499 return "${retval}"
500} 490}
501 491
502# bool mark_service_stopped(service) 492# bool mark_service_stopped(service)
503# 493#
504# Mark 'service' as stopped. 494# Mark 'service' as stopped.
510 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1" 500 [[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
511 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" 501 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
512 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1" 502 [[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
513 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1" 503 [[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
514 504
515 return $? 505 return 0
516} 506}
517 507
518# bool test_service_state(char *service, char *state) 508# bool test_service_state(char *service, char *state)
519# 509#
520# Returns 0 if the service link exists and points to a file, otherwise 1 510# Returns 0 if the service link exists and points to a file, otherwise 1

Legend:
Removed from v.200  
changed lines
  Added in v.201

  ViewVC Help
Powered by ViewVC 1.1.20