]> git.ipfire.org Git - network.git/commitdiff
Add script to create radvd configuration file on the fly.
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 7 Aug 2011 08:53:55 +0000 (08:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 7 Aug 2011 08:53:55 +0000 (08:53 +0000)
Makefile
functions.radvd
hooks/zones/bridge.configs/ipv4-static
hooks/zones/bridge.configs/ipv6-static
network-radvd-config [new file with mode: 0755]

index 487a9da019a15b9f798e01713881eca0363b6203..4552d2794ba47534ace21836c02f7356441762ec 100644 (file)
--- 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
index 1653415738c1f9935338f69bf4dbb9d569f043e1..0cc04d1c3339ce7d414c0aa40bb4bd9c08720235 100644 (file)
@@ -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
index b46864eff46198d46fbc8e62a28e6971a34b73aa..44b854397c7b1c687051c51ae1bfa17c447d0424 100755 (executable)
@@ -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}
 }
index aaaafacd5b49b3b8f1df77d5565cc7443732b8e4..097823c724f0c1c31441eae44f43caca83a89360 100755 (executable)
@@ -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 (executable)
index 0000000..fbf7e79
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+. /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}