/[gentoo-alt]/trunk/baselayout-prefix/sbin/rc-services.sh
Gentoo

Diff of /trunk/baselayout-prefix/sbin/rc-services.sh

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

Revision 1683 Revision 1684
6 6
7[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh 7[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
8 8
9if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then 9if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
10 # Only try and update if we are root 10 # Only try and update if we are root
11 if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh ; then 11 if [[ ${EUID} == "0" ]] && ! @GENTOO_PORTAGE_EPREFIX@/sbin/depscan.sh ; then
12 echo 12 echo
13 eerror "Error running '/sbin/depscan.sh'!" 13 eerror "Error running '@GENTOO_PORTAGE_EPREFIX@/sbin/depscan.sh'!"
14 eerror "Please correct any problems above." 14 eerror "Please correct any problems above."
15 exit 1 15 exit 1
16 fi 16 fi
17 17
18 source "${svcdir}/deptree" 18 source "${svcdir}/deptree"
19 if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then 19 if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
20 echo 20 echo
21 eerror "Dependency info is missing! Please run" 21 eerror "Dependency info is missing! Please run"
22 eerror " # /sbin/depscan.sh" 22 eerror " # @GENTOO_PORTAGE_EPREFIX@/sbin/depscan.sh"
23 eerror "to fix this." 23 eerror "to fix this."
24 exit 1 24 exit 1
25 fi 25 fi
26fi 26fi
27 27
132 fi 132 fi
133 133
134 if ! get_dep_info "${myservice}" >/dev/null ; then 134 if ! get_dep_info "${myservice}" >/dev/null ; then
135 eerror "Could not get dependency info for ${myservice}!" > /dev/stderr 135 eerror "Could not get dependency info for ${myservice}!" > /dev/stderr
136 eerror "Please run:" > /dev/stderr 136 eerror "Please run:" > /dev/stderr
137 eerror " # /sbin/depscan.sh" > /dev/stderr 137 eerror " # @GENTOO_PORTAGE_EPREFIX@/sbin/depscan.sh" > /dev/stderr
138 eerror "to try and fix this." > /dev/stderr 138 eerror "to try and fix this." > /dev/stderr
139 return 1 139 return 1
140 fi 140 fi
141 141
142 # Do we have valid info for 'deptype' ? 142 # Do we have valid info for 'deptype' ?
210is_fake_service() { 210is_fake_service() {
211 local x fake_services 211 local x fake_services
212 212
213 [[ -z $1 || -z $2 ]] && return 1 213 [[ -z $1 || -z $2 ]] && return 1
214 214
215 [[ $2 != "${BOOTLEVEL}" && -e /etc/runlevels/"${BOOTLEVEL}"/.fake ]] && \ 215 [[ $2 != "${BOOTLEVEL}" && -e @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/"${BOOTLEVEL}"/.fake ]] && \
216 fake_services="$( < /etc/runlevels/"${BOOTLEVEL}"/.fake )" 216 fake_services="$( < @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/"${BOOTLEVEL}"/.fake )"
217 217
218 [[ -e /etc/runlevels/"$2"/.fake ]] && \ 218 [[ -e @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/"$2"/.fake ]] && \
219 fake_services="${fake_services} $( < /etc/runlevels/"$2"/.fake )" 219 fake_services="${fake_services} $( < @GENTOO_PORTAGE_EPREFIX@/etc/runlevels/"$2"/.fake )"
220 220
221 for x in ${fake_services} ; do 221 for x in ${fake_services} ; do
222 [[ $1 == "${x##*/}" ]] && return 0 222 [[ $1 == "${x##*/}" ]] && return 0
223 done 223 done
224 224
230# Returns true if 'service' is in runlevel 'runlevel'. 230# Returns true if 'service' is in runlevel 'runlevel'.
231# 231#
232in_runlevel() { 232in_runlevel() {
233 [[ -z $1 || -z $2 ]] && return 1 233 [[ -z $1 || -z $2 ]] && return 1
234 234
235 [[ -L "/etc/runlevels/$2/$1" ]] && return 0 235 [[ -L "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/$2/$1" ]] && return 0
236 236
237 return 1 237 return 1
238} 238}
239 239
240# bool is_runlevel_start() 240# bool is_runlevel_start()
383# 383#
384start_service() { 384start_service() {
385 local service="$1" 385 local service="$1"
386 [[ -z ${service} ]] && return 1 386 [[ -z ${service} ]] && return 1
387 387
388 if [[ ! -e "/etc/init.d/${service}" ]] ; then 388 if [[ ! -e "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" ]] ; then
389 mark_service_stopped "${service}" 389 mark_service_stopped "${service}"
390 return 1 390 return 1
391 fi 391 fi
392 392
393 service_starting "${service}" && return 0 393 service_starting "${service}" && return 0
406 if [[ ${RC_PARALLEL_STARTUP} != "yes" || \ 406 if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
407 ${START_CRITICAL} == "yes" ]] ; then 407 ${START_CRITICAL} == "yes" ]] ; then
408 # if we can not start the services in parallel 408 # if we can not start the services in parallel
409 # then just start it and return the exit status 409 # then just start it and return the exit status
410 ( 410 (
411 profiling name "/etc/init.d/${service} start" 411 profiling name "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service} start"
412 "/etc/init.d/${service}" start 412 "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" start
413 ) 413 )
414 414
415 service_started "${service}" || service_inactive "${service}" \ 415 service_started "${service}" || service_inactive "${service}" \
416 || service_scheduled "${service}" 416 || service_scheduled "${service}"
417 retval=$? 417 retval=$?
421 421
422 return "${retval}" 422 return "${retval}"
423 else 423 else
424 # if parallel startup is allowed, start it in background 424 # if parallel startup is allowed, start it in background
425 ( 425 (
426 profiling name "/etc/init.d/${service} start" 426 profiling name "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service} start"
427 "/etc/init.d/${service}" start 427 "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" start
428 428
429 service_started "${service}" || service_inactive "${service}" \ 429 service_started "${service}" || service_inactive "${service}" \
430 || service_scheduled "${service}" 430 || service_scheduled "${service}"
431 retval=$? 431 retval=$?
432 432
443# 443#
444stop_service() { 444stop_service() {
445 local service="$1" 445 local service="$1"
446 [[ -z ${service} ]] && return 1 446 [[ -z ${service} ]] && return 1
447 447
448 if [[ ! -e "/etc/init.d/${service}" ]] ; then 448 if [[ ! -e "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" ]] ; then
449 mark_service_stopped "${service}" 449 mark_service_stopped "${service}"
450 return 0 450 return 0
451 fi 451 fi
452 452
453 service_stopping "${service}" && return 0 453 service_stopping "${service}" && return 0
468 splash "svc_stop" "${service}" 468 splash "svc_stop" "${service}"
469 if [[ ${RC_PARALLEL_STARTUP} != "yes" || \ 469 if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
470 ${STOP_CRITICAL} == "yes" ]] ; then 470 ${STOP_CRITICAL} == "yes" ]] ; then
471 # if we can not start the services in parallel 471 # if we can not start the services in parallel
472 # then just start it and return the exit status 472 # then just start it and return the exit status
473 ( "/etc/init.d/${service}" stop ) 473 ( "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" stop )
474 service_stopped "${service}" 474 service_stopped "${service}"
475 retval=$? 475 retval=$?
476 end_service "${service}" "${retval}" 476 end_service "${service}" "${retval}"
477 splash "svc_stopped" "${service}" "${retval}" 477 splash "svc_stopped" "${service}" "${retval}"
478 return "${retval}" 478 return "${retval}"
479 else 479 else
480 # if parallel startup is allowed, start it in background 480 # if parallel startup is allowed, start it in background
481 ( 481 (
482 ( "/etc/init.d/${service}" stop ) 482 ( "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/${service}" stop )
483 service_stopped "${service}" 483 service_stopped "${service}"
484 retval=$? 484 retval=$?
485 end_service "${service}" "${retval}" 485 end_service "${service}" "${retval}"
486 splash "svc_stopped" "${service}" "${retval}" 486 splash "svc_stopped" "${service}" "${retval}"
487 ) & 487 ) &
494# Mark 'service' as coldplugged. 494# Mark 'service' as coldplugged.
495# 495#
496mark_service_coldplugged() { 496mark_service_coldplugged() {
497 [[ -z $1 ]] && return 1 497 [[ -z $1 ]] && return 1
498 498
499 ln -snf "/etc/init.d/$1" "${svcdir}/coldplugged/$1" 499 ln -snf "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/coldplugged/$1"
500 return 0 500 return 0
501} 501}
502 502
503# bool mark_service_starting(service) 503# bool mark_service_starting(service)
504# 504#
505# Mark 'service' as starting. 505# Mark 'service' as starting.
506# 506#
507mark_service_starting() { 507mark_service_starting() {
508 [[ -z $1 ]] && return 1 508 [[ -z $1 ]] && return 1
509 509
510 ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1 510 ln -sn "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1
511 511
512 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1" 512 [[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
513 [[ -f "${svcdir}/inactive/$1" ]] \ 513 [[ -f "${svcdir}/inactive/$1" ]] \
514 && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1" 514 && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1"
515 return 0 515 return 0
520# Mark 'service' as started. 520# Mark 'service' as started.
521# 521#
522mark_service_started() { 522mark_service_started() {
523 [[ -z $1 ]] && return 1 523 [[ -z $1 ]] && return 1
524 524
525 ln -snf "/etc/init.d/$1" "${svcdir}/started/$1" 525 ln -snf "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/started/$1"
526 526
527 rm -f "${svcdir}/starting/$1" "${svcdir}/inactive/$1" \ 527 rm -f "${svcdir}/starting/$1" "${svcdir}/inactive/$1" \
528 "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \ 528 "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
529 "${svcdir}"/scheduled/*/"$1" 529 "${svcdir}"/scheduled/*/"$1"
530 530
536# Mark service as inactive 536# Mark service as inactive
537# 537#
538mark_service_inactive() { 538mark_service_inactive() {
539 [[ -z $1 ]] && return 1 539 [[ -z $1 ]] && return 1
540 540
541 ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1" 541 ln -snf "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/inactive/$1"
542 542
543 rm -f "${svcdir}/started/$1" "${svcdir}/wasinactive/$1" \ 543 rm -f "${svcdir}/started/$1" "${svcdir}/wasinactive/$1" \
544 "${svcdir}/starting/$1" "${svcdir}/stopping/$1" 544 "${svcdir}/starting/$1" "${svcdir}/stopping/$1"
545 545
546 return 0 546 return 0
551# Mark 'service' as stopping. 551# Mark 'service' as stopping.
552# 552#
553mark_service_stopping() { 553mark_service_stopping() {
554 [[ -z $1 ]] && return 1 554 [[ -z $1 ]] && return 1
555 555
556 ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1 556 ln -sn "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1
557 557
558 rm -f "${svcdir}/started/$1" 558 rm -f "${svcdir}/started/$1"
559 [[ -f "${svcdir}/inactive/$1" ]] \ 559 [[ -f "${svcdir}/inactive/$1" ]] \
560 && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1" 560 && mv "${svcdir}/inactive/$1" "${svcdir}/wasinactive/$1"
561 561
688# this is only valid on runlevel change ... 688# this is only valid on runlevel change ...
689# 689#
690mark_service_failed() { 690mark_service_failed() {
691 [[ -z $1 || ! -d "${svcdir}/failed" ]] && return 1 691 [[ -z $1 || ! -d "${svcdir}/failed" ]] && return 1
692 692
693 ln -snf "/etc/init.d/$1" "${svcdir}/failed/$1" 693 ln -snf "@GENTOO_PORTAGE_EPREFIX@/etc/init.d/$1" "${svcdir}/failed/$1"
694} 694}
695 695
696# bool service_failed(service) 696# bool service_failed(service)
697# 697#
698# Return true if 'service' have failed during this runlevel. 698# Return true if 'service' have failed during this runlevel.
742 lo) 742 lo)
743 service_started "net.lo" 743 service_started "net.lo"
744 return $? 744 return $?
745 ;; 745 ;;
746 yes) 746 yes)
747 for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ 747 for x in $(dolisting "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${BOOTLEVEL}/net.*") \
748 $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") ; do 748 $(dolisting "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${SOFTLEVEL}/net.*") ; do
749 local y="${x##*/}" 749 local y="${x##*/}"
750 [[ ${y} == "$1" ]] && return 1 750 [[ ${y} == "$1" ]] && return 1
751 service_started "${y}" || return 1 751 service_started "${y}" || return 1
752 done 752 done
753 return 0 753 return 0
783 783
784 # Cannot be SOFTLEVEL, as we need to know current runlevel 784 # Cannot be SOFTLEVEL, as we need to know current runlevel
785 [[ -f "${svcdir}/softlevel" ]] && mylevel=$( < "${svcdir}/softlevel" ) 785 [[ -f "${svcdir}/softlevel" ]] && mylevel=$( < "${svcdir}/softlevel" )
786 786
787 for x in $( i$1 "$2" ) ; do 787 for x in $( i$1 "$2" ) ; do
788 [[ -e "/etc/runlevels/${BOOTLEVEL}/${x}" || \ 788 [[ -e "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${BOOTLEVEL}/${x}" || \
789 -e "/etc/runlevels/${mylevel}/${x}" || \ 789 -e "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${mylevel}/${x}" || \
790 ${x} == "net" ]] \ 790 ${x} == "net" ]] \
791 && valid="${valid} ${x}" 791 && valid="${valid} ${x}"
792 done 792 done
793 793
794 echo "${valid:1}" 794 echo "${valid:1}"
834 for x in $(dolisting "${svcdir}/started/net.*") \ 834 for x in $(dolisting "${svcdir}/started/net.*") \
835 $(dolisting "${svcdir}/inactive/net.*") ; do 835 $(dolisting "${svcdir}/inactive/net.*") ; do
836 net_services="${net_services} ${x##*/}" 836 net_services="${net_services} ${x##*/}"
837 done 837 done
838 else 838 else
839 for x in $(dolisting "/etc/runlevels/${BOOTLEVEL}/net.*") \ 839 for x in $(dolisting "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${BOOTLEVEL}/net.*") \
840 $(dolisting "/etc/runlevels/${SOFTLEVEL}/net.*") \ 840 $(dolisting "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/${SOFTLEVEL}/net.*") \
841 $(dolisting "/etc/runlevels/coldplugged/net.*") ; do 841 $(dolisting "@GENTOO_PORTAGE_EPREFIX@/etc/runlevels/coldplugged/net.*") ; do
842 net_services="${net_services} ${x##*/}" 842 net_services="${net_services} ${x##*/}"
843 done 843 done
844 fi 844 fi
845 845
846 # Cache the generic "net" depends 846 # Cache the generic "net" depends

Legend:
Removed from v.1683  
changed lines
  Added in v.1684

  ViewVC Help
Powered by ViewVC 1.1.20