diff options
author | zsdc <taras@vyos.io> | 2021-10-25 21:44:00 +0300 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-11-01 09:11:22 +0100 |
commit | 0c2384114e8abbd9c883a57729564c70c0a86eec (patch) | |
tree | b4178e675dd3c0b606fec83341ae831ec48c9c25 /src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient | |
parent | e482377b29df05e60dbdb31d6276ae2030ffa2f9 (diff) | |
download | vyos-1x-0c2384114e8abbd9c883a57729564c70c0a86eec.tar.gz vyos-1x-0c2384114e8abbd9c883a57729564c70c0a86eec.zip |
dhclient: T3940: Added lease file argument to the `dhclient -x` call
When `dhclient` with the `-x` option is used to stop running DHCP client
with a lease file that is not the same as in the new `dhclient` process,
it requires a `-lf` argument with a path to the old lease file to find
information about old/active leases and process them according to
instructions and config.
This commit adds the option to the `02-vyos-stopdhclient` hook, which
allows to properly process `dhclient` instances started in different
ways.
(cherry picked from commit 393970f9ee5b3dfc58e0e999d3d5941a198b2c6f)
Diffstat (limited to 'src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient')
-rw-r--r-- | src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient b/src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient index f737148dc..ae6bf9f16 100644 --- a/src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient +++ b/src/etc/dhcp/dhclient-enter-hooks.d/02-vyos-stopdhclient @@ -23,10 +23,12 @@ if [ -z ${CONTROLLED_STOP} ] ; then if ([ $dhclient -ne $current_dhclient ] && [ $dhclient -ne $master_dhclient ]); then # get path to PID-file of dhclient process local dhclient_pidfile=`ps --no-headers --format args --pid $dhclient | awk 'match(\$0, ".*-pf (/.*pid) .*", PF) { print PF[1] }'` + # get path to lease-file of dhclient process + local dhclient_leasefile=`ps --no-headers --format args --pid $dhclient | awk 'match(\$0, ".*-lf (/\\\S*leases) .*", LF) { print LF[1] }'` # stop dhclient with native command - this will run dhclient-script with correct reason unlike simple kill - logmsg info "Stopping dhclient with PID: ${dhclient}, PID file: $dhclient_pidfile" + logmsg info "Stopping dhclient with PID: ${dhclient}, PID file: ${dhclient_pidfile}, Leases file: ${dhclient_leasefile}" if [[ -e $dhclient_pidfile ]]; then - dhclient -e CONTROLLED_STOP=yes -x -pf $dhclient_pidfile + dhclient -e CONTROLLED_STOP=yes -x -pf $dhclient_pidfile -lf $dhclient_leasefile else logmsg error "PID file $dhclient_pidfile does not exists, killing dhclient with SIGTERM signal" kill -s 15 ${dhclient} |