2009-01-04 15:10:30 +03:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
2009-04-21 20:08:57 +04:00
|
|
|
# $NetBSD: rndctl,v 1.3 2009/04/21 16:08:57 joerg Exp $
|
2009-01-04 15:10:30 +03:00
|
|
|
#
|
|
|
|
|
|
|
|
# PROVIDE: rndctl
|
2009-04-21 20:08:57 +04:00
|
|
|
# BEFORE: DISKS ike ipsec sshd
|
|
|
|
# REQUIRE: wdogctl
|
2009-01-04 15:10:30 +03:00
|
|
|
|
|
|
|
$_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.
|
|
|
|
#
|
2009-02-02 12:24:47 +03:00
|
|
|
# Note that -d/-t flag must be last.
|
|
|
|
#
|
2009-01-04 15:10:30 +03:00
|
|
|
case "${flags}" in
|
|
|
|
*[cCeE]*) ;;
|
2009-02-02 12:24:47 +03:00
|
|
|
*) flags="-c -e ${flags}" ;;
|
2009-01-04 15:10:30 +03:00
|
|
|
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"
|