This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "IPFire 2.x development tree".
The branch, static-routing has been updated via daf9669080f7b03530bdebcfee822697c89242c5 (commit) via aba9ac599fe3ba8657a2a35519ee0e8266def38b (commit) from bfd77eaf70f5112da41c9ae379c130fc8bceed76 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit daf9669080f7b03530bdebcfee822697c89242c5 Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jul 5 19:10:31 2011 +0200
Add binary "rebuildroutes" to setup routes from the webif.
commit aba9ac599fe3ba8657a2a35519ee0e8266def38b Author: Michael Tremer michael.tremer@ipfire.org Date: Tue Jul 5 18:57:33 2011 +0200
Update static routing script to actually add the routes.
-----------------------------------------------------------------------
Summary of changes: config/rootfiles/common/misc-progs | 1 + src/initscripts/init.d/static-routes | 54 +++++++++++++++++++++++++-------- src/misc-progs/Makefile | 4 ++- src/misc-progs/rebuildroutes.c | 17 ++++++++++ 4 files changed, 62 insertions(+), 14 deletions(-) create mode 100644 src/misc-progs/rebuildroutes.c
Difference in files: diff --git a/config/rootfiles/common/misc-progs b/config/rootfiles/common/misc-progs index 6e5d7ca..adab51b 100644 --- a/config/rootfiles/common/misc-progs +++ b/config/rootfiles/common/misc-progs @@ -18,6 +18,7 @@ usr/local/bin/outgoingfwctrl usr/local/bin/pakfire usr/local/bin/qosctrl usr/local/bin/rebuildhosts +usr/local/bin/rebuildroutes usr/local/bin/redctrl #usr/local/bin/sambactrl usr/local/bin/setaliases diff --git a/src/initscripts/init.d/static-routes b/src/initscripts/init.d/static-routes index 184f97d..970083c 100644 --- a/src/initscripts/init.d/static-routes +++ b/src/initscripts/init.d/static-routes @@ -6,34 +6,62 @@
function init_table() { # Check if table does already exist. If not we add it. - if (ip rule | grep -qeE static >/dev/null 2>&1); then + if (ip rule | grep -q "static" >/dev/null 2>&1); then return fi
ip rule add table static }
+function create_all_routes() { + local file=${1} + shift + + # Remote all routes. + ip route flush table static >/dev/null 2>&1 + + local status + local network + local gateway + local remark + + # Read all routes from the configuration file and add the enabled ones + # immediately. + while IFS=, read status network gateway remark; do + [ "${status}" = "on" ] || continue + + if [ -z "${network}" -o -z "${gateway}" ]; then + # Silently skipping invalid routes. + continue + fi + + ip route add ${network} via ${gateway} table static + done < ${file} +} + +CONFIGFILE="/var/ipfire/main/routing"
case "${1}" in start) - boot_mesg "Adding static routes..." + boot_mesg "Adding static routes..."
# First, initialize the table - init_table + init_table
- ### ADD ALL ROUTES + # Add all routes + create_all_routes ${CONFIGFILE}
evaluate_retval - ;; + ;;
- stop) - boot_mesg "Removing static routes..." - ip route flush table static >/dev/null 2>&1 + stop) + boot_mesg "Removing static routes..." + ip route flush table static >/dev/null 2>&1 evaluate_retval - ;; + ;;
- *) - echo "Usage: ${0} {start|stop}" - exit 1 - ;; + *) + echo "Usage: ${0} {start|stop}" + exit 1 + ;; esac diff --git a/src/misc-progs/Makefile b/src/misc-progs/Makefile index 348f91c..9f1e3f0 100644 --- a/src/misc-progs/Makefile +++ b/src/misc-progs/Makefile @@ -32,7 +32,7 @@ SUID_PROGS = setdmzholes setportfw setxtaccess \ wirelessctrl getipstat getiptstate qosctrl launch-ether-wake \ redctrl syslogdctrl extrahdctrl sambactrl upnpctrl tripwirectrl \ smartctrl clamavctrl addonctrl pakfire mpfirectrl wlanapctrl \ - setaliases urlfilterctrl updxlratorctrl fireinfoctrl + setaliases urlfilterctrl updxlratorctrl fireinfoctrl rebuildroutes SUID_UPDX = updxsetperms
install : all @@ -158,3 +158,5 @@ updxsetperms: updxsetperms.c setuid.o ../install+setup/libsmooth/varval.o fireinfoctrl: fireinfoctrl.c setuid.o ../install+setup/libsmooth/varval.o $(COMPILE) -I../install+setup/libsmooth/ fireinfoctrl.c setuid.o ../install+setup/libsmooth/varval.o -o $@
+rebuildroutes: rebuildroutes.c setuid.o ../install+setup/libsmooth/varval.o + $(COMPILE) -I../install+setup/libsmooth/ rebuildroutes.c setuid.o ../install+setup/libsmooth/varval.o -o $@ diff --git a/src/misc-progs/rebuildroutes.c b/src/misc-progs/rebuildroutes.c new file mode 100644 index 0000000..3655692 --- /dev/null +++ b/src/misc-progs/rebuildroutes.c @@ -0,0 +1,17 @@ +/* IPFire helper program - rebuildroutes + * + * This program is distributed under the terms of the GNU General Public + * Licence. See the file COPYING for details. + */ + +#include "libsmooth.h" +#include "setuid.h" + +int main(int argc, char *argv[]) { + if (!(initsetuid())) + exit(1); + + safe_system("/etc/init.d/static-routes start >/dev/null 2>&1"); + + return 0; +}
hooks/post-receive -- IPFire 2.x development tree