Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 118418 | Differences between
and this patch

Collapse All | Expand All

(-)runscript.sh (-28 / +33 lines)
Lines 91-114 Link Here
91
	local ordservice=
91
	local ordservice=
92
	local was_inactive=false
92
	local was_inactive=false
93
93
94
	if service_stopping "${myservice}" ; then
95
		eerror "ERROR:  \"${myservice}\" is already stopping."
96
		return 0
97
	elif service_stopped "${myservice}" ; then
98
		eerror "ERROR:  \"${myservice}\" has not yet been started."
99
		return 0
100
	fi
101
102
	# Do not try to stop if it had already failed to do so on runlevel change
94
	# Do not try to stop if it had already failed to do so on runlevel change
103
	if is_runlevel_stop && service_failed "${myservice}" ; then
95
	if is_runlevel_stop && service_failed "${myservice}" ; then
104
		return 1
96
		return 1
105
	fi
97
	fi
98
	
99
	if service_stopped "${myservice}" ; then
100
		ewarn "WARNING:  \"${myservice}\" has not yet been started."
101
		return 0
102
	fi
106
103
107
	service_inactive "${myservice}" && was_inactive=true
104
	service_inactive "${myservice}" && was_inactive=true
108
105
	if ! mark_service_stopping "${myservice}" ; then
109
	# Remove symlink to prevent recursion
106
		ewarn "WARNING:  \"${myservice}\" is already stopping."
110
	mark_service_stopping "${myservice}"
107
		return 0
111
108
	fi
109
	# Lock service starting too ...
110
	mark_service_starting "${myservice}"
111
	
112
	service_message "Stopping service ${myservice}"
112
	service_message "Stopping service ${myservice}"
113
113
114
	if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
114
	if in_runlevel "${myservice}" "${BOOTLEVEL}" && \
Lines 212-217 Link Here
212
	else
212
	else
213
		# Stop einfo/ebegin/eend from working as parallel messes us up
213
		# Stop einfo/ebegin/eend from working as parallel messes us up
214
		[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes"
214
		[[ ${RC_PARALLEL_STARTUP} == "yes" ]] && RC_QUIET_STDOUT="yes"
215
215
		# Now that deps are stopped, stop our service
216
		# Now that deps are stopped, stop our service
216
		( stop )
217
		( stop )
217
		retval=$?
218
		retval=$?
Lines 224-232 Link Here
224
	if [[ ${retval} -ne 0 ]] ; then
225
	if [[ ${retval} -ne 0 ]] ; then
225
		# Did we fail to stop? create symlink to stop multible attempts at
226
		# Did we fail to stop? create symlink to stop multible attempts at
226
		# runlevel change.  Note this is only used at runlevel change ...
227
		# runlevel change.  Note this is only used at runlevel change ...
227
		if is_runlevel_stop ; then
228
		is_runlevel_stop && mark_service_failed "${myservice}"
228
			mark_service_failed "${myservice}"
229
		fi
230
		
229
		
231
		# If we are halting the system, do it as cleanly as possible
230
		# If we are halting the system, do it as cleanly as possible
232
		if [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
231
		if [[ ${SOFTLEVEL} != "reboot" && ${SOFTLEVEL} != "shutdown" ]] ; then
Lines 259-287 Link Here
259
	local y=
258
	local y=
260
	local myserv=
259
	local myserv=
261
	local ordservice=
260
	local ordservice=
261
	local was_inactive=false
262
262
263
	if service_starting "${myservice}" ; then
263
	# Do not try to start if i have done so already on runlevel change
264
		ewarn "WARNING: \"${myservice}\" is already starting."
264
	if is_runlevel_start && service_failed "${myservice}" ; then
265
		return 1
266
	fi
267
268
	if service_started "${myservice}" ; then
269
		ewarn "WARNING: \"${myservice}\" has already been started."
265
		return 0
270
		return 0
266
	elif service_stopping "${myservice}" ; then
271
	elif service_stopping "${myservice}" ; then
267
		ewarn "WARNING: please wait for \"${myservice}\" to stop first."
272
		eerror "ERROR: please wait for \"${myservice}\" to stop first."
268
		return 0
273
		return 1
269
	elif service_inactive "${myservice}" ; then
274
	elif service_inactive "${myservice}" ; then
270
		if [[ ${IN_BACKGROUND} != "true" ]] ; then
275
		if [[ ${IN_BACKGROUND} != "true" ]] ; then
271
			ewarn "WARNING: \"${myservice}\" has already been started."
276
			ewarn "WARNING: \"${myservice}\" has already been started."
272
			return 0
277
			return 0
273
		fi
278
		fi
274
	elif service_started "${myservice}" ; then
275
		ewarn "WARNING: \"${myservice}\" has already been started."
276
		return 0
277
	fi
279
	fi
278
280
279
	# Do not try to start if i have done so already on runlevel change
281
	service_inactive "${myservice}" && was_inactive=true
280
	if is_runlevel_start && service_failed "${myservice}" ; then
282
	if ! mark_service_starting "${myservice}" ; then
281
		return 1
283
		ewarn "WARNING: \"${myservice}\" is already starting."
284
		return 0
282
	fi
285
	fi
283
284
	mark_service_starting "${myservice}"
285
	service_message "Starting service ${myservice}"
286
	service_message "Starting service ${myservice}"
286
287
287
	# On rc change, start all services "before $myservice" first
288
	# On rc change, start all services "before $myservice" first
Lines 383-389 Link Here
383
		# If we're booting, we need to continue and do our best to get the
384
		# If we're booting, we need to continue and do our best to get the
384
		# system up.
385
		# system up.
385
		if [[ ${SOFTLEVEL} != "${BOOTLEVEL}" ]]; then
386
		if [[ ${SOFTLEVEL} != "${BOOTLEVEL}" ]]; then
386
			mark_service_stopped "${myservice}"
387
			if ${was_inactive} ; then
388
				mark_service_inactive "${myservice}"
389
			else
390
				mark_service_stopped "${myservice}"
391
			fi
387
		fi
392
		fi
388
393
389
		service_message "eerror" "FAILED to start service ${myservice}!"
394
		service_message "eerror" "FAILED to start service ${myservice}!"
(-)rc-services.sh (-19 / +12 lines)
Lines 449-462 Link Here
449
mark_service_starting() {
449
mark_service_starting() {
450
	[[ -z $1 ]] && return 1
450
	[[ -z $1 ]] && return 1
451
451
452
	ln -snf "/etc/init.d/$1" "${svcdir}/starting/$1"
452
	ln -sn "/etc/init.d/$1" "${svcdir}/starting/$1" 2>/dev/null || return 1
453
	local retval=$?
453
454
	
454
	# We need to clear the inactive flag
455
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
456
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
455
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
457
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
456
	return 0
458
	
459
	return "${retval}"
460
}
457
}
461
458
462
# bool mark_service_started(service)
459
# bool mark_service_started(service)
Lines 467-479 Link Here
467
	[[ -z $1 ]] && return 1
464
	[[ -z $1 ]] && return 1
468
465
469
	ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
466
	ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
470
	local retval=$?
471
	
467
	
472
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
468
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
473
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
469
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
474
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
470
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
475
471
476
	return "${retval}"
472
	return 0 
477
}
473
}
478
474
479
# bool mark_service_inactive(service)
475
# bool mark_service_inactive(service)
Lines 484-495 Link Here
484
	[[ -z $1 ]] && return 1
480
	[[ -z $1 ]] && return 1
485
481
486
	ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
482
	ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
487
	local retval=$?
483
	
488
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
484
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
489
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
485
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
490
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
486
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
491
487
492
	return "${retval}"
488
	return 0
493
}
489
}
494
490
495
# bool mark_service_stopping(service)
491
# bool mark_service_stopping(service)
Lines 499-512 Link Here
499
mark_service_stopping() {
495
mark_service_stopping() {
500
	[[ -z $1 ]] && return 1
496
	[[ -z $1 ]] && return 1
501
497
502
	ln -snf "/etc/init.d/$1" "${svcdir}/stopping/$1"
498
	ln -sn "/etc/init.d/$1" "${svcdir}/stopping/$1" 2>/dev/null || return 1
503
	local retval=$?
504
	
505
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
506
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
507
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
508
499
509
	return "${retval}"
500
	# We need to clear the inactive flag
501
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
502
	return 0
510
}
503
}
511
504
512
# bool mark_service_stopped(service)
505
# bool mark_service_stopped(service)
Lines 522-528 Link Here
522
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
515
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
523
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
516
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
524
517
525
	return $?
518
	return 0
526
}
519
}
527
520
528
# bool test_service_state(char *service, char *state)
521
# bool test_service_state(char *service, char *state)

Return to bug 118418