Expand PMF_FN_* macros.
[netbsd-mini2440.git] / etc / rc.d / rndctl
blobf69abd392a7e7df62e168337e885596f4a36d02e
1 #!/bin/sh
3 # $NetBSD: rndctl,v 1.2 2009/02/02 09:24:47 apb Exp $
6 # PROVIDE: rndctl
7 # BEFORE: DISKS ike ipsec sshd
8 # REQUIRE: wdogctl
10 $_rc_subr_loaded . /etc/rc.subr
12 name="rndctl"
13 rcvar=$name
14 command="/sbin/${name}"
16 start_cmd="rndctl_startcmd"
18 rndctl_startcmd()
20 # $rndctl_flags can contain multiple semicolon-separated
21 # segments in which each segment contains optional flags
22 # followed by one or more device or type names. If none of the
23 # -c/-C/-e/-E flags is specified, then "-c -e" is used. If
24 # neither of the -d/-t flags is specified, then "-d" is used.
26 # For example, given
27 # rndctl_flags="wd0 wd1; -t tty; -c -t net"
28 # we will perform the following commands:
29 # rndctl -c -e -d wd0
30 # rndctl -c -e -d wd1
31 # rndctl -c -e -t tty
32 # rndctl -c -t net
34 local args arg flags
36 # Split $rndctl_flags on semicolons
37 oIFS="$IFS"
38 IFS=';'
39 set -- $rndctl_flags
40 IFS="$oIFS"
41 # The outer "for args" loop cycles once per semicolon-separated
42 # segment; the inner "for arg" loop cycles once per word in a
43 # segment.
44 for args in "$@"; do
45 #echo >&2 "${name} DEBUG: Parsing segment: $args";
46 flags=''
47 for arg in ${args}; do
48 case "${arg}" in
49 -*)
50 flags="${flags} ${arg}"
53 # We have a device or type name.
54 # If none of -c/-C/-e/-E flags was
55 # specified, add "-c -e". If neither
56 # of -d/-t was specified, add "-d".
57 # Then perform the command with the
58 # specified device or type name.
60 # Note that -d/-t flag must be last.
62 case "${flags}" in
63 *[cCeE]*) ;;
64 *) flags="-c -e ${flags}" ;;
65 esac
66 case "${flags}" in
67 *[dt]*) ;;
68 *) flags="${flags} -d" ;;
69 esac
70 #echo >&2 "${name} DEBUG: running:" \
71 # "$command $flags $arg"
72 $command ${flags} ${arg}
74 esac
75 done
76 done
79 load_rc_config $name
80 run_rc_command "$1"