Followup to last commit, cleanup some SMP/UP conditionals.
[dragonfly.git] / etc / rc.d / dhclient
blobfce260bcc8eec3fa553d581188aa729e5eccc2fc
1 #!/bin/sh
3 # $NetBSD: dhclient,v 1.8 2002/03/22 04:33:58 thorpej Exp $
4 # $FreeBSD: src/etc/rc.d/dhclient,v 1.6 2003/06/29 05:34:41 mtm Exp $
5 # $DragonFly: src/etc/rc.d/dhclient,v 1.7 2005/11/19 21:47:32 swildner Exp $
8 # PROVIDE: dhclient
9 # REQUIRE: netif mountcritlocal
10 # BEFORE: NETWORKING
12 # Note that there no syslog logging of dhclient messages at boot because
13 # dhclient needs to start before services that syslog depends upon do.
16 . /etc/rc.subr
17 . /etc/network.subr
19 name="dhclient"
20 pidfile="/var/run/${name}.pid"
21 rcvar=
22 start_precmd="dhclient_prestart"
23 start_postcmd="dhclient_poststart"
24 stop_cmd="dhclient_stop"
25 stop_precmd="dhclient_prestop"
26 stop_postcmd="dhclient_poststop"
29 dhclient_common()
31 dhcp_list="`list_net_interfaces dhcp`"
32 if [ -z "$dhcp_list" ]; then
33 return $RC_IRRELEVANT
36 # Determine the scope of the command
38 _cooked_list="$dhcp_list"
39 if [ -n "$_cmdifn" ]; then
40 eval _cooked_list=\"`expr "$dhcp_list" : ".*\($_cmdifn\).*"`\"
41 if [ -z "$_cooked_list" ]; then
42 err "No such network interface: $_cmdifn"
43 return 1
48 dhclient_prestart()
50 dhclient_common || return $?
52 for ifn in ${_cooked_list}; do
53 ifscript_up ${ifn}
54 done
56 rc_flags="${rc_flags} ${_cooked_list}"
57 return 0
60 dhclient_poststart()
62 for ifn in ${_cooked_list}; do
63 ifalias_up ${ifn}
64 ipx_up ${ifn}
65 ifconfig ${ifn}
66 done
69 dhclient_stop()
71 echo -n "Releasing DHCP leases:"
72 for ifn in $_cooked_list ; do
73 ${command} -r $ifn
74 if [ $? -eq 0 ]; then
75 echo -n " $ifn"
76 else
77 _fail="$_fail $ifn"
79 done
80 echo '.'
81 debug "The following leases failed to release: $_fail"
84 dhclient_prestop()
86 dhclient_common || return $?
88 for ifn in ${_cooked_list}; do
89 ipx_down ${ifn}
90 ifalias_down ${ifn}
91 done
94 dhclient_poststop()
96 for ifn in ${_cooked_list}; do
97 ifscript_down ${ifn}
98 done
101 if [ -n "$2" ]; then
102 _cmdifn="$2"
105 load_rc_config $name
107 run_rc_command "$1"