#!/bin/sh

# Get the PID
PIDFILE='/var/run/dhclient.<%= scope.lookupvar('site_config::params::interface') %>.pid'

# Capture how dhclient is currently running so we can relaunch it
dhclient=`/bin/ps --no-headers --pid $(cat $PIDFILE) -f | /usr/bin/awk '{for(i=8;i<=NF;++i) printf("%s ",  $i) }'`

# Kill the current dhclient
/usr/bin/pkill -F $PIDFILE

# Restart dhclient with the arguments it had previously
$dhclient