/[vps]/baselayout-vserver/trunk/sbin/rc-services.sh
Gentoo

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

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

Revision 275 Revision 276
1# Copyright 1999-2004 Gentoo Foundation 1# Copyright 1999-2004 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3 3
4# RC Dependency and misc service functions 4# RC Dependency and misc service functions
5
6RC_GOT_SERVICES="yes" 5RC_GOT_SVCNAMES="yes"
7 6
8[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh 7[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
9 8
10if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then 9if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
11 # Only try and update if we are root 10 # Only try and update if we are root
12 if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh -u ; then 11 if [[ ${EUID} == "0" ]] && ! /sbin/depscan.sh ; then
13 echo 12 echo
14 eerror "Error running '/sbin/depscan.sh'!" 13 eerror "Error running '/sbin/depscan.sh'!"
15 eerror "Please correct any problems above." 14 eerror "Please correct any problems above."
16 exit 1 15 exit 1
17 fi 16 fi
139 eerror "to try and fix this." > /dev/stderr 138 eerror "to try and fix this." > /dev/stderr
140 return 1 139 return 1
141 fi 140 fi
142 141
143 # Do we have valid info for 'deptype' ? 142 # Do we have valid info for 'deptype' ?
144 eval deps=\"\$\{rc_$1\}\" 143 deps="rc_$1"
145 [[ -z ${deps} ]] && return 1 144 [[ -z ${!deps} ]] && return 1
146 145
147 if [[ $2 == "-t" && -n $4 ]]; then 146 if [[ $2 == "-t" && -n $4 ]]; then
148 # Check if 'service1' have 'deptype' dependency on 'service2' 147 # Check if 'service1' have 'deptype' dependency on 'service2'
149 for x in ${deps} ; do 148 for x in ${!deps} ; do
150 [[ ${x} == "$4" ]] && return 0 149 [[ ${x} == "$4" ]] && return 0
151 done 150 done
152 return 1 151 return 1
153 else 152 else
154 # Just list all services that 'service1' have 'deptype' dependency on. 153 # Just list all services that 'service1' have 'deptype' dependency on.
155 echo "${deps}" 154 echo "${!deps}"
156 return 0 155 return 0
157 fi 156 fi
158} 157}
159 158
160# Same as for check_dependency, except 'deptype' is set to 159# Same as for check_dependency, except 'deptype' is set to
506 [[ -z $1 ]] && return 1 505 [[ -z $1 ]] && return 1
507 506
508 rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \ 507 rm -Rf "${svcdir}/daemons/$1" "${svcdir}/starting/$1" \
509 "${svcdir}/started/$1" "${svcdir}/inactive/$1" \ 508 "${svcdir}/started/$1" "${svcdir}/inactive/$1" \
510 "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \ 509 "${svcdir}/wasinactive/$1" "${svcdir}/stopping/$1" \
511 "${svcdir}/scheduled/$1" 510 "${svcdir}/scheduled/$1" "${svcdir}/options/$1"
512 511
513 end_service "$1" 0 512 end_service "$1" 0
514 513
515 return 0 514 return 0
516} 515}
720 local -a services=( "$@" ) net_deps 719 local -a services=( "$@" ) net_deps
721 local i j net_services x 720 local i j net_services x
722 721
723 if [[ $1 == -* ]]; then 722 if [[ $1 == -* ]]; then
724 deptype="${1/-/}" 723 deptype="${1/-/}"
725 if net_service "${myservice}" ; then 724 if net_service "${SVCNAME}" ; then
726 services=( "net" "${myservice}" ) 725 services=( "net" "${SVCNAME}" )
727 else 726 else
728 services=( "${myservice}" ) 727 services=( "${SVCNAME}" )
729 fi 728 fi
730 fi 729 fi
731 730
732 net_services="$( cd "${svcdir}"/started; ls net.* 2>/dev/null )" 731 net_services="$( cd "${svcdir}"/started; ls net.* 2>/dev/null )"
733 # If no net services are running or we only have net.lo up, then 732 # If no net services are running or we only have net.lo up, then
798 services=( "${sorted[@]}" ) 797 services=( "${sorted[@]}" )
799 798
800 if [[ -n ${deptype} ]] ; then 799 if [[ -n ${deptype} ]] ; then
801 # If deptype is set, we do not want the name of this service 800 # If deptype is set, we do not want the name of this service
802 x=" ${services[@]} " 801 x=" ${services[@]} "
803 services=( ${x// ${myservice} / } ) 802 services=( ${x// ${SVCNAME} / } )
804 803
805 # If its a net service, do not include "net" 804 # If its a net service, do not include "net"
806 if net_service "${myservice}" ; then 805 if net_service "${SVCNAME}" ; then
807 x=" ${services[@]} " 806 x=" ${services[@]} "
808 sorted=( ${services// net / } ) 807 sorted=( ${services// net / } )
809 fi 808 fi
810 fi 809 fi
811 810

Legend:
Removed from v.275  
changed lines
  Added in v.276

  ViewVC Help
Powered by ViewVC 1.1.20