/[baselayout]/branches/baselayout-1_12/sbin/runscript.sh
Gentoo

Diff of /branches/baselayout-1_12/sbin/runscript.sh

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

Revision 1379 Revision 1380
90 local was_inactive=false 90 local was_inactive=false
91 91
92 if service_stopping "${myservice}" ; then 92 if service_stopping "${myservice}" ; then
93 eerror "ERROR: \"${myservice}\" is already stopping." 93 eerror "ERROR: \"${myservice}\" is already stopping."
94 return 0 94 return 0
95 fi
96
97 if service_stopped "${myservice}" ; then 95 elif service_stopped "${myservice}" ; then
98 eerror "ERROR: \"${myservice}\" has not yet been started." 96 eerror "ERROR: \"${myservice}\" has not yet been started."
99 return 0 97 return 0
100 fi 98 fi
101 99
102 # Do not try to stop if it had already failed to do so on runlevel change 100 # Do not try to stop if it had already failed to do so on runlevel change
169 continue 167 continue
170 fi 168 fi
171 169
172 stop_service "${x}" 170 stop_service "${x}"
173 171
174 if [[ $? -ne 0 ]] ; then 172 if ! service_stopped "${x}" ; then
175 # If we are halting the system, try and get it down as 173 # If we are halting the system, try and get it down as
176 # clean as possible, else do not stop our service if 174 # clean as possible, else do not stop our service if
177 # a dependent service did not stop. 175 # a dependent service did not stop.
178 if needsme -t "${mydep}" "${x}" >/dev/null && \ 176 if needsme -t "${mydep}" "${x}" >/dev/null && \
179 [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] 177 [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]]
217 mark_service_inactive "${myservice}" 215 mark_service_inactive "${myservice}"
218 else 216 else
219 mark_service_started "${myservice}" 217 mark_service_started "${myservice}"
220 fi 218 fi
221 fi 219 fi
220
221 service_message "eerror" "FAILED to stop service ${myservice}!"
222 else 222 else
223 # If we're stopped from a daemon that sets ${IN_BACKGROUND} such as 223 # If we're stopped from a daemon that sets ${IN_BACKGROUND} such as
224 # wpa_monitor when we mark as inactive instead of taking the down 224 # wpa_monitor when we mark as inactive instead of taking the down
225 if ${IN_BACKGROUND:-false} ; then 225 if ${IN_BACKGROUND:-false} ; then
226 mark_service_inactive "${myservice}" 226 mark_service_inactive "${myservice}"
227 else 227 else
228 mark_service_stopped "${myservice}" 228 mark_service_stopped "${myservice}"
229 fi 229 fi
230 fi
231
232 if [[ ${retval} == 0 ]]; then
233 service_message "Stopped service ${myservice}" 230 service_message "Stopped service ${myservice}"
234 else
235 service_message "eerror" "FAILED to stop service ${myservice}!"
236 fi 231 fi
237 232
238 return "${retval}" 233 return "${retval}"
239} 234}
240 235
244 local x= 239 local x=
245 local y= 240 local y=
246 local myserv= 241 local myserv=
247 local ordservice= 242 local ordservice=
248 243
244 if service_starting "${myservice}" ; then
245 ewarn "WARNING: \"${myservice}\" is already starting."
246 return 0
249 if service_stopping "${myservice}" ; then 247 elif service_stopping "${myservice}" ; then
250 ewarn "WARNING: please wait for \"${myservice}\" to stop first." 248 ewarn "WARNING: please wait for \"${myservice}\" to stop first."
251 return 0 249 return 0
252 fi
253
254 if service_inactive "${myservice}" ; then 250 elif service_inactive "${myservice}" ; then
255 if [[ ${IN_BACKGROUND} != "true" ]] ; then 251 if [[ ${IN_BACKGROUND} != "true" ]] ; then
256 ewarn "WARNING: \"${myservice}\" has already been started." 252 ewarn "WARNING: \"${myservice}\" has already been started."
257 return 0 253 return 0
258 fi 254 fi
259 else
260 if service_started "${myservice}" ; then 255 elif service_started "${myservice}" ; then
261 ewarn "WARNING: \"${myservice}\" has already been started." 256 ewarn "WARNING: \"${myservice}\" has already been started."
262 return 0 257 return 0
263 elif service_starting "${myservice}" ; then
264 ewarn "WARNING: \"${myservice}\" is already starting."
265 return 0
266 fi
267 fi 258 fi
268 259
269 # Do not try to start if i have done so already on runlevel change 260 # Do not try to start if i have done so already on runlevel change
270 if is_runlevel_start && service_failed "${myservice}" ; then 261 if is_runlevel_start && service_failed "${myservice}" ; then
271 return 1 262 return 1
272 fi 263 fi
273 264
274 # Link first to prevent possible recursion
275 mark_service_starting "${myservice}" 265 mark_service_starting "${myservice}"
276
277 service_message "Starting service ${myservice}" 266 service_message "Starting service ${myservice}"
278 267
279 # On rc change, start all services "before $myservice" first 268 # On rc change, start all services "before $myservice" first
280 if is_runlevel_start ; then 269 if is_runlevel_start ; then
281 startupservices="$(ineed "${myservice}") \ 270 startupservices="$(ineed "${myservice}") \
341 330
342 if [[ ${startfail} == "yes" ]] ; then 331 if [[ ${startfail} == "yes" ]] ; then
343 eerror "ERROR: Problem starting needed services." 332 eerror "ERROR: Problem starting needed services."
344 eerror " \"${myservice}\" was not started." 333 eerror " \"${myservice}\" was not started."
345 retval=1 334 retval=1
335 elif broken "${myservice}" ; then
336 eerror "ERROR: Some services needed are missing. Run"
337 eerror " './${myservice} broken' for a list of those"
338 eerror " services. \"${myservice}\" was not started."
339 retval=1
346 else 340 else
347 if broken "${myservice}" ; then
348 eerror "ERROR: Some services needed are missing. Run"
349 eerror " './${myservice} broken' for a list of those"
350 eerror " services. \"${myservice}\" was not started."
351 retval=1
352 else
353 ( 341 (
354 exit() { 342 exit() {
355 RC_QUIET_STDOUT="no" 343 RC_QUIET_STDOUT="no"
356 eerror "DO NOT USE EXIT IN INIT.D SCRIPTS" 344 eerror "DO NOT USE EXIT IN INIT.D SCRIPTS"
357 eerror "This IS a bug, please fix your broken init.d" 345 eerror "This IS a bug, please fix your broken init.d"
358 unset -f exit 346 unset -f exit
359 exit $@ 347 exit $@
360 } 348 }
361 # Stop einfo/ebegin/eend from working as parallel messes us up 349 # Stop einfo/ebegin/eend from working as parallel messes us up
362 [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes" 350 [[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes"
363 start 351 start
364 ) 352 )
365 retval=$? 353 retval=$?
366 354
367 # If a service has been marked inactive, exit now as something 355 # If a service has been marked inactive, exit now as something
368 # may attempt to start it again later 356 # may attempt to start it again later
369 service_inactive "${myservice}" && return 1 357 service_inactive "${myservice}" && return 1
370 fi 358 fi
371 fi
372 359
373 if [[ ${retval} -ne 0 ]] && is_runlevel_start ; then 360 if [[ ${retval} != 0 ]]; then
374 mark_service_failed "${myservice}" 361 is_runlevel_start && mark_service_failed "${myservice}"
375 fi
376 362
377 # Remove link if service didn't start; but only if we're not booting 363 # Remove link if service didn't start; but only if we're not booting
378 # if we're booting, we need to continue and do our best to get the 364 # If we're booting, we need to continue and do our best to get the
379 # system up. 365 # system up.
380 if [[ ${retval} -ne 0 ]] && [[ ${SOFTLEVEL} != ${BOOTLEVEL} ]] ; then 366 if [[ ${SOFTLEVEL} != "${BOOTLEVEL}" ]]; then
381 mark_service_stopped "${myservice}" 367 mark_service_stopped "${myservice}"
382 elif [[ ${retval} -eq 0 ]] ; then 368 fi
369
370 service_message "eerror" "FAILED to start service ${myservice}!"
371 else
383 mark_service_started "${myservice}" 372 mark_service_started "${myservice}"
384 fi
385 373
386 if [[ ${retval} == 0 ]]; then
387 service_message "Service ${myservice} started OK" 374 service_message "Service ${myservice} started OK"
388 else
389 service_message "eerror" "FAILED to start service ${myservice}!"
390 fi 375 fi
391 376
392 return "${retval}" 377 return "${retval}"
393} 378}
394 379

Legend:
Removed from v.1379  
changed lines
  Added in v.1380

  ViewVC Help
Powered by ViewVC 1.1.20