rc.d.vkernel.patch

nant, 06/13/2007 05:23 PM

Download (5.64 KB)

View differences:

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

  
430 430
##############################################################
431
###  VKernel options #########################################
432
##############################################################
433

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

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

  
454
##############################################################
431 455
### Define source_rc_confs, the mechanism used by /etc/rc.* ##
432 456
### scripts to source rc_conf_files overrides safely.	    ##
433 457
##############################################################
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
		# Configure vkernel binary
22
		eval _bin=\"\${vkernel_${_vkernel}_bin}\"
23
		if [ -z "${_bin}" ]; then
24
			echo
25
			warn "No binary has been defined for vkernel '${_vkernel}'. Skipping."
26
			continue
27
		else
28
			bin=${_bin}
29
		fi
30

  
31
		# Configure vkernel memory
32
		eval _memsize=\"\$vkernel_${_vkernel}_memsize\"
33
		if [ -z "${_memsize}" ]; then
34
			echo
35
			warn "No memsize has been defined for vkernel '${_vkernel}'. Skipping."
36
			continue
37
		else
38
			memsize="-m ${_memsize}"
39
		fi
40

  
41
		# Configure vkernel root image(s)
42
		eval _rootimgs=\"\${vkernel_${_vkernel}_rootimg_list}\"
43
		if [ -z "${_rootimgs}" ]; then
44
			echo
45
			warn "No root image has been defined for vkernel '${_vkernel}'. Skipping."
46
			continue
47
		else
48
			for _rootimg in ${_rootimgs}
49
			do
50
				eval rootimgs=\"${rootimgs} -r ${_rootimg}\"
51
			done
52
		fi
53

  
54
		# Configure optional vkernel network interface(s)
55
		eval _ifaces=\"\${vkernel_${_vkernel}_iface_list}\"
56
		if [ -n "${_ifaces}" ]; then
57
			for _iface in ${_ifaces}
58
			do
59
				eval ifaces=\"${ifaces} -I ${_iface}\"
60
			done
61
		fi
62

  
63
		# Configure optional console logfile
64
		eval logfile=\"\${vkernel_${_vkernel}_logfile}\"
65
		[ -z "${logfile}" ] && logfile="/dev/null"
66

  
67
		# Configure optional flags
68
		eval flags=\"\${vkernel_${_vkernel}_flags}\"
69

  
70
		eval "daemon ${bin} ${memsize} ${rootimgs} ${ifaces} ${flags} >>${logfile} 2>&1"
71
		echo -n " ${_vkernel}"
72
	done
73
	echo '.'
74
}
75

  
76
vkernel_stop()
77
{
78
	for _vkernel in ${vkernel_list} 
79
	do
80
		eval _bin=\"\${vkernel_${_vkernel}_bin}\"
81
		if [ -n "$_bin" ]; then
82
			eval pid=`ps auxwww | grep ${_bin} | grep -v grep | awk '{print $2}'`
83
			if [ -z "${pid}" ]; then
84
				warn "vkernel '${_vkernel}' not running?"
85
			else
86
				eval kill -TERM ${pid}
87
			fi
88
		fi
89
	done
90
}
91

  
92

  
93
load_rc_config $name
94
run_rc_command "$1"
share/man/man5/rc.conf.5
2668 2668
if
2669 2669
.Xr shutdown 8
2670 2670
has not completed within the specified time (in seconds).
2671
.It Va vkernel_enable
2672
.Pq Vt bool
2673
If set to
2674
.Dq Li NO ,
2675
any configured vkernels will not be started.
2676
.It Va vkernel_list
2677
.Pq Vt str
2678
A space separated list of names for vkernels.
2679
This is purely a configuration aid to help identify and
2680
configure multiple vkernels.
2681
The names specified in this list will be used to
2682
identify settings common to a vkernel instance.
2683
Assuming that the vkernel in question was named
2684
.Li example ,
2685
you would have the following dependent variables
2686
(filled with reference values in this text):
2687
.Bd -literal
2688
vkernel_example_bin="/usr/obj/usr/src/sys/VKERNEL/kernel.debug"
2689
vkernel_example_memsize="64m"
2690
vkernel_example_rootimg_list="/var/vkernel/rootimg.01"
2691
vkernel_example_iface_list="auto:bridge0"
2692
vkernel_example_logfile="/dev/null"
2693
vkernel_example_flags="-U"
2694
.Ed
2695
.Pp
2696
The last three are optional.
2697
They default to an empty string if not set, except for logfile which defaults to
2698
.Pa /dev/null
2699
if it is not set.
2671 2700
.El
2672 2701
.Sh FILES
2673 2702
.Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact