/[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 205 Revision 206
66 echo "${index}" 66 echo "${index}"
67 return 0 67 return 0
68 fi 68 fi
69 69
70 for (( x=1; x<=${RC_DEPEND_TREE[0]}; x++ )); do 70 for (( x=1; x<=${RC_DEPEND_TREE[0]}; x++ )); do
71 index=$(( ${x} * ${rc_index_scale} )) 71 index="$(( ${x} * ${rc_index_scale} ))"
72 if [[ ${myservice} == "${RC_DEPEND_TREE[${index}]}" ]] ; then 72 if [[ ${myservice} == "${RC_DEPEND_TREE[${index}]}" ]] ; then
73 echo "${index}" 73 echo "${index}"
74 return 0 74 return 0
75 fi 75 fi
76 done 76 done
89 local myservice="$1" 89 local myservice="$1"
90 90
91 # We already have the right stuff ... 91 # We already have the right stuff ...
92 [[ ${myservice} == "${rc_name}" && -n ${rc_mtime} ]] && return 0 92 [[ ${myservice} == "${rc_name}" && -n ${rc_mtime} ]] && return 0
93 93
94 rc_index="`get_service_index "${myservice}" "${rc_index}"`" 94 rc_index="$(get_service_index "${myservice}" "${rc_index}")"
95 rc_mtime="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_mtime}))]}" 95 rc_mtime="${RC_DEPEND_TREE[$((${rc_index} + ${rc_type_mtime}))]}"
96 96
97 # Verify that we have the correct index (rc_index) ... 97 # Verify that we have the correct index (rc_index) ...
98 # [[ ${rc_index} == "0" ]] && return 1 98 # [[ ${rc_index} == "0" ]] && return 1
99 99
131 else 131 else
132 myservice="$2" 132 myservice="$2"
133 fi 133 fi
134 134
135 if ! get_dep_info "${myservice}" >/dev/null ; then 135 if ! get_dep_info "${myservice}" >/dev/null ; then
136 eerror "Could not get dependency info for \"${myservice}\"!" > /dev/stderr 136 eerror "Could not get dependency info for ${myservice}!" > /dev/stderr
137 eerror "Please run:" > /dev/stderr 137 eerror "Please run:" > /dev/stderr
138 eerror " # /sbin/depscan.sh" > /dev/stderr 138 eerror " # /sbin/depscan.sh" > /dev/stderr
139 eerror "to try and fix this." > /dev/stderr 139 eerror "to try and fix this." > /dev/stderr
140 return 1 140 return 1
141 fi 141 fi
212 local x fake_services 212 local x fake_services
213 213
214 [[ -z $1 || -z $2 ]] && return 1 214 [[ -z $1 || -z $2 ]] && return 1
215 215
216 [[ $2 != "${BOOTLEVEL}" && -e /etc/runlevels/"${BOOTLEVEL}"/.fake ]] && \ 216 [[ $2 != "${BOOTLEVEL}" && -e /etc/runlevels/"${BOOTLEVEL}"/.fake ]] && \
217 fake_services=$( < /etc/runlevels/"${BOOTLEVEL}"/.fake ) 217 fake_services="$( < /etc/runlevels/"${BOOTLEVEL}"/.fake )"
218 218
219 [[ -e /etc/runlevels/"$2"/.fake ]] && \ 219 [[ -e /etc/runlevels/"$2"/.fake ]] && \
220 fake_services="${fake_services} $( < /etc/runlevels/$2/.fake )" 220 fake_services="${fake_services} $( < /etc/runlevels/"$2"/.fake )"
221 221
222 for x in ${fake_services} ; do 222 for x in ${fake_services} ; do
223 [[ $1 == "${x##*/}" ]] && return 0 223 [[ $1 == "${x##*/}" ]] && return 0
224 done 224 done
225 225
269 fi 269 fi
270 270
271 local r="${RC_QUIET_STDOUT}" 271 local r="${RC_QUIET_STDOUT}"
272 RC_QUIET_STDOUT="no" 272 RC_QUIET_STDOUT="no"
273 ${cmd} "$@" 273 ${cmd} "$@"
274 RC_QUIET_STDOUT=${r} 274 RC_QUIET_STDOUT="${r}"
275} 275}
276 276
277# bool begin_service( service ) 277# bool begin_service( service )
278# 278#
279# atomically marks the service as being executed 279# atomically marks the service as being executed
334 [[ ${START_CRITICAL} == "yes" || ${STOP_CRITICAL} == "yes" ]] && return 0 334 [[ ${START_CRITICAL} == "yes" || ${STOP_CRITICAL} == "yes" ]] && return 0
335 [[ ! -e ${fifo} ]] && return 0 335 [[ ! -e ${fifo} ]] && return 0
336 336
337 # This will block until the service fifo is touched 337 # This will block until the service fifo is touched
338 # Otheriwse we don't block 338 # Otheriwse we don't block
339 # We need to use cat instead of the bash inbuilt < so we don't see errors
339 $( < "${fifo}" &>/dev/null ) 340 local tmp="$( cat "${fifo}" 2>/dev/null )"
340 local exitstatus=$( < "${svcdir}/exitcodes/${service}" ) 341 local exitstatus="$( < "${svcdir}/exitcodes/${service}" )"
341 342
342 return "${exitstatus}" 343 return "${exitstatus}"
343} 344}
344 345
345# int start_service(service) 346# int start_service(service)
635 ;; 636 ;;
636 esac 637 esac
637 638
638 # Only worry about net.* services if this is the last one running, 639 # Only worry about net.* services if this is the last one running,
639 # or if RC_NET_STRICT_CHECKING is set ... 640 # or if RC_NET_STRICT_CHECKING is set ...
640 if [[ "${netcount}" -lt 1 || ${RC_NET_STRICT_CHECKING} == "yes" ]] ; then 641 if [[ ${netcount} -lt 1 || ${RC_NET_STRICT_CHECKING} == "yes" ]] ; then
641 return 1 642 return 1
642 fi 643 fi
643 644
644 return 0 645 return 0
645} 646}
709 else 710 else
710 services=( "${myservice}" ) 711 services=( "${myservice}" )
711 fi 712 fi
712 fi 713 fi
713 714
714 net_services=$( cd "${svcdir}"/started; ls net.* 2>/dev/null ) 715 net_services="$( cd "${svcdir}"/started; ls net.* 2>/dev/null )"
715 # If no net services are running or we only have net.lo up, then 716 # If no net services are running or we only have net.lo up, then
716 # assume we are in boot runlevel or starting a new runlevel 717 # assume we are in boot runlevel or starting a new runlevel
717 if [[ -z ${net_services} || ${net_services} == "net.lo" ]]; then 718 if [[ -z ${net_services} || ${net_services} == "net.lo" ]]; then
718 get_net_services() { 719 get_net_services() {
719 local runlevel="$1" 720 local runlevel="$1"
723 ls net.* 2>/dev/null 724 ls net.* 2>/dev/null
724 fi 725 fi
725 } 726 }
726 727
727 local mylevel="${BOOTLEVEL}" 728 local mylevel="${BOOTLEVEL}"
728 local x=$( get_net_services "${mylevel}" ) 729 local x="$( get_net_services "${mylevel}" )"
729 730
730 [[ -f "${svcdir}/softlevel" ]] && mylevel=$( < "${svcdir}/softlevel" ) 731 [[ -f "${svcdir}/softlevel" ]] && mylevel="$( < "${svcdir}/softlevel" )"
731 [[ ${BOOTLEVEL} != "${mylevel}" ]] && \ 732 [[ ${BOOTLEVEL} != "${mylevel}" ]] && \
732 local x="${x} $( get_net_services "${mylevel}" )" 733 local x="${x} $( get_net_services "${mylevel}" )"
733 [[ -n ${x} ]] && net_services="${x}" 734 [[ -n ${x} ]] && net_services="${x}"
734 fi 735 fi
735 736
803 local x list 804 local x list
804 local netservice="no" 805 local netservice="no"
805 806
806 [[ -z $1 || -z $2 ]] && return 1 807 [[ -z $1 || -z $2 ]] && return 1
807 808
808 list=$( trace_dependencies "$1" ) 809 list="$( trace_dependencies "$1" )"
809 810
810 net_service "$2" && netservice="yes" 811 net_service "$2" && netservice="yes"
811 812
812 for x in ${list} ; do 813 for x in ${list} ; do
813 [[ ${x} == "$2" ]] && return 0 814 [[ ${x} == "$2" ]] && return 0

Legend:
Removed from v.205  
changed lines
  Added in v.206

  ViewVC Help
Powered by ViewVC 1.1.20