dhcpcd: Remove chroot setup and restore things as they were before
[dragonfly.git] / etc / rc.d / dhcpcd
1 #!/bin/sh
2
3 # PROVIDE: dhcpcd
4 # REQUIRE: mountcritlocal cleanvar
5 # BEFORE: mountcritremote
6 # KEYWORD: nojail
7
8 . /etc/rc.subr
9 . /etc/network.subr
10
11 name="dhcpcd"
12 rcvar=
13 command="/sbin/$name"
14 extra_commands="reload"
15
16 load_rc_config $name
17 load_rc_config network
18
19 ifn="$2"
20 if [ -z "$ifn" ]; then
21         rcvar=`set_rcvar`  # running in master mode
22 else
23         _if_args="$(get_if_var $ifn dhcpcd_flags_IF)"
24         if dhcpif $ifn ipv4 && dhcpif $ifn ipv6; then
25                 command_args="$ifn"
26         elif dhcpif $ifn ipv4; then
27                 command_args="-4 $ifn"
28         elif dhcpif $ifn ipv6; then
29                 command_args="-6 $ifn"
30         else
31                 err 1 "$ifn is not enabled for DHCP (IPv4/IPv6)"
32         fi
33 fi
34
35 # Work out what pidfile dhcpcd will use based on flags
36 if [ -n "$flags" ]; then
37         _flags=$flags
38 elif [ -n "$_if_args" ]; then
39         _flags=$_if_args
40 else
41         eval _flags=\$${name}_flags
42 fi
43 pidfile=$($command -P $_flags $command_args 2>/dev/null)
44 : ${pidfile:=/var/run/$name.pid}
45 unset _flags _if_args
46
47 run_rc_command "$@"