summaryrefslogtreecommitdiff
path: root/files/common/etc/init.d/n2n
diff options
context:
space:
mode:
authorwrtbuild <wrtbuild@localhost.(none)>2011-10-16 07:34:24 (GMT)
committerwrtbuild <wrtbuild@localhost.(none)>2011-10-16 07:34:24 (GMT)
commit64ca2d1ca4e6f9ae279fc17d84b2abd453140d28 (patch)
tree84a28cd644955e52bd6b91f2c474e9f338841119 /files/common/etc/init.d/n2n
parent0850ac21d153d490ddc2b02f29b74b4b5ed88181 (diff)
add makefile to generate images
Diffstat (limited to 'files/common/etc/init.d/n2n')
-rwxr-xr-xfiles/common/etc/init.d/n2n43
1 files changed, 43 insertions, 0 deletions
diff --git a/files/common/etc/init.d/n2n b/files/common/etc/init.d/n2n
new file mode 100755
index 0000000..26f2e72
--- /dev/null
+++ b/files/common/etc/init.d/n2n
@@ -0,0 +1,43 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2008 OpenWrt.org
+[ -n "$IPKG_INSTROOT" ] && exit 0
+START=90
+
+config_cb() {
+ local cfg="$CONFIG_SECTION"
+ config_get configname "$cfg" TYPE
+
+ case "$configname" in
+ edge)
+ config_get ipaddr "$cfg" ipaddr
+ config_get supernode "$cfg" supernode
+ config_get port "$cfg" port
+ config_get community "$cfg" community
+ config_get key "$cfg" key
+ config_get_bool route "$cfg" route 0
+ config_get devname "$cfg" devname
+ node_mac=`ifconfig ath0 | grep HWaddr | awk '{print $5}' | tr -d "\n" | cut -c6-`
+ [ "$route" = "1" ] && args='-r'
+ if [ "$ipaddr" != "" ]; then
+ mac_random=`echo $(head -30 /dev/urandom | tr -dc "0123456789" | head -c2)`
+ edge -f $args -a 169.254.0.1 -d $devname -c $community -k $key -m 12:${mac_random}${node_mac} -l ${supernode}:${port}
+ ifconfig $devname 0.0.0.0
+ batctl if add $devname
+ fi
+ ;;
+ supernode)
+ config_get port "$cfg" port
+ if [ "$port" != "" ]; then
+ supernode -l $port &
+ fi
+ ;;
+ esac
+}
+
+start() {
+ config_load n2n
+}
+stop() {
+ killall -9 edge
+ killall supernode
+}
contact: Jan Huwald // Impressum