summaryrefslogtreecommitdiff
path: root/src/etc
diff options
context:
space:
mode:
authorbri <284789+b-@users.noreply.github.com>2023-02-26 15:05:56 -0500
committerGitHub <noreply@github.com>2023-02-26 21:05:56 +0100
commit40e0cb294e0377fdfe11171b35d78bd27e231df2 (patch)
treec41f96d2d45961496576d08cd5b5044c157b98ca /src/etc
parenta721e8b5067d78886f4dcc396c831ed50eb5472c (diff)
downloadvyos-1x-40e0cb294e0377fdfe11171b35d78bd27e231df2.tar.gz
vyos-1x-40e0cb294e0377fdfe11171b35d78bd27e231df2.zip
T4997: add dhcp client user hooks
This commit adds a script to run user-defined hook scripts upon renewing a DHCP lease. This can be used to, for example, dynamically define a firewall address-group based on the dynamic IP address of an interface. For an example of its use (as well as the use case I had in mind while coding this), see https://vyos.dev/T2196#142394 Co-authored-by: br <git@ibeep.com>
Diffstat (limited to 'src/etc')
-rw-r--r--src/etc/dhcp/dhclient-enter-hooks.d/99-run-user-hooks5
-rwxr-xr-xsrc/etc/dhcp/dhclient-exit-hooks.d/99-run-user-hooks5
2 files changed, 10 insertions, 0 deletions
diff --git a/src/etc/dhcp/dhclient-enter-hooks.d/99-run-user-hooks b/src/etc/dhcp/dhclient-enter-hooks.d/99-run-user-hooks
new file mode 100644
index 000000000..b4b4d516d
--- /dev/null
+++ b/src/etc/dhcp/dhclient-enter-hooks.d/99-run-user-hooks
@@ -0,0 +1,5 @@
+#!/bin/bash
+DHCP_PRE_HOOKS="/config/scripts/dhcp-client/pre-hooks.d/"
+if [ -d "${DHCP_PRE_HOOKS}" ] ; then
+ run-parts "${DHCP_PRE_HOOKS}"
+fi
diff --git a/src/etc/dhcp/dhclient-exit-hooks.d/99-run-user-hooks b/src/etc/dhcp/dhclient-exit-hooks.d/99-run-user-hooks
new file mode 100755
index 000000000..442419d79
--- /dev/null
+++ b/src/etc/dhcp/dhclient-exit-hooks.d/99-run-user-hooks
@@ -0,0 +1,5 @@
+#!/bin/bash
+DHCP_POST_HOOKS="/config/scripts/dhcp-client/post-hooks.d/"
+if [ -d "${DHCP_POST_HOOKS}" ] ; then
+ run-parts "${DHCP_POST_HOOKS}"
+fi