Files
configpolicy/roles/dch-gw/files/outside-address.dhcpcd-hook
Dustin C. Hatch a7ac6c586d dch-gw: Initial commit
The *dch-gw* role, and the corresponding `dch-gw.yml` playbook, apply
all of the necessary configuration to the edge router on my home
network.
2018-03-27 20:44:43 -05:00

29 lines
456 B
Bash

# vim: set ft=sh :
(
RULESET=/var/lib/dhcpcd/outside-address.ruleset
reload_nftables() {
systemctl reload nftables
}
write_ruleset() {
install -d "${RULESET%/*}"
printf 'define outside_address = %s\n' "${new_ip_address}" \
> "${RULESET}"
}
if [ -n "${new_ip_address}" ]; then
if [ ! -f "${ruleset}" ]; then
write_ruleset
reload_nftables
elif [ "${new_ip_address}" != "${old_ip_address}" ]; then
write_ruleset
reload_nftables
fi
fi
)