dhclient revision 178233
1#!/bin/sh 2# 3# $FreeBSD: head/etc/rc.d/dhclient 178233 2008-04-15 23:03:35Z brooks $ 4# 5 6# PROVIDE: dhclient 7# KEYWORD: nojail nostart 8 9. /etc/rc.subr 10. /etc/network.subr 11 12name="dhclient" 13rcvar= 14start_cmd="dhclient_start" 15stop_cmd="dhclient_stop" 16 17dhclient_start() 18{ 19 # prevent unnecessary restarts 20 # XXX: dhclient had better create a pidfile 21 if [ -x /bin/pgrep ]; then 22 pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"` 23 if [ -n "$pids" ]; then 24 sleep 1 25 pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"` 26 if [ -n "$pids" ]; then 27 exit 0 28 fi 29 elif [ -e /var/run/dhclient.pid ]; then 30 if [ -n "`pgrep -F /var/run/dhclient.pid`" ]; then 31 exit 0 32 fi 33 fi 34 fi 35 36 # Override for $ifn specific flags (see rc.subr for $flags setting) 37 specific=`get_if_var $ifn dhclient_flags_IF` 38 if [ -z "$flags" -a -n "$specific" ]; then 39 rc_flags=$specific 40 fi 41 42 background_dhclient=`get_if_var $ifn background_dhclient_IF $background_dhclient` 43 if checkyesno background_dhclient; then 44 rc_flags="${rc_flags} -b" 45 fi 46 47 ${dhclient_program} ${rc_flags} $ifn 48} 49 50dhclient_stop() 51{ 52 ifconfig $ifn down # cause dhclient to die 53} 54 55ifn="$2" 56 57load_rc_config $name 58load_rc_config network 59 60if ! dhcpif $ifn; then 61 return 1 62fi 63 64run_rc_command "$1" 65