From: Michael Tremer Date: Sun, 7 Aug 2011 08:53:55 +0000 (+0000) Subject: Add script to create radvd configuration file on the fly. X-Git-Tag: 003~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b368da2f339c4829676352cd498f0705a3d3744a;p=network.git Add script to create radvd configuration file on the fly. --- diff --git a/Makefile b/Makefile index 487a9da0..4552d279 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ install: cp -rfv {hooks,header*,functions*} $(DESTDIR)/lib/network/ cp -fv sysctl.d/* $(DESTDIR)/usr/lib/sysctl.d/ cp -rfv udev/* $(DESTDIR)/lib/udev + cp -rfv network-* $(DESTDIR)/lib/network/ install -m 755 -v ppp/ip-updown $(DESTDIR)/etc/ppp ln -svf ip-updown $(DESTDIR)/etc/ppp/ip-pre-up diff --git a/functions.radvd b/functions.radvd index 16534157..0cc04d1c 100644 --- a/functions.radvd +++ b/functions.radvd @@ -38,6 +38,8 @@ function radvd_write_config() { __radvd_write "# This is the radvd daemon configuration file." __radvd_write "# THIS FILE IS AUTOMATICALLY GENERATED AND WILL OVERWRITE" __radvd_write "# ANY CUSTOM CHANGES!" + __radvd_write "#" + __radvd_write "# $(date -u)" __radvd_write "#\n" # Write the configuration for all zones. @@ -47,6 +49,10 @@ function radvd_write_config() { done } +function radvd_clear() { + __radvd_clear +} + function __radvd_clear() { log DEBUG "Clearing radvd config file." @@ -63,6 +69,9 @@ function __radvd_config_interface() { assert isset zone + log DEBUG "Writing radvd configuration for ${zone}" + echo $zone + # If the interface does not provide any routing information, # we can skip this whole stuff. if ! routing_db_exists ${zone} ipv6; then diff --git a/hooks/zones/bridge.configs/ipv4-static b/hooks/zones/bridge.configs/ipv4-static index b46864ef..44b85439 100755 --- a/hooks/zones/bridge.configs/ipv4-static +++ b/hooks/zones/bridge.configs/ipv4-static @@ -79,15 +79,13 @@ function _up() { ip_address_add ${zone} ${ADDRESS}/${PREFIX} - if [ -n "${GATEWAY}" ]; then - # Save configuration - routing_db_set ${zone} ipv4 type "${HOOK}" - routing_db_set ${zone} ipv4 local-ip-address "${ADDRESS}/${PREFIX}" - routing_db_set ${zone} ipv4 remote-ip-address "${GATEWAY}" - routing_db_set ${zone} ipv4 active 1 + # Save configuration + routing_db_set ${zone} ipv4 type "${HOOK}" + routing_db_set ${zone} ipv4 local-ip-address "${ADDRESS}/${PREFIX}" + routing_db_set ${zone} ipv4 remote-ip-address "${GATEWAY}" + routing_db_set ${zone} ipv4 active 1 - routing_update ${zone} ipv4 - fi + routing_update ${zone} ipv4 exit ${EXIT_OK} } diff --git a/hooks/zones/bridge.configs/ipv6-static b/hooks/zones/bridge.configs/ipv6-static index aaaafacd..097823c7 100755 --- a/hooks/zones/bridge.configs/ipv6-static +++ b/hooks/zones/bridge.configs/ipv6-static @@ -78,12 +78,10 @@ function _up() { ip_address_add ${zone} ${ADDRESS}/${PREFIX} - if [ -n "${GATEWAY}" ]; then - routing_db_set ${zone} ipv6 local-ip-address ${ADDRESS}/${PREFIX} - routing_db_set ${zone} ipv6 remote-ip-address ${GATEWAY} - routing_db_set ${zone} ipv6 active 1 - routing_default_update - fi + routing_db_set ${zone} ipv6 local-ip-address ${ADDRESS}/${PREFIX} + routing_db_set ${zone} ipv6 remote-ip-address ${GATEWAY} + routing_db_set ${zone} ipv6 active 1 + routing_default_update exit ${EXIT_OK} } diff --git a/network-radvd-config b/network-radvd-config new file mode 100755 index 00000000..fbf7e790 --- /dev/null +++ b/network-radvd-config @@ -0,0 +1,35 @@ +#!/bin/bash +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2011 Michael Tremer & Christian Schmidt # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +. /lib/network/functions + +case "${1}" in + start) + # Write the radvd configuration file. + radvd_write_config + ;; + stop) + # Clear all contents in the configuration file. + radvd_clear + ;; +esac + +exit ${EXIT_OK}