/[baselayout]/trunk/sbin/runscript.sh
Gentoo

Diff of /trunk/sbin/runscript.sh

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

Revision 388 Revision 389
44# (3) Source /etc/conf.d/net if it is a net.* service 44# (3) Source /etc/conf.d/net if it is a net.* service
45# (4) Source /etc/rc.conf to pick up potentially overriding 45# (4) Source /etc/rc.conf to pick up potentially overriding
46# configuration, if the system administrator chose to put it 46# configuration, if the system administrator chose to put it
47# there (if it exists). 47# there (if it exists).
48 48
49[ -e "/etc/conf.d/basic" ] && source /etc/conf.d/basic 49[ -e "$(add_suffix /etc/conf.d/basic)" ] && source "$(add_suffix /etc/conf.d/basic)"
50 50
51[ -e "/etc/conf.d/${myservice}" ] && source "/etc/conf.d/${myservice}" 51[ -e "$(add_suffix /etc/conf.d/${myservice})" ] && source "$(add_suffix /etc/conf.d/${myservice})"
52 52
53[ -e "/etc/conf.d/net" ] && \ 53[ -e "$(add_suffix /etc/conf.d/net)" ] && \
54[ "${myservice%%.*}" = "net" ] && \ 54[ "${NETSERVICE}" = "yes" ] && source "$(add_suffix /etc/conf.d/net)"
55[ "${myservice##*.}" != "${myservice}" ] && source /etc/conf.d/net
56 55
57[ -e "/etc/rc.conf" ] && source /etc/rc.conf 56[ -e "$(add_suffix /etc/rc.conf)" ] && source "$(add_suffix /etc/rc.conf)"
58 57
59 58
60usage() { 59usage() {
61 local IFS="|" 60 local IFS="|"
62 myline="Usage: ${myservice} { $* " 61 myline="Usage: ${myservice} { $* "
102 return 0 101 return 0
103 fi 102 fi
104 fi 103 fi
105 104
106 # Do not try to stop if it had already failed to do so on runlevel change 105 # Do not try to stop if it had already failed to do so on runlevel change
107 if runlevel_stop && service_failed "${myservice}" 106 if is_runlevel_stop && service_failed "${myservice}"
108 then 107 then
109 exit 1 108 exit 1
110 fi 109 fi
111 110
112 # Remove symlink to prevent recursion 111 # Remove symlink to prevent recursion
147 for mydep in ${mydeps} 146 for mydep in ${mydeps}
148 do 147 do
149 # If some service 'need' $mydep, stop it first; or if it is a runlevel change, 148 # If some service 'need' $mydep, stop it first; or if it is a runlevel change,
150 # first stop all services that is started 'after' $mydep. 149 # first stop all services that is started 'after' $mydep.
151 if needsme "${mydep}" &>/dev/null || \ 150 if needsme "${mydep}" &>/dev/null || \
152 (runlevel_stop && ibefore "${mydep}" &>/dev/null) 151 (is_runlevel_stop && ibefore "${mydep}" &>/dev/null)
153 then 152 then
154 local servicelist="$(needsme "${mydep}")" 153 local servicelist="$(needsme "${mydep}")"
155 154
156 # On runlevel change, stop all services "after $mydep" first ... 155 # On runlevel change, stop all services "after $mydep" first ...
157 runlevel_stop && servicelist="${servicelist} $(ibefore "${mydep}")" 156 is_runlevel_stop && servicelist="${servicelist} $(ibefore "${mydep}")"
158 157
159 for x in ${servicelist} 158 for x in ${servicelist}
160 do 159 do
161 # Make sure we have a relevant rc-script ... 160 # Make sure we have a relevant rc-script ...
162 if [ "${x}" != "net" -a ! -f "/etc/init.d/${x}" ] 161 if [ "${x}" != "net" -a ! -f "/etc/init.d/${x}" ]
197 then 196 then
198 eerror "ERROR: problems stopping dependent services." 197 eerror "ERROR: problems stopping dependent services."
199 eerror " \"${myservice}\" is still up." 198 eerror " \"${myservice}\" is still up."
200 else 199 else
201 # Now that deps are stopped, stop our service 200 # Now that deps are stopped, stop our service
202 stop 201 (filter_environ; stop)
203 retval="$?" 202 retval="$?"
204 fi 203 fi
205 204
206 if [ "${retval}" -ne 0 ] 205 if [ "${retval}" -ne 0 ]
207 then 206 then
208 # Did we fail to stop? create symlink to stop multible attempts at 207 # Did we fail to stop? create symlink to stop multible attempts at
209 # runlevel change. Note this is only used at runlevel change ... 208 # runlevel change. Note this is only used at runlevel change ...
210 if runlevel_stop 209 if is_runlevel_stop
211 then 210 then
212 mark_service_failed "${myservice}" 211 mark_service_failed "${myservice}"
213 fi 212 fi
214 213
215 # If we are halting the system, do it as cleanly as possible 214 # If we are halting the system, do it as cleanly as possible
231 local ordservice= 230 local ordservice=
232 231
233 if ! service_started "${myservice}" 232 if ! service_started "${myservice}"
234 then 233 then
235 # Do not try to start if i have done so already on runlevel change 234 # Do not try to start if i have done so already on runlevel change
236 if runlevel_start && service_failed "${myservice}" 235 if is_runlevel_start && service_failed "${myservice}"
237 then 236 then
238 exit 1 237 exit 1
239 fi 238 fi
240 239
241 # Link first to prevent possible recursion 240 # Link first to prevent possible recursion
242 mark_service_started "${myservice}" 241 mark_service_started "${myservice}"
243 242
244 # On rc change, start all services "before $myservice" first 243 # On rc change, start all services "before $myservice" first
245 if runlevel_start 244 if is_runlevel_start
246 then 245 then
247 startupservices="$(ineed "${myservice}") \ 246 startupservices="$(ineed "${myservice}") \
248 $(valid_iuse "${myservice}") \ 247 $(valid_iuse "${myservice}") \
249 $(valid_iafter "${myservice}")" 248 $(valid_iafter "${myservice}")"
250 else 249 else
314 eerror " './${myservice} broken' for a list of those" 313 eerror " './${myservice} broken' for a list of those"
315 eerror " services. \"${myservice}\" was not started." 314 eerror " services. \"${myservice}\" was not started."
316 retval=1 315 retval=1
317 elif [ "${retval}" -eq 0 ] && ! broken "${myservice}" &>/dev/null 316 elif [ "${retval}" -eq 0 ] && ! broken "${myservice}" &>/dev/null
318 then 317 then
319 start 318 (filter_environ; start)
320 retval="$?" 319 retval="$?"
321 fi 320 fi
322 321
323 if [ "${retval}" -ne 0 ] && runlevel_start 322 if [ "${retval}" -ne 0 ] && is_runlevel_start
324 then 323 then
325 mark_service_failed "${myservice}" 324 mark_service_failed "${myservice}"
326 fi 325 fi
327 326
328 # Remove link if service didn't start; but only if we're not booting 327 # Remove link if service didn't start; but only if we're not booting
408 if [ "${x}" = "${arg}" ] 407 if [ "${x}" = "${arg}" ]
409 then 408 then
410 if typeset -F "${x}" &>/dev/null 409 if typeset -F "${x}" &>/dev/null
411 then 410 then
412 # Run the homegrown function 411 # Run the homegrown function
413 "${x}" 412 (filter_environ; "${x}")
414 413
415 return $? 414 return $?
416 fi 415 fi
417 fi 416 fi
418 done 417 done

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

  ViewVC Help
Powered by ViewVC 1.1.20