[BACK]Return to rndctl CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / etc / rc.d

File: [cvs.NetBSD.org] / src / etc / rc.d / rndctl (download)

Revision 1.2.2.3, Fri Feb 6 00:56:48 2009 UTC (15 years, 2 months ago) by snj
Branch: netbsd-5
CVS Tags: netbsd-5-2-RELEASE, netbsd-5-2-RC1, netbsd-5-2-3-RELEASE, netbsd-5-2-2-RELEASE, netbsd-5-2-1-RELEASE, netbsd-5-2, netbsd-5-1-RELEASE, netbsd-5-1-RC4, netbsd-5-1-RC3, netbsd-5-1-RC2, netbsd-5-1-RC1, netbsd-5-1-5-RELEASE, netbsd-5-1-4-RELEASE, netbsd-5-1-3-RELEASE, netbsd-5-1-2-RELEASE, netbsd-5-1-1-RELEASE, netbsd-5-1, netbsd-5-0-RELEASE, netbsd-5-0-RC4, netbsd-5-0-RC3, netbsd-5-0-RC2, netbsd-5-0-2-RELEASE, netbsd-5-0-1-RELEASE, netbsd-5-0, matt-nb5-pq3-base, matt-nb5-pq3, matt-nb5-mips64-u2-k2-k4-k7-k8-k9, matt-nb5-mips64-u1-k1-k5, matt-nb5-mips64-premerge-20101231, matt-nb5-mips64-premerge-20091211, matt-nb5-mips64-k15, matt-nb5-mips64, matt-nb4-mips64-k7-u2a-k9b
Changes since 1.2.2.2: +4 -2 lines

Pull up following revision(s) (requested by apb in ticket #406):
	etc/rc.d/rndctl: revision 1.2
The -d or -t flag must appear after -c/-C/-e/-E flags, because of the
way we add the device name. after the flags.
Addresses PR 40495 from Ryo HAYASAKA.

#!/bin/sh
#
# $NetBSD: rndctl,v 1.2.2.3 2009/02/06 00:56:48 snj Exp $
#

# PROVIDE: rndctl
# BEFORE: disks ike ipsec sshd

$_rc_subr_loaded . /etc/rc.subr

name="rndctl"
rcvar=$name
command="/sbin/${name}"

start_cmd="rndctl_startcmd"

rndctl_startcmd()
{
	# $rndctl_flags can contain multiple semicolon-separated
	# segments in which each segment contains optional flags
	# followed by one or more device or type names.  If none of the
	# -c/-C/-e/-E flags is specified, then "-c -e" is used.  If
	# neither of the -d/-t flags is specified, then "-d" is used.
	#
	# For example, given
	#	rndctl_flags="wd0 wd1; -t tty; -c -t net"
	# we will perform the following commands:
	#	rndctl -c -e -d wd0
	#	rndctl -c -e -d wd1
	#	rndctl -c -e -t tty
	#	rndctl -c -t net

	local args arg flags

	# Split $rndctl_flags on semicolons
	oIFS="$IFS"
	IFS=';'
	set -- $rndctl_flags
	IFS="$oIFS"
	# The outer "for args" loop cycles once per semicolon-separated
	# segment; the inner "for arg" loop cycles once per word in a
	# segment.
	for args in "$@"; do
		#echo >&2 "${name} DEBUG: Parsing segment: $args";
		flags=''
		for arg in ${args}; do
			case "${arg}" in
				-*)
					flags="${flags} ${arg}"
					;;
				*)
					# We have a device or type name.
					# If none of -c/-C/-e/-E flags was
					# specified, add "-c -e".  If neither
					# of -d/-t was specified, add "-d".
					# Then perform the command with the
					# specified device or type name.
					#
					# Note that -d/-t flag must be last.
					#
					case "${flags}" in
					*[cCeE]*) ;;
					*)	flags="-c -e ${flags}" ;;
					esac
					case "${flags}" in
					*[dt]*) ;;
					*)	flags="${flags} -d" ;;
					esac
					#echo >&2 "${name} DEBUG: running:" \
					#    "$command $flags $arg"
					$command ${flags} ${arg}
					;;
			esac
		done
	done
}

load_rc_config $name
run_rc_command "$1"