122347Spst#!/bin/sh 222347Spst# 329964Sache# $FreeBSD$ 492906Smarkm# 592906Smarkm 622347Spst# PROVIDE: dhclient 722347Spst# KEYWORD: nojail nostart 822347Spst 922347Spst. /etc/rc.subr 1022347Spst. /etc/network.subr 1122347Spst 1222347Spstifn="$2" 1322347Spst 1422347Spstname="dhclient" 1522347Spstrcvar= 1659118Skrispidfile="/var/run/${name}.${ifn}.pid" 1759118Skrisstart_precmd="dhclient_prestart" 1822347Spststop_precmd="dhclient_pre_check" 1922347Spst 2022347Spst# rc_force check can only be done at the run_rc_command 2122347Spst# time, so we're testing it in the pre* hooks. 2222347Spstdhclient_pre_check() 2322347Spst{ 2422347Spst if [ -z "${rc_force}" ] && ! dhcpif $ifn; then 2522347Spst local msg 2622347Spst msg="'$ifn' is not a DHCP-enabled interface" 2722347Spst if [ -z "${rc_quiet}" ]; then 2822347Spst echo "$msg" 2922347Spst else 3022347Spst debug "$msg" 3122347Spst fi 3222347Spst exit 1 3322347Spst fi 3422347Spst} 3522347Spst 3622347Spstdhclient_prestart() 3722347Spst{ 3822347Spst dhclient_pre_check 3922347Spst 4022347Spst # Interface-specific flags (see rc.subr for $flags setting) 4122347Spst specific=$(get_if_var $ifn dhclient_flags_IF) 4222347Spst if [ -z "$flags" -a -n "$specific" ]; then 4322347Spst rc_flags=$specific 4422347Spst fi 4522347Spst 4622347Spst background_dhclient=$(get_if_var $ifn background_dhclient_IF $background_dhclient) 4722347Spst if checkyesno background_dhclient; then 4822347Spst rc_flags="${rc_flags} -b" 4922347Spst fi 5022347Spst 5122347Spst rc_flags="${rc_flags} ${ifn}" 5222347Spst} 5322347Spst 5422347Spstload_rc_config $name 5522347Spstload_rc_config network 5622347Spst 5722347Spstif [ -z $ifn ] ; then 5822347Spst # only complain if a command was specified but no interface 5922347Spst if [ -n "$1" ] ; then 6022347Spst err 1 "$0: no interface specified" 6122347Spst fi 6222347Spstfi 6322347Spst 6422347Spstrun_rc_command "$1" 6522347Spst