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

(-)orig/etc/conf.d/rc (+9 lines)
Lines 179-184 Link Here
179
svcdir="/var/lib/init.d"
179
svcdir="/var/lib/init.d"
180
180
181
181
182
# rc-scripts locking directory
183
#
184
# NOTE:  Do not remove the next line, as its needed by the baselayout ebuild!
185
#
186
#  svclock="/var/lib/init.d/locks"
187
188
svclock="/var/lib/init.d/locks"
189
190
182
# Should we mount $svcdir in a ram disk for some speed increase 
191
# Should we mount $svcdir in a ram disk for some speed increase 
183
# for slower machines, or for the more extreme setups ?
192
# for slower machines, or for the more extreme setups ?
184
193
(-)orig/lib/rcscripts/sh/rc-services.sh (-11 / +67 lines)
Lines 6-11 Link Here
6
RC_GOT_SERVICES="yes"
6
RC_GOT_SERVICES="yes"
7
7
8
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
8
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && source /sbin/functions.sh
9
[[ ${RC_GOT_LOCKING} != "yes" ]] && source "${svclib}/sh/rc-locking.sh"
9
10
10
if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
11
if [[ ${RC_GOT_DEPTREE_INFO} != "yes" ]] ; then
11
	# Only try and update if we are root
12
	# Only try and update if we are root
Lines 357-375 Link Here
357
		mark_service_stopped "${service}"
358
		mark_service_stopped "${service}"
358
		return 1
359
		return 1
359
	fi
360
	fi
361
362
	lock "status"
363
	
364
	if service_starting "${service}"  ||
365
	   service_started  "${service}"
366
	then
367
		unlock "status"
368
		return 0
369
	fi
360
	
370
	
361
	service_starting "${service}" && return 0
371
	if service_inactive "${service}" ; then
362
	service_started "${service}" && return 0
372
		unlock "status"
363
	service_inactive "${service}" && return 1
373
		return 1
374
	fi
364
375
365
	if is_fake_service "${service}" "${SOFTLEVEL}" ; then
376
	if is_fake_service "${service}" "${SOFTLEVEL}" ; then
366
		mark_service_started "${service}"
377
		mark_service_started "${service}"
378
		unlock "status"
367
		splash "svc_start" "${service}"
379
		splash "svc_start" "${service}"
368
		splash "svc_started" "${service}" "0"
380
		splash "svc_started" "${service}" "0"
369
		return 0
381
		return 0
370
	fi
382
	fi
371
383
372
	begin_service "${service}" || return 0
384
	if ! begin_service "${service}" ; then
385
		unlock "status"
386
		return 0
387
	fi
388
389
	unlock "status"
390
373
	splash "svc_start" "${service}"
391
	splash "svc_start" "${service}"
374
	if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
392
	if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
375
		  ${START_CRITICAL} == "yes" ]] ; then
393
		  ${START_CRITICAL} == "yes" ]] ; then
Lines 405-412 Link Here
405
		return 0
423
		return 0
406
	fi
424
	fi
407
425
408
	service_stopping "${service}" && return 0
426
	lock "status"
409
	service_stopped "${service}" && return 0
427
428
	if service_stopping "${service}" ||
429
	   service_stopped  "${service}"
430
	then
431
		unlock "status"
432
		return 0
433
	fi
410
	
434
	
411
	local level="${SOFTLEVEL}"
435
	local level="${SOFTLEVEL}"
412
	is_runlevel_stop && level="${OLDSOFTLEVEL}"
436
	is_runlevel_stop && level="${OLDSOFTLEVEL}"
Lines 414-424 Link Here
414
	if is_fake_service "${service}" "${level}" ; then
438
	if is_fake_service "${service}" "${level}" ; then
415
		splash "svc_stop" "${service}"
439
		splash "svc_stop" "${service}"
416
		mark_service_stopped "${service}"
440
		mark_service_stopped "${service}"
441
		unlock "status"
417
		splash "svc_stopped" "${service}" "0"
442
		splash "svc_stopped" "${service}" "0"
