rc.d: Introduce 'dhcp_client' to wrap over dhclient and dhcpcd
[dragonfly.git] / etc / rc.d / dhcp_client
1 #!/bin/sh
2
3 # PROVIDE: dhcp_client
4 # REQUIRE: mountcritlocal
5 # KEYWORD: nojail nostart
6
7 . /etc/rc.subr
8
9 name="dhcp_client"
10
11 load_rc_config ${name}
12 dummy_rc_command "$1"
13
14 find_client()
15 {
16         [ -x "${dhcp_client}" ] && {
17                 echo -n "${dhcp_client}"
18                 return
19         }
20
21         for dir in /etc/rc.d ${local_startup}; do
22                 [ -x "${dir}/${dhcp_client}" ] && {
23                         echo -n "${dir}/${dhcp_client}"
24                         return
25                 }
26         done
27 }
28
29 command=$(find_client)
30 debug "found client program: ${command}"
31 if [ -n "${command}" ]; then
32         ${command} "$@"
33 else
34         echo "ERROR: cannot find the command to start DHCP client."
35         exit 1
36 fi