diff options
author | zsdc <taras@vyos.io> | 2021-10-25 21:44:00 +0300 |
---|---|---|
committer | zsdc <taras@vyos.io> | 2021-10-25 21:44:00 +0300 |
commit | 393970f9ee5b3dfc58e0e999d3d5941a198b2c6f (patch) | |
tree | ef87fed363eb487d6eaf28d41ffcee6de95b7a43 /src/etc/dhcp | |
parent | 8cf5a4f023c5459cad4c84e93f73a9ddd69be81a (diff) | |
download | vyos-1x-393970f9ee5b3dfc58e0e999d3d5941a198b2c6f.tar.gz vyos-1x-393970f9ee5b3dfc58e0e999d3d5941a198b2c6f.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.
Diffstat (limited to 'src/etc/dhcp')
-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} |