diff options
author | des <des@FreeBSD.org> | 2011-10-13 17:20:45 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2011-10-13 17:20:45 +0000 |
commit | ad844b42a2ded6583ac9176413a9ef594c5e677b (patch) | |
tree | 572fea409097b2acc4b4642288642b8048c9efca /etc | |
parent | c9a3d28e97b357af334a68382823f39076347e40 (diff) | |
download | FreeBSD-src-ad844b42a2ded6583ac9176413a9ef594c5e677b.zip FreeBSD-src-ad844b42a2ded6583ac9176413a9ef594c5e677b.tar.gz |
Make dhclient use a pid file. Modify the rc script accordingly; while
there, clean it up and add some error checks.
Glanced at by: brooks@
MFC after: 3 weeks
Diffstat (limited to 'etc')
-rwxr-xr-x | etc/rc.d/dhclient | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/etc/rc.d/dhclient b/etc/rc.d/dhclient index c7e4b4d..8faf0ec 100755 --- a/etc/rc.d/dhclient +++ b/etc/rc.d/dhclient @@ -9,55 +9,39 @@ . /etc/rc.subr . /etc/network.subr +ifn="$2" + name="dhclient" rcvar= -start_cmd="dhclient_start" -stop_cmd="dhclient_stop" +pidfile="/var/run/${name}.${ifn}.pid" +start_precmd="dhclient_prestart" -dhclient_start() +dhclient_prestart() { - # prevent unnecessary restarts - # XXX: dhclient had better create a pidfile - if [ -x /bin/pgrep ]; then - pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"` - if [ -n "$pids" ]; then - sleep 1 - pids=`/bin/pgrep -f "dhclient: $ifn(\$| .*)"` - if [ -n "$pids" ]; then - exit 0 - fi - elif [ -e /var/run/dhclient.pid ]; then - if [ -n "`pgrep -F /var/run/dhclient.pid`" ]; then - exit 0 - fi - fi - fi - - # Override for $ifn specific flags (see rc.subr for $flags setting) - specific=`get_if_var $ifn dhclient_flags_IF` + # Interface-specific flags (see rc.subr for $flags setting) + specific=$(get_if_var $ifn dhclient_flags_IF) if [ -z "$flags" -a -n "$specific" ]; then rc_flags=$specific fi - background_dhclient=`get_if_var $ifn background_dhclient_IF $background_dhclient` + background_dhclient=$(get_if_var $ifn background_dhclient_IF $background_dhclient) if checkyesno background_dhclient; then rc_flags="${rc_flags} -b" fi - ${dhclient_program} ${rc_flags} $ifn -} - -dhclient_stop() -{ - ifconfig $ifn down # cause dhclient to die + rc_flags="${rc_flags} ${ifn}" } -ifn="$2" - load_rc_config $name load_rc_config network -if ! dhcpif $ifn; then +if [ -z $ifn ] ; then + # only complain if a command was specified but no interface + if [ -n "$1" ] ; then + echo 1>&2 "$0: no interface specified" + return 1 + fi +elif [ -n "${rc_force}" ] && ! dhcpif $ifn; then return 1 fi |