418
		return 0
443
		return 0
419
	fi
444
	fi
420
445
421
	begin_service "${service}" || return 0
446
	if ! begin_service "${service}" ; then
447
		unlock "status"
448
		return 0
449
	fi
450
	unlock "status"
422
451
423
	splash "svc_stop" "${service}"
452
	splash "svc_stop" "${service}"
424
	if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
453
	if [[ ${RC_PARALLEL_STARTUP} != "yes" || \
Lines 449-454 Link Here
449
mark_service_starting() {
478
mark_service_starting() {
450
	[[ -z $1 ]] && return 1
479
	[[ -z $1 ]] && return 1
451
480
481
	lock "status"
482
452
	ln -snf "/etc/init.d/$1" "${svcdir}/starting/$1"
483
	ln -snf "/etc/init.d/$1" "${svcdir}/starting/$1"
453
	local retval=$?
484
	local retval=$?
454
	
485
	
Lines 456-461 Link Here
456
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
487
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
457
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
488
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
458
	
489
	
490
	unlock "status"
491
	
459
	return "${retval}"
492
	return "${retval}"
460
}
493
}
461
494
Lines 466-471 Link Here
466
mark_service_started() {
499
mark_service_started() {
467
	[[ -z $1 ]] && return 1
500
	[[ -z $1 ]] && return 1
468
501
502
	lock "status"
503
469
	ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
504
	ln -snf "/etc/init.d/$1" "${svcdir}/started/$1"
470
	local retval=$?
505
	local retval=$?
471
	
506
	
Lines 473-478 Link Here
473
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
508
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
474
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
509
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
475
510
511
	unlock "status"
512
476
	return "${retval}"
513
	return "${retval}"
477
}
514
}
478
515
Lines 483-494 Link Here
483
mark_service_inactive() {
520
mark_service_inactive() {
484
	[[ -z $1 ]] && return 1
521
	[[ -z $1 ]] && return 1
485
522
523
	lock "status"
524
486
	ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
525
	ln -snf "/etc/init.d/$1" "${svcdir}/inactive/$1"
487
	local retval=$?
526
	local retval=$?
488
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
527
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
489
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
528
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
490
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
529
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
491
530
531
	unlock "status"
532
492
	return "${retval}"
533
	return "${retval}"
493
}
534
}
494
535
Lines 499-504 Link Here
499
mark_service_stopping() {
540
mark_service_stopping() {
500
	[[ -z $1 ]] && return 1
541
	[[ -z $1 ]] && return 1
501
542
543
	lock "status"
544
502
	ln -snf "/etc/init.d/$1" "${svcdir}/stopping/$1"
545
	ln -snf "/etc/init.d/$1" "${svcdir}/stopping/$1"
503
	local retval=$?
546
	local retval=$?
504
	
547
	
Lines 506-511 Link Here
506
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
549
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
507
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
550
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
508
551
552
	unlock "status"
553
509
	return "${retval}"
554
	return "${retval}"
510
}
555
}
511
556
Lines 516-527 Link Here
516
mark_service_stopped() {
561
mark_service_stopped() {
517
	[[ -z $1 ]] && return 1
562
	[[ -z $1 ]] && return 1
518
563
564
	lock "status"
565
519
	[[ -f "${svcdir}/daemons/$1" ]] && rm -f "${svcdir}/daemons/$1"
566
	[[ -f "${svcdir}/daemons/$1" ]] && rm -f "${svcdir}/daemons/$1"
520
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
567
	[[ -f "${svcdir}/starting/$1" ]] && rm -f "${svcdir}/starting/$1"
521
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
568
	[[ -f "${svcdir}/started/$1" ]] && rm -f "${svcdir}/started/$1"
522
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
569
	[[ -f "${svcdir}/inactive/$1" ]] && rm -f "${svcdir}/inactive/$1"
523
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
570
	[[ -f "${svcdir}/stopping/$1" ]] && rm -f "${svcdir}/stopping/$1"
524
571
572
	unlock "status"
573
525
	return $?
574
	return $?
526
}
575
}
527
576
Lines 580-590 Link Here
580
service_stopped() {
629
service_stopped() {
581
	[[ -z $1 ]] && return 1
630
	[[ -z $1 ]] && return 1
582
631
583
	service_starting "$1" && return 1
632
	lock "status"
584
	service_started "$1" && return 1
633
585
	service_stopping "$1" && return 1
634
	if service_starting "$1" ||
586
	service_inactive "$1" && return 1
635
	   service_started  "$1" ||
636
	   service_stopping "$1" ||
637
	   service_inactive "$1"
638
	then
639
		unlock "status"
640
		return 1
641
	fi
587
642
643
	unlock "status"
588
	return 0
644
	return 0
589
}
645
}
590
646
(-)orig/sbin/functions.sh (+1 lines)
Lines 12-17 Link Here
12
# Check /etc/conf.d/rc for a description of these ...
12
# Check /etc/conf.d/rc for a description of these ...
13
svclib="/lib/rcscripts"
13
svclib="/lib/rcscripts"
14
svcdir=${svcdir:-/var/lib/init.d}
14
svcdir=${svcdir:-/var/lib/init.d}
15
svclock=${svclock:-/var/lib/init.d/locks}
15
svcmount=${svcmount:-no}
16
svcmount=${svcmount:-no}
16
svcfstype=${svcfstype:-tmpfs}
17
svcfstype=${svcfstype:-tmpfs}
17
svcsize=${svcsize:-1024}
18
svcsize=${svcsize:-1024}
(-)orig/sbin/rc (-1 / +9 lines)
Lines 489-495 Link Here
489
489
490
	# Update the dependency cache
490
	# Update the dependency cache
491
	/sbin/depscan.sh -u
491
	/sbin/depscan.sh -u
492
492
	
493
	# Create locking directory
494
	if [[ ! -d "${svclock}" ]] ; then
495
		if ! mkdir -p -m 0755 "${svclock}" 2>/dev/null ; then
496
			eerror "Could not create needed directory '${svclock}'!"
497
		fi
498
	fi
499
	
500
	
493
	# Now that the dependency cache are up to date, make sure these
501
	# Now that the dependency cache are up to date, make sure these
494
	# are marked as started ...
502
	# are marked as started ...
495
	(
503
	(
(-)orig/sbin/runscript.sh (-2 / +24 lines)
Lines 88-103 Link Here
88
	local ordservice=
88
	local ordservice=
89
	local was_inactive=false
89
	local was_inactive=false
90
90
91
	lock "status"
92
91
	if service_stopping "${myservice}" ; then
93
	if service_stopping "${myservice}" ; then
94
		unlock "status"
92
		eerror "ERROR:  \"${myservice}\" is already stopping."
95
		eerror "ERROR:  \"${myservice}\" is already stopping."
93
		return 0
96
		return 0
94
	elif service_stopped "${myservice}" ; then
97
	elif service_stopped "${myservice}" ; then
98
		unlock "status"
95
		eerror "ERROR:  \"${myservice}\" has not yet been started."
99
		eerror "ERROR:  \"${myservice}\" has not yet been started."
96
		return 0
100
		return 0
97
	fi
101
	fi
98
102
99
	# Do not try to stop if it had already failed to do so on runlevel change
103
	# Do not try to stop if it had already failed to do so on runlevel change
100
	if is_runlevel_stop && service_failed "${myservice}" ; then
104
	if is_runlevel_stop && service_failed "${myservice}" ; then
105
		unlock "status"
101
		return 1
106
		return 1
102
	fi
107
	fi
103
108
Lines 105-110 Link Here
105
110
106
	# Remove symlink to prevent recursion
111
	# Remove symlink to prevent recursion
107
	mark_service_stopping "${myservice}"
112
	mark_service_stopping "${myservice}"
113
	
114
	unlock "status"
108
115
109
	service_message "Stopping service ${myservice}"
116
	service_message "Stopping service ${myservice}"
110
117
Lines 257-284 Link Here
257
	local myserv=
265
	local myserv=
258
	local ordservice=
266
	local ordservice=
259
267
268
	lock "status"
269
260
	if service_starting "${myservice}" ; then
270
	if service_starting "${myservice}" ; then
271
		unlock "status"
261
		ewarn "WARNING: \"${myservice}\" is already starting."
272
		ewarn "WARNING: \"${myservice}\" is already starting."
262
		return 0
273
		return 0
263
	elif service_stopping "${myservice}" ; then
274
	elif service_stopping "${myservice}" ; then
275
		unlock "status"
264
		ewarn "WARNING: please wait for \"${myservice}\" to stop first."
276
		ewarn "WARNING: please wait for \"${myservice}\" to stop first."
265
		return 0
277
		return 0
266
	elif service_inactive "${myservice}" ; then
278
	elif service_inactive "${myservice}" ; then
279
		unlock "status"
267
		if [[ ${IN_BACKGROUND} != "true" ]] ; then
280
		if [[ ${IN_BACKGROUND} != "true" ]] ; then
268
			ewarn "WARNING: \"${myservice}\" has already been started."
281
			ewarn "WARNING: \"${myservice}\" has already been started."
269
			return 0
282
			return 0
270
		fi
283
		fi
271
	elif service_started "${myservice}" ; then
284
	elif service_started "${myservice}" ; then
285
		unlock "status"
272
		ewarn "WARNING: \"${myservice}\" has already been started."
286
		ewarn "WARNING: \"${myservice}\" has already been started."
273
		return 0
287
		return 0
274
	fi
288
	fi
275
289
276
	# Do not try to start if i have done so already on runlevel change
290
	# Do not try to start if i have done so already on runlevel change
277
	if is_runlevel_start && service_failed "${myservice}" ; then
291
	if is_runlevel_start && service_failed "${myservice}" ; then
292
		unlock "status"
278
		return 1
293
		return 1
279
	fi
294
	fi
280
295
281
	mark_service_starting "${myservice}"
296
	mark_service_starting "${myservice}"
297
298
	unlock "status"
299
282
	service_message "Starting service ${myservice}"
300
	service_message "Starting service ${myservice}"
283
301
284
	# On rc change, start all services "before $myservice" first
302
	# On rc change, start all services "before $myservice" first
Lines 302-308 Link Here
302
				if service_stopped "${mynetservice}" ; then
320
				if service_stopped "${mynetservice}" ; then
303
					start_service "${mynetservice}"
321
					start_service "${mynetservice}"
304
				fi
322
				fi
305
			done	
323
			done
306
		elif [[ ${x} != "net" ]] ; then
324
		elif [[ ${x} != "net" ]] ; then
307
			if service_stopped "${x}" ; then
325
			if service_stopped "${x}" ; then
308
				start_service "${x}"
326
				start_service "${x}"
Lines 411-417 Link Here
411
	# If we are effectively root, check to see if required daemons are running
430
	# If we are effectively root, check to see if required daemons are running
412
	# and update our status accordingly
431
	# and update our status accordingly
413
	[[ ${EUID} == 0 ]] && update_service_status "${myservice}"
432
	[[ ${EUID} == 0 ]] && update_service_status "${myservice}"
414
433
	
434
	lock "status"
435
	
415
	if service_starting "${myservice}" ; then
436
	if service_starting "${myservice}" ; then
416
		efunc="einfo"
437
		efunc="einfo"
417
		state="starting"
438
		state="starting"
Lines 428-433 Link Here
428
		efunc="eerror"
449
		efunc="eerror"
429
		state="stopped"
450
		state="stopped"
430
	fi
451
	fi
452
		
453
	unlock "status"
454
	
431
	[[ ${RC_QUIET_STDOUT} != "yes" ]] \
455
	[[ ${RC_QUIET_STDOUT} != "yes" ]] \
432
		&& ${efunc} "status:  ${state}"
456
		&& ${efunc} "status:  ${state}"
433
457

Return to bug 118418