rc.d.vkernel2.patch

nant, 06/20/2007 10:49 PM

Download (6 KB)

View differences:

etc/defaults/rc.conf
426 426
watchdogd_enable="NO"	# Start the software watchdog daemon
427 427

  
428 428
##############################################################
429
###  VKernel options #########################################
430
##############################################################
431

  
432
vkernel_enable="NO"	# Set to YES to enable starting of vkernels
433
vkernel_list=""		# Space separated list of names of vkernels
434

  
435
#
436
# Create an entry for each vkernel specified in vkernel_list
437
# replacing 'example' by the name of the vkernel.
438
#
439
#vkernel_example_bin="/usr/obj/usr/src/sys/VKERNEL/kernel.debug"
440
	# Path to the vkernel binary
441
#vkernel_example_memsize="64m"
442
	# Amount of memory for the vkernel
443
#vkernel_example_rootimg_list="/var/vkernel/rootimg.01"
444
	# Space separated list of disk images
445
#vkernel_example_iface_list="auto:bridge0"
446
	# Optional: space separated list network interfaces for the vkernel
447
#vkernel_example_logfile="/dev/null"
448
	# Optional: path to the console log file
449
#vkernel_example_flags="-U"
450
	# Optional: aditional flags to start the vkernel with
451

  
452
##############################################################
429 453
### Define source_rc_confs, the mechanism used by /etc/rc.* ##
430 454
### scripts to source rc_conf_files overrides safely.	    ##
431 455
##############################################################
etc/rc.d/Makefile
22 22
	quota random rarpd rcconf.sh resident rndcontrol root route6d routed \
23 23
	routing rpcbind rtadvd rtsold rwho sysdb savecore securelevel sendmail \
24 24
	serial sppp sshd swap1 syscons sysctl syslogd timed ttys usbd \
25
	vinum virecover watchdogd ypbind yppasswdd ypserv ypset ypupdated \
25
	vinum virecover vkernel watchdogd \
26
	ypbind yppasswdd ypserv ypset ypupdated \
26 27
	ypxfrd varsym
27 28
FILESDIR=	/etc/rc.d
28 29
FILESMODE=	${BINMODE}
etc/rc.d/vkernel
1
#!/bin/sh
2
#
3
# $DragonFly$
4
#
5

  
6
# PROVIDE: vkernel
7
# REQUIRE: LOGIN NETWORKING
8

  
9
. /etc/rc.subr
10

  
11
name="vkernel"
12
rcvar=`set_rcvar`
13
start_cmd="vkernel_start"
14
stop_cmd="vkernel_stop"
15

  
16
vkernel_start()
17
{
18
	echo -n 'Starting virtual kernels:'
19
	for _vkernel in ${vkernel_list} 
20
	do
21
		# Check if already running
22
		eval pidfile="/var/run/vkernel.${_vkernel}.pid"
23
		if [ -f "${_pidfile}" ]; then
24
			echo
25
			warn "Vkernel ${_vkernel} already running? (check ${pidfile})"
26
			continue
27
		fi
28

  
29
		# Configure vkernel binary
30
		eval _bin=\"\${vkernel_${_vkernel}_bin}\"
31
		if [ -z "${_bin}" -o ! -x "${_bin}" ]; then
32
			echo
33
			warn "Missing or undefined binary for vkernel '${_vkernel}'. Skipping."
34
			continue
35
		else
36
			bin=${_bin}
37
		fi
38

  
39
		# Configure vkernel memory
40
		eval _memsize=\"\$vkernel_${_vkernel}_memsize\"
41
		if [ -z "${_memsize}" ]; then
42
			echo
43
			warn "No memsize has been defined for vkernel '${_vkernel}'. Skipping."
44
			continue
45
		else
46
			memsize="-m ${_memsize}"
47
		fi
48

  
49
		# Configure vkernel root image(s)
50
		eval _rootimgs=\"\${vkernel_${_vkernel}_rootimg_list}\"
51
		if [ -z "${_rootimgs}" ]; then
52
			echo
53
			warn "No root image has been defined for vkernel '${_vkernel}'. Skipping."
54
			continue
55
		else
56
			for _rootimg in ${_rootimgs}
57
			do
58
				eval rootimgs=\"${rootimgs} -r ${_rootimg}\"
59
			done
60
		fi
61

  
62
		# Configure optional vkernel network interface(s)
63
		eval _ifaces=\"\${vkernel_${_vkernel}_iface_list}\"
64
		if [ -n "${_ifaces}" ]; then
65
			for _iface in ${_ifaces}
66
			do
67
				eval ifaces=\"${ifaces} -I ${_iface}\"
68
			done
69
		fi
70

  
71
		# Configure optional console logfile
72
		eval logfile=\"\${vkernel_${_vkernel}_logfile}\"
73
		[ -z "${logfile}" ] && logfile="/dev/null"
74

  
75
		# Configure optional flags
76
		eval flags=\"\${vkernel_${_vkernel}_flags}\"
77

  
78
		eval "daemon ${bin} ${memsize} ${rootimgs} ${ifaces} ${flags} -p ${pidfile} >>${logfile} 2>&1"
79
		echo -n " ${_vkernel}"
80
	done
81
	echo '.'
82
}
83

  
84
vkernel_stop()
85
{
86
	for _vkernel in ${vkernel_list} 
87
	do
88
		eval pidfile="/var/run/vkernel.${_vkernel}.pid"
89
		if [ -f "${pidfile}" ]; then
90
			eval pid=`cat ${pidfile}` 
91
		else
92
			eval _bin=\"\${vkernel_${_vkernel}_bin}\"
93
			if [ -n "$_bin" ]; then
94
				eval pid=`ps auxwww | grep ${_bin} | grep -v grep | awk '{print $2}'`
95
			fi
96
		fi
97
		if [ -z "${pid}" ]; then
98
			warn "vkernel '${_vkernel}' not running?"
99
		else
100
			eval kill -TERM ${pid}
101
		fi
102
	done
103
}
104

  
105

  
106
load_rc_config $name
107
run_rc_command "$1"
share/man/man5/rc.conf.5
2523 2523
if
2524 2524
.Xr shutdown 8
2525 2525
has not completed within the specified time (in seconds).
2526
.It Va vkernel_enable
2527
.Pq Vt bool
2528
If set to
2529
.Dq Li NO ,
2530
any configured vkernels will not be started.
2531
.It Va vkernel_list
2532
.Pq Vt str
2533
A space separated list of names for vkernels.
2534
This is purely a configuration aid to help identify and
2535
configure multiple vkernels.
2536
The names specified in this list will be used to
2537
identify settings common to a vkernel instance.
2538
Assuming that the vkernel in question was named
2539
.Li example ,
2540
you would have the following dependent variables
2541
(filled with reference values in this text):
2542
.Bd -literal
2543
vkernel_example_bin="/usr/obj/usr/src/sys/VKERNEL/kernel.debug"
2544
vkernel_example_memsize="64m"
2545
vkernel_example_rootimg_list="/var/vkernel/rootimg.01"
2546
vkernel_example_iface_list="auto:bridge0"
2547
vkernel_example_logfile="/dev/null"
2548
vkernel_example_flags="-U"
2549
.Ed
2550
.Pp
2551
The last three are optional.
2552
They default to an empty string if not set, except for logfile which defaults to
2553
.Pa /dev/null
2554
if it is not set.
2526 2555
.El
2527 2556
.Sh FILES
2528 2557
.Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact