1#!/bin/sh 2# 3# 4 5# PROVIDE: dhclient 6# KEYWORD: nojailvnet nostart 7 8. /etc/rc.subr 9. /etc/network.subr 10 11ifn="$2" 12 13name="dhclient" 14desc="Dynamic Host Configuration Protocol (DHCP) client" 15rcvar= 16pidfile="/var/run/dhclient/${name}.${ifn}.pid" 17start_precmd="dhclient_prestart" 18stop_precmd="dhclient_pre_check" 19 20# rc_force check can only be done at the run_rc_command 21# time, so we're testing it in the pre* hooks. 22dhclient_pre_check() 23{ 24 if [ -z "${rc_force}" ] && ! dhcpif $ifn; then 25 local msg 26 msg="'$ifn' is not a DHCP-enabled interface" 27 if [ -z "${rc_quiet}" ]; then 28 echo "$msg" 29 else 30 debug "$msg" 31 fi 32 exit 1 33 fi 34} 35 36dhclient_prestart() 37{ 38 dhclient_pre_check 39 40 # Interface-specific flags (see rc.subr for $flags setting) 41 specific=$(get_if_var $ifn dhclient_flags_IF) 42 if [ -z "$flags" -a -n "$specific" ]; then 43 rc_flags=$specific 44 fi 45 46 background_dhclient=$(get_if_var $ifn background_dhclient_IF $background_dhclient) 47 if checkyesno background_dhclient; then 48 rc_flags="${rc_flags} -b" 49 fi 50 51 dhclient_arpwait=$(get_if_var $ifn dhclient_arpwait_IF $dhclient_arpwait) 52 if ! checkyesno dhclient_arpwait; then 53 rc_flags="${rc_flags} -n" 54 fi 55 56 # /var/run/dhclient is not guaranteed to exist, 57 # e.g. if /var/run is a tmpfs 58 install -d -o root -g wheel -m 755 ${pidfile%/*} 59 60 rc_flags="${rc_flags} ${ifn}" 61} 62 63load_rc_config $name 64load_rc_config network 65 66# dhclient_prestart is not compatible with svcj 67dhclient_svcj="NO" 68 69if [ -z $ifn ] ; then 70 # only complain if a command was specified but no interface 71 if [ -n "$1" ] ; then 72 err 1 "$0: no interface specified" 73 fi 74fi 75 76run_rc_command "$1" 77