Last active
October 13, 2023 14:49
-
-
Save b-/ddc0b039b50e7a4eea6c7a87cb6604ad to your computer and use it in GitHub Desktop.
set-addrgroup for vyos
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# /config/scripts/dhcp-client/post-hooks.d/set-addrgroup | |
# To enable this script set the following variable to "yes" | |
RUN="yes" | |
if [ "$RUN" = "yes" ]; then | |
tmpfile=$(mktemp /tmp/dhcp-script.XXXXXXXX) | |
chmod -R 755 "${tmpfile}" | |
logfile=/tmp/set-addrgroup.debug | |
if [[ _"$reason"_ == "_BOUND_" ]] ; then | |
echo "BOUND!" >> $logfile | |
echo "$tmpfile" >> $logfile | |
tee "$tmpfile" >> $logfile <<EOF | |
#!/usr/bin/vbash | |
source /opt/vyatta/etc/functions/script-template | |
configure | |
delete firewall group address-group ADDRv4_${interface} | |
set firewall group address-group ADDRv4_${interface} address ${new_ip_address} | |
commit comment "Updated address-group ADDRv4${interface} from DHCP" | |
save | |
EOF | |
sg vyattacfg -c "/usr/bin/vbash -x ${tmpfile}" | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment