rewrite the olsrd init stuff to have a sane default config
authorFelix Fietkau <nbd@openwrt.org>
Sun, 8 Oct 2006 19:41:06 +0000 (19:41 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Sun, 8 Oct 2006 19:41:06 +0000 (19:41 +0000)
SVN-Revision: 4970

openwrt/package/olsrd/Makefile
openwrt/package/olsrd/files/olsrd.conf [new file with mode: 0644]
openwrt/package/olsrd/files/olsrd.init

index a5092c875886ef87c4cbf95f5ea1dae57f199fd5..6d2ca17f1fc470fdb226a86a4fc48d3d8ef13b65 100644 (file)
@@ -61,7 +61,7 @@ $(PKG_BUILD_DIR)/.built:
 
 $(IPKG_OLSRD):
        install -d -m0755 $(IDIR_OLSRD)/etc
-       $(CP) $(PKG_INSTALL_DIR)/etc/olsrd.conf $(IDIR_OLSRD)/etc/
+       $(CP) ./files/olsrd.conf $(IDIR_OLSRD)/etc/
        install -d -m0755 $(IDIR_OLSRD)/usr/sbin
        $(CP) $(PKG_INSTALL_DIR)/usr/sbin/olsrd $(IDIR_OLSRD)/usr/sbin/
        install -d -m0755 $(IDIR_OLSRD)/etc/init.d
diff --git a/openwrt/package/olsrd/files/olsrd.conf b/openwrt/package/olsrd/files/olsrd.conf
new file mode 100644 (file)
index 0000000..33076ac
--- /dev/null
@@ -0,0 +1,44 @@
+DebugLevel              0
+IpVersion               4
+AllowNoInt              yes
+Pollrate                0.1
+TcRedundancy            2
+MprCoverage             7
+LinkQualityFishEye      1
+LinkQualityWinSize      100
+LinkQualityDijkstraLimit 0 5.0
+
+Hna4 {
+       @@HNA_IP@@ @@HNA_MASK@@
+}
+
+LoadPlugin "olsrd_dyn_gw.so.0.4"
+{
+}
+
+LoadPlugin "olsrd_httpinfo.so.0.1"
+{
+        PlParam "port"  "8080"
+        PlParam "Host"  "127.0.0.1"
+        PlParam "Net" "192.168.1.0 255.255.255.0"
+}
+IpcConnect
+{
+        MaxConnections  1
+        Host            127.0.0.1
+        Net 192.168.1.0 255.255.255.0
+}
+LinkQualityLevel 2
+UseHysteresis no
+Interface @@INTERFACE@@
+{
+        HelloInterval           5.0
+        HelloValidityTime       90.0
+        TcInterval              2.0
+        TcValidityTime          270.0
+        MidInterval             15.0
+        MidValidityTime         90.0
+        HnaInterval             15.0
+        HnaValidityTime         90.0
+}
+
index 1f1fdb95192f2ddab1536873e0ccf6fe20b31322..685f14e9e4c0f5d4ab8e3c4758f5e2fbb6c9864d 100644 (file)
@@ -1,11 +1,38 @@
 #!/bin/sh
 
 DEFAULT=/etc/default/olsrd
+OPTIONS="-f /tmp/olsrd.conf"
 [ -f $DEFAULT ] && . $DEFAULT
 
 case $1 in
- start)
-  olsrd $OPTIONS
+       start)
+               lanip="$(nvram get lan_ipaddr)"
+               case "${lanip%\.*}" in
+                       192.168.1|192.168.0)
+                               HNA_IP=
+                               HNA_MASK=
+                       ;;
+                       *)
+                               HNA_IP="$lanip"
+                               HNA_MASK="$(nvram get lan_netmask)"
+                       ;;
+               esac
+               wifi_ifname="$(nvram get wifi_ifname)"
+               [ -z "$wifi_ifname" ] && grep '@INTERFACE@' /etc/olsrd.conf && {
+                       echo No interface...
+                       exit 1
+               }
+               (
+                       cat <<EOF
+@define HNA_IP $HNA_IP
+@define HNA_MASK $HNA_MASK
+@define INTERFACE "$wifi_ifname"
+EOF
+                       cat /etc/olsrd.conf
+               ) | awk -f /usr/lib/parse-config.awk > /tmp/olsrd.conf
+               iptables -D input_rule -i "$wifi_ifname" -o "$wifi_ifname" -j ACCEPT 2>/dev/null >/dev/null # no duplicates please
+               iptables -A input_rule -i "$wifi_ifname" -o "$wifi_ifname" -j ACCEPT
+               olsrd $OPTIONS
   ;;
  *)
   echo "usage: $0 (start)"