diff options
| author | lassulus <lassulus@googlemail.com> | 2011-12-23 11:21:19 +0100 | 
|---|---|---|
| committer | lassulus <lassulus@googlemail.com> | 2011-12-23 11:21:19 +0100 | 
| commit | 700072324a693670664d8674a7a6371d6f1b47e4 (patch) | |
| tree | 7b8bfb2a37fc8f93431bf8c10bdf475649fba320 /retiolum/scripts/routing | |
| parent | 87dbc17afc18b541a122662334c005d3e972880b (diff) | |
added defaultroute script
Diffstat (limited to 'retiolum/scripts/routing')
| -rwxr-xr-x | retiolum/scripts/routing/defaultroute.sh | 37 | 
1 files changed, 37 insertions, 0 deletions
diff --git a/retiolum/scripts/routing/defaultroute.sh b/retiolum/scripts/routing/defaultroute.sh new file mode 100755 index 00000000..0cb142d0 --- /dev/null +++ b/retiolum/scripts/routing/defaultroute.sh @@ -0,0 +1,37 @@ +#!/bin/bash +usage() +{ +    echo "usage:" +    echo "-h,      print this help youre currently reading" +    echo "-a       activate routing" +    echo "-d       deactivate routing" +} + +defaultroute=$(route -n | grep 'UG[ \t]' | awk '{print $2}') +tincdir="/etc/tinc/retiolum" + +if [[ $(id -u) -gt 0 ]]; then +    echo "This script should be run as root." +    exit 1 +fi + +case "$1" in +    -h|-help) +        usage +        exit 0;; +    -a) +        command="add" +        ;; +    -d) +        command="del" +        ;; +    -*|*) +        usage +        exit 1;; +esac + +cat $tincdir/hosts/* | grep Address | cut -b 11- | +while read host +do +    route $command $host gw $defaultroute +done  | 
