diff options
author | Lassulus <lassulus@googlemail.com> | 2012-12-28 01:56:08 +0100 |
---|---|---|
committer | Lassulus <lassulus@googlemail.com> | 2012-12-28 01:56:08 +0100 |
commit | 1aa5bf4c3c30c474c081bcb8d89a4f06fd3e6e86 (patch) | |
tree | 93d8ecab1ce3d40a4d84d11cd996fdb44f10bcfd | |
parent | 98f66c758c1a5eaaacd0cd8ad7ecb742d8adae2f (diff) |
fixed netmask magic
-rwxr-xr-x | retiolum/scripts/tinc_setup/new_install.sh | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/retiolum/scripts/tinc_setup/new_install.sh b/retiolum/scripts/tinc_setup/new_install.sh index 579ebff9..82878673 100755 --- a/retiolum/scripts/tinc_setup/new_install.sh +++ b/retiolum/scripts/tinc_setup/new_install.sh @@ -17,6 +17,7 @@ HOSTN=${HOSTN:-$SYSHOSTN} NETNAME=${NETNAME:-retiolum} MASK4=${MASK4:-16} MASK6=${MASK6:-16} +RMASK=${RMASK:-255.255.0.0} URL=${URL:-http://euer.krebsco.de/retiolum/hosts.tar.gz} SURL=${SURL:-http://euer.krebsco.de/retiolum/supernodes.tar.gz} @@ -60,14 +61,13 @@ EOF host2subnet() { NEEDDOTSINSUB=$(expr 3 - $( echo $SUBNET4 | tr -C -d . | wc -c)) - FULLSUBNET=$(echo $SUBNET4$(eval "printf '.0'%.0s {1..${#NEEDDOTSINSUB}}"s)) - result=$(($(($((1 << $1)) - 1)) << $((32 - $1)))) - byte="" - for i in {0..2}; do - byte=.$(($result % 256))$byte - result=$(($result / 256)) - done - RETARDEDMASK=$result$byte + case $NEEDDOTSINSUB in + 3) FULLSUBNET=$SUBNET4.0.0.0 ;; + 2) FULLSUBNET=$SUBNET4.0.0 ;; + 1) FULLSUBNET=$SUBNET4.0 ;; + 0) FULLSUBNET=$SUBNET4 ;; + *) echo "cannot read subnet" && exit 1;; + esac } #check if ip is valid ipv4 function @@ -370,7 +370,7 @@ else echo '' >> tinc-up echo "addr4=\$(sed -n \"s|^ *Subnet *= *\\($SUBNET4[.][^ ]*\\) *$|\\1|p\" \$host)" >> tinc-up echo 'ifconfig $INTERFACE $addr4' >> tinc-up - echo "route add -net $FULLSUBNET netmask $RETARDEDMASK dev \$INTERFACE " >> tinc-up + echo "route add -net $FULLSUBNET netmask $RMASK dev \$INTERFACE " >> tinc-up fi #fix permissions |