diff options
Diffstat (limited to 'roles/ws/minet/files/minet_helpers.sh')
-rw-r--r-- | roles/ws/minet/files/minet_helpers.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/roles/ws/minet/files/minet_helpers.sh b/roles/ws/minet/files/minet_helpers.sh new file mode 100644 index 00000000..1b82e4a5 --- /dev/null +++ b/roles/ws/minet/files/minet_helpers.sh @@ -0,0 +1,53 @@ +# These are helper functions for the Minimalistic Network Manager +# Author: Christian Pointner <equinox@chaos-at-home.org> + +activate_interface() +{ + echo 2 > /proc/sys/net/ipv6/conf/default/use_tempaddr + modprobe $2 + while true; do + ip link set up dev $1 >/dev/null 2>&1 + if [ $? -eq 0 ]; then + break + fi + echo -n "." + sleep 1 + echo 2 > /proc/sys/net/ipv6/conf/$1/use_tempaddr + done + if [ $2 = "eth0" ]; then + sleep 2 + ethtool -s $2 advertise 0x008 + fi + echo "" +} + +deactivate_interface() +{ + ip link set down dev $1 >/dev/null 2>&1 + modprobe -r $2 +} + +wpa_select_ssid() +{ + NET=$(wpa_cli -i$1 list_networks | awk "BEGIN { FS = \"\\t\" } ; \$2 == \"$2\" { print(\$1) }") + if [ -n "$NET" ]; then + wpa_cli -i$1 select_network $NET + else + echo "SSID '$2' is not in wpa_supplicant.conf - ignoring it..." + fi +} + +create_6to4() +{ + IPV6_ADDR=`printf "2002:%02x%02x:%02x%02x::1" \`echo "$2" | tr "." " "\`` + + ip tunnel add mode sit remote 192.88.99.1 name $1 + ip link set dev $1 up + ip addr add dev $1 $IPV6_ADDR/48 + ip -6 route add default dev $1 +} + +destroy_6to4() +{ + ip tunnel del name $1 +} |