OONF v0.9.1 for chaos calmer 119/head
authorHenning Rogge <hrogge@gmail.com>
Wed, 5 Aug 2015 11:19:59 +0000 (13:19 +0200)
committerHenning Rogge <hrogge@gmail.com>
Wed, 5 Aug 2015 11:19:59 +0000 (13:19 +0200)
12 files changed:
oonf-dlep-proxy/Makefile [new file with mode: 0644]
oonf-dlep-proxy/files/dlep_proxy.hotplug [new file with mode: 0755]
oonf-dlep-proxy/files/dlep_proxy.init [new file with mode: 0755]
oonf-dlep-proxy/files/dlep_proxy.uci [new file with mode: 0644]
oonf-dlep-radio/Makefile [new file with mode: 0644]
oonf-dlep-radio/files/dlep_radio.hotplug [new file with mode: 0755]
oonf-dlep-radio/files/dlep_radio.init [new file with mode: 0755]
oonf-dlep-radio/files/dlep_radio.uci [new file with mode: 0644]
oonf-olsrd2/Makefile [new file with mode: 0644]
oonf-olsrd2/files/olsrd2.hotplug [new file with mode: 0755]
oonf-olsrd2/files/olsrd2.init [new file with mode: 0755]
oonf-olsrd2/files/olsrd2.uci [new file with mode: 0644]

diff --git a/oonf-dlep-proxy/Makefile b/oonf-dlep-proxy/Makefile
new file mode 100644 (file)
index 0000000..9a6cd2f
--- /dev/null
@@ -0,0 +1,67 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=oonf-dlep-proxy
+PKG_VERSION:=0.9.1-r1
+PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
+PKG_RELEASE:=$(PKG_REV)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://olsr.org/git/oonf.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+CMAKE_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_OPTIONS=-D OONF_NO_WERROR:Bool=true \
+              -D OONF_LOGGING_LEVEL:String=debug \
+              -D OONF_NO_TESTING:Bool=true \
+              -D UCI:Bool=true \
+              -D OONF_APP_DEFAULT_CFG_HANDLER:String=uci \
+              -D OONF_STATIC_PLUGINS:String="class;clock;interface;layer2;packet_socket;socket;stream_socket;telnet;timer;viewer;os_clock;os_socket;os_interface;os_system;nl80211_listener;layer2info;systeminfo;cfg_uciloader;cfg_compact;dlep_proxy" \
+              -D OONF_LIB_GIT:String=v$(PKG_VERSION)-archive \
+              -D OONF_VERSION:String=$(PKG_VERSION) \
+              -D INSTALL_LIB_DIR:Path=lib/oonf \
+              -D INSTALL_INCLUDE_DIR:Path=include/oonf \
+              -D INSTALL_CMAKE_DIR:Path=lib/oonf \
+              -D CMAKE_PREFIX_PATH=$(STAGING_DIR)/usr
+
+define Package/oonf-git/template
+       SECTION:=net
+       CATEGORY:=Network
+       MAINTAINER:=Henning Rogge <hrogge@gmail.com>
+       SUBMENU:=OLSR.org network framework
+       URL:=http://www.olsr.org/
+endef
+
+define Package/oonf-dlep-proxy
+       $(call Package/oonf-git/template) 
+       TITLE:= Build DLEP Radio+Router Agent
+       DEPENDS:=+librt +libnl-tiny +libuci
+       VERSION:=$(PKG_VERSION)
+endef
+
+Build/Compile=$(call Build/Compile/Default,dlep_radio_static)
+Build/Install=
+
+define Build/Install
+       $(INSTALL_BIN) -D $(PKG_BUILD_DIR)/$(MAKE_PATH)/dlep_radio_static $(PKG_INSTALL_DIR)/usr/sbin/dlep_proxy;
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -I${STAGING_DIR}/usr/include/libnl-tiny
+
+define Package/oonf-dlep-proxy/install
+       $(INSTALL_BIN)  -D $(PKG_BUILD_DIR)/dlep_radio_static $(1)/usr/sbin/dlep_proxy
+       $(INSTALL_BIN)  -D ./files/dlep_proxy.init            $(1)/etc/init.d/dlep_proxy
+       $(INSTALL_BIN)  -D ./files/dlep_proxy.hotplug         $(1)/etc/hotplug.d/iface/50-dlep_proxy
+       $(INSTALL_DATA) -D ./files/dlep_proxy.uci             $(1)/etc/config/dlep_proxy
+endef
+
+define Package/oonf-dlep-proxy/conffiles
+/etc/config/dlep_proxy
+endef
+
+$(eval $(call BuildPackage,oonf-dlep-proxy))
diff --git a/oonf-dlep-proxy/files/dlep_proxy.hotplug b/oonf-dlep-proxy/files/dlep_proxy.hotplug
new file mode 100755 (executable)
index 0000000..e42e646
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+daemon=dlep_proxy
+
+case "$ACTION" in
+       ifup)
+               . /etc/rc.common /etc/init.d/${daemon} enabled && {
+                       logger -t '${daemon}[hotplug]' -p daemon.info 'reloading configuration'
+                       . /etc/rc.common /etc/init.d/${daemon} reload
+               }
+       ;;
+esac
diff --git a/oonf-dlep-proxy/files/dlep_proxy.init b/oonf-dlep-proxy/files/dlep_proxy.init
new file mode 100755 (executable)
index 0000000..fddbf01
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/sh /etc/rc.common
+
+START=82
+
+daemon=dlep_proxy
+
+. /usr/share/libubox/jshn.sh
+
+oonf_log()
+{
+  logger -s -t ${daemon} -p daemon.info "$1"
+}
+
+oonf_get_layer3_device()
+{
+  local interface="$1"  # e.g. 'mywifi'
+  local status dev proto
+  local query="{ \"interface\" : \"$interface\" }"
+
+  status="$( ubus -S call network.interface status "$query" )" && {
+    json_load "$status"
+    json_get_var 'dev' l3_device
+    json_get_var 'proto' proto
+    case "$proto" in
+      pppoe)
+        # TODO: otherwise it segfaults
+        oonf_log "refusing to add '$interface', because of proto '$proto'"
+      ;;
+      *)
+        echo "$dev" # e.g. 'wlan0-1'
+      ;;
+    esac
+  }
+}
+
+oonf_add_devices_to_configuration()
+{
+  local i=0
+  local device_name= section= interface= single_interface=
+
+  # make a copy of configuration and
+  # add a 'name' (physical name) for all
+  # 'interface-names' (e.g. mywifi)
+  #
+  # olsrd2.@interface[2]=interface
+  # olsrd2.@interface[2].ifname='wan lan wlanadhoc wlanadhocRADIO1'
+
+  # /var is in ramdisc/tmpfs
+  cp /etc/config/${daemon} /var/etc/${daemon}_dev
+
+  while section="$( uci -q -c /etc/config get "${daemon}.@[$i]" )"; do {
+    echo "section: $section"
+
+    interface="$( uci -q -c /etc/config get "${daemon}.@[$i].ifname" )" || {
+      i=$(( $i + 1 ))
+      continue
+    }
+
+    case "$( uci -q get "${daemon}.@[$i].ignore" )" in
+      1|on|true|enabled|yes)
+        oonf_log "removing/ignore section '$section'"
+        uci -q -c /var/etc delete "${daemon}_dev.@[$j]"
+        i=$(( $i + 1 ))
+
+        continue
+      ;;
+    esac
+
+    for single_interface in $interface; do {
+      device_name="$( oonf_get_layer3_device "$single_interface" )"
+
+      echo "Interface: $single_interface = $device_name"
+
+      if [ ! -z "$device_name" ]
+      then
+        # add option 'name' for 'ifname' (e.g. 'mywifi')
+        uci -q -c /var/etc add_list "${daemon}_dev.@[$i].name=$device_name"
+      fi
+    } done
+    i=$(( $i + 1 ))
+  } done
+
+  uci -q -c /var/etc commit ${daemon}_dev
+
+  oonf_log "wrote '/var/etc/${daemon}_dev'"
+}
+
+oonf_reread_config()
+{
+  local pid
+  local pidfile='/var/run/${daemon}.pid'
+
+  if   [ -e "$pidfile" ]; then
+    read pid <"$pidfile"
+  elif pidfile="$( uci -q get '${daemon}.@global[0].pidfile' )"; then
+    read pid <"$pidfile"
+  fi
+
+  # if empty, ask kernel
+  pid="${pid:-$( pidof ${daemon} )}"
+
+  [ -n "$pid" ] && kill -SIGHUP $pid
+}
+
+start()
+{
+  oonf_add_devices_to_configuration
+
+  # produce coredumps
+  ulimit -c unlimited
+
+  service_start /usr/sbin/${daemon} --set global.fork=true --load uci:///var/etc/${daemon}_dev
+}
+
+stop()
+{
+  service_stop /usr/sbin/${daemon}
+}
+
+reload()
+{
+  oonf_add_devices_to_configuration
+  oonf_reread_config
+}
diff --git a/oonf-dlep-proxy/files/dlep_proxy.uci b/oonf-dlep-proxy/files/dlep_proxy.uci
new file mode 100644 (file)
index 0000000..72a4d7d
--- /dev/null
@@ -0,0 +1,24 @@
+config global
+       option 'failfast'       'no'
+       option 'pidfile'        '/var/run/dlep_proxy.pid'
+       option 'lockfile'       '/var/lock/dlep_proxy'
+
+config log
+       option 'syslog'         'true'
+       option 'stderr'         'true'
+#      option 'file'           '/var/log/dlep_proxy.log'
+#      option 'info'           'all'
+#      option 'debug'          'all'
+
+config telnet
+#      option 'port' '2009'
+
+#config dlep_radio
+#  list 'name' 'eth0'
+#  option 'datapath_if' 'eth1'
+#  option 'not_proxied' 'false'
+#  option 'proxied' 'true'
+
+#config dlep-router
+#  list 'name' 'eth0'
+#  option 'datapath_if' 'eth0'
diff --git a/oonf-dlep-radio/Makefile b/oonf-dlep-radio/Makefile
new file mode 100644 (file)
index 0000000..4fb9124
--- /dev/null
@@ -0,0 +1,67 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=oonf-dlep-radio
+PKG_VERSION:=0.9.1-r1
+PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
+PKG_RELEASE:=$(PKG_REV)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://olsr.org/git/oonf.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+CMAKE_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_OPTIONS=-D OONF_NO_WERROR:Bool=true \
+              -D OONF_LOGGING_LEVEL:String=debug \
+              -D OONF_NO_TESTING:Bool=true \
+              -D UCI:Bool=true \
+              -D OONF_APP_DEFAULT_CFG_HANDLER:String=uci \
+              -D OONF_STATIC_PLUGINS:String="class;clock;interface;layer2;packet_socket;socket;stream_socket;telnet;timer;viewer;os_clock;os_socket;os_interface;os_system;nl80211_listener;layer2info;systeminfo;cfg_uciloader;cfg_compact;dlep_radio" \
+              -D OONF_LIB_GIT:String=v$(PKG_VERSION)-archive \
+              -D OONF_VERSION:String=$(PKG_VERSION) \
+              -D INSTALL_LIB_DIR:Path=lib/oonf \
+              -D INSTALL_INCLUDE_DIR:Path=include/oonf \
+              -D INSTALL_CMAKE_DIR:Path=lib/oonf \
+              -D CMAKE_PREFIX_PATH=$(STAGING_DIR)/usr
+
+define Package/oonf-git/template
+       SECTION:=net
+       CATEGORY:=Network
+       MAINTAINER:=Henning Rogge <hrogge@gmail.com>
+       SUBMENU:=OLSR.org network framework
+       URL:=http://www.olsr.org/
+endef
+
+define Package/oonf-dlep-radio
+       $(call Package/oonf-git/template) 
+       TITLE:= Build DLEP Radio Agent
+       DEPENDS:=+librt +libnl-tiny +libuci
+       VERSION:=$(PKG_VERSION)
+endef
+
+Build/Compile=$(call Build/Compile/Default,dlep_radio_static)
+Build/Install=
+
+define Build/Install
+       $(INSTALL_BIN) -D $(PKG_BUILD_DIR)/$(MAKE_PATH)/dlep_radio_static $(PKG_INSTALL_DIR)/usr/sbin/dlep_radio;
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -I${STAGING_DIR}/usr/include/libnl-tiny
+
+define Package/oonf-dlep-radio/install
+       $(INSTALL_BIN)  -D $(PKG_BUILD_DIR)/dlep_radio_static $(1)/usr/sbin/dlep_radio
+       $(INSTALL_BIN)  -D ./files/dlep_radio.init            $(1)/etc/init.d/dlep_radio
+       $(INSTALL_BIN)  -D ./files/dlep_radio.hotplug         $(1)/etc/hotplug.d/iface/50-dlep_radio
+       $(INSTALL_DATA) -D ./files/dlep_radio.uci             $(1)/etc/config/dlep_radio
+endef
+
+define Package/oonf-dlep-radio/conffiles
+/etc/config/dlep_radio
+endef
+
+$(eval $(call BuildPackage,oonf-dlep-radio))
diff --git a/oonf-dlep-radio/files/dlep_radio.hotplug b/oonf-dlep-radio/files/dlep_radio.hotplug
new file mode 100755 (executable)
index 0000000..87d1dbe
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+daemon=dlep_radio
+
+case "$ACTION" in
+       ifup)
+               . /etc/rc.common /etc/init.d/${daemon} enabled && {
+                       logger -t '${daemon}[hotplug]' -p daemon.info 'reloading configuration'
+                       . /etc/rc.common /etc/init.d/${daemon} reload
+               }
+       ;;
+esac
diff --git a/oonf-dlep-radio/files/dlep_radio.init b/oonf-dlep-radio/files/dlep_radio.init
new file mode 100755 (executable)
index 0000000..be22ed1
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/sh /etc/rc.common
+
+START=82
+
+daemon=dlep_radio
+
+. /usr/share/libubox/jshn.sh
+
+oonf_log()
+{
+  logger -s -t ${daemon} -p daemon.info "$1"
+}
+
+oonf_get_layer3_device()
+{
+  local interface="$1"  # e.g. 'mywifi'
+  local status dev proto
+  local query="{ \"interface\" : \"$interface\" }"
+
+  status="$( ubus -S call network.interface status "$query" )" && {
+    json_load "$status"
+    json_get_var 'dev' l3_device
+    json_get_var 'proto' proto
+    case "$proto" in
+      pppoe)
+        # TODO: otherwise it segfaults
+        oonf_log "refusing to add '$interface', because of proto '$proto'"
+      ;;
+      *)
+        echo "$dev" # e.g. 'wlan0-1'
+      ;;
+    esac
+  }
+}
+
+oonf_add_devices_to_configuration()
+{
+  local i=0
+  local device_name= section= interface= single_interface=
+
+  # make a copy of configuration and
+  # add a 'name' (physical name) for all
+  # 'interface-names' (e.g. mywifi)
+  #
+  # olsrd2.@interface[2]=interface
+  # olsrd2.@interface[2].ifname='wan lan wlanadhoc wlanadhocRADIO1'
+
+  # /var is in ramdisc/tmpfs
+  cp /etc/config/${daemon} /var/etc/${daemon}_dev
+
+  while section="$( uci -q -c /etc/config get "${daemon}.@[$i]" )"; do {
+    echo "section: $section"
+
+    interface="$( uci -q -c /etc/config get "${daemon}.@[$i].ifname" )" || {
+      i=$(( $i + 1 ))
+      continue
+    }
+
+    case "$( uci -q get "${daemon}.@[$i].ignore" )" in
+      1|on|true|enabled|yes)
+        oonf_log "removing/ignore section '$section'"
+        uci -q -c /var/etc delete "${daemon}_dev.@[$j]"
+        i=$(( $i + 1 ))
+
+        continue
+      ;;
+    esac
+
+    for single_interface in $interface; do {
+      device_name="$( oonf_get_layer3_device "$single_interface" )"
+
+      echo "Interface: $single_interface = $device_name"
+
+      if [ ! -z "$device_name" ]
+      then
+        # add option 'name' for 'ifname' (e.g. 'mywifi')
+        uci -q -c /var/etc add_list "${daemon}_dev.@[$i].name=$device_name"
+      fi
+    } done
+    i=$(( $i + 1 ))
+  } done
+
+  uci -q -c /var/etc commit ${daemon}_dev
+
+  oonf_log "wrote '/var/etc/${daemon}_dev'"
+}
+
+oonf_reread_config()
+{
+  local pid
+  local pidfile='/var/run/${daemon}.pid'
+
+  if   [ -e "$pidfile" ]; then
+    read pid <"$pidfile"
+  elif pidfile="$( uci -q get '${daemon}.@global[0].pidfile' )"; then
+    read pid <"$pidfile"
+  fi
+
+  # if empty, ask kernel
+  pid="${pid:-$( pidof ${daemon} )}"
+
+  [ -n "$pid" ] && kill -SIGHUP $pid
+}
+
+start()
+{
+  oonf_add_devices_to_configuration
+
+  # produce coredumps
+  ulimit -c unlimited
+
+  service_start /usr/sbin/${daemon} --set global.fork=true --load uci:///var/etc/${daemon}_dev
+}
+
+stop()
+{
+  service_stop /usr/sbin/${daemon}
+}
+
+reload()
+{
+  oonf_add_devices_to_configuration
+  oonf_reread_config
+}
diff --git a/oonf-dlep-radio/files/dlep_radio.uci b/oonf-dlep-radio/files/dlep_radio.uci
new file mode 100644 (file)
index 0000000..2f1ac9b
--- /dev/null
@@ -0,0 +1,24 @@
+config global
+       option 'failfast' 'no'
+       option 'pidfile'  '/var/run/dlep_radio.pid'
+       option 'lockfile' '/var/lock/dlep_radio'
+
+config log
+       option 'syslog'   'true'
+       option 'stderr'   'true'
+#      option 'file'             '/var/log/dlep_radio.log'
+#      option 'info'     'all'
+#      option 'debug'    'all'
+
+config telnet
+#      option 'port' '2009'
+
+config dlep_radio
+  list   'name'        'wlan0'
+  option 'datapath_if' 'br-lan'
+  option 'not_proxied' 'false'
+  option 'proxied'     'true'
+
+config nl80211_listener
+  option 'if'          'wlan0'
+  option 'interval'    '1.0'
diff --git a/oonf-olsrd2/Makefile b/oonf-olsrd2/Makefile
new file mode 100644 (file)
index 0000000..4651f94
--- /dev/null
@@ -0,0 +1,67 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=oonf-olsrd2
+PKG_VERSION:=0.9.1-r1
+PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
+PKG_RELEASE:=$(PKG_REV)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://olsr.org/git/oonf.git
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+
+CMAKE_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_OPTIONS=-D OONF_NO_WERROR:Bool=true \
+              -D OONF_LOGGING_LEVEL:String=debug \
+              -D OONF_NO_TESTING:Bool=true \
+              -D UCI:Bool=true \
+              -D OONF_APP_DEFAULT_CFG_HANDLER:String=uci \
+              -D OONF_STATIC_PLUGINS:String="class;clock;duplicate_set;interface;layer2;packet_socket;rfc5444;socket;stream_socket;telnet;timer;viewer;os_clock;os_socket;os_interface;os_routing;os_system;nhdp;olsrv2;ff_dat_metric;neighbor_probing;nl80211_listener;link_config;layer2info;systeminfo;cfg_uciloader;cfg_compact;nhdpinfo;olsrv2info;netjsoninfo" \
+              -D OONF_LIB_GIT:String=v$(PKG_VERSION)-archive \
+              -D OONF_VERSION:String=$(PKG_VERSION) \
+              -D INSTALL_LIB_DIR:Path=lib/oonf \
+              -D INSTALL_INCLUDE_DIR:Path=include/oonf \
+              -D INSTALL_CMAKE_DIR:Path=lib/oonf \
+              -D CMAKE_PREFIX_PATH=$(STAGING_DIR)/usr
+
+define Package/oonf-git/template
+       SECTION:=net
+       CATEGORY:=Network
+       MAINTAINER:=Henning Rogge <hrogge@gmail.com>
+       SUBMENU:=OLSR.org network framework
+       URL:=http://www.olsr.org/
+endef
+
+define Package/oonf-olsrd2
+       $(call Package/oonf-git/template) 
+       TITLE:= Build Olsrd V2 Routing Agent
+       DEPENDS:=+librt +libnl-tiny +libuci
+       VERSION:=$(PKG_VERSION)
+endef
+
+Build/Compile=$(call Build/Compile/Default,olsrd2_static)
+Build/Install=
+
+define Build/Install
+       $(INSTALL_BIN) -D $(PKG_BUILD_DIR)/$(MAKE_PATH)/olsrd2_static $(PKG_INSTALL_DIR)/usr/sbin/olsrd2;
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include -I${STAGING_DIR}/usr/include/libnl-tiny
+
+define Package/oonf-olsrd2/install
+       $(INSTALL_BIN)  -D $(PKG_BUILD_DIR)/olsrd2_static $(1)/usr/sbin/olsrd2
+       $(INSTALL_BIN)  -D ./files/olsrd2.init            $(1)/etc/init.d/olsrd2
+       $(INSTALL_BIN)  -D ./files/olsrd2.hotplug         $(1)/etc/hotplug.d/iface/50-olsrd2
+       $(INSTALL_DATA) -D ./files/olsrd2.uci             $(1)/etc/config/olsrd2
+endef
+
+define Package/oonf-olsrd2/conffiles
+/etc/config/olsrd2
+endef
+
+$(eval $(call BuildPackage,oonf-olsrd2))
diff --git a/oonf-olsrd2/files/olsrd2.hotplug b/oonf-olsrd2/files/olsrd2.hotplug
new file mode 100755 (executable)
index 0000000..a67de86
--- /dev/null
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+daemon=olsrd2
+
+case "$ACTION" in
+       ifup)
+               . /etc/rc.common /etc/init.d/${daemon} enabled && {
+                       logger -t '${daemon}[hotplug]' -p daemon.info 'reloading configuration'
+                       . /etc/rc.common /etc/init.d/${daemon} reload
+               }
+       ;;
+esac
diff --git a/oonf-olsrd2/files/olsrd2.init b/oonf-olsrd2/files/olsrd2.init
new file mode 100755 (executable)
index 0000000..3f3b667
--- /dev/null
@@ -0,0 +1,124 @@
+#!/bin/sh /etc/rc.common
+
+START=82
+
+daemon=olsrd2
+
+. /usr/share/libubox/jshn.sh
+
+oonf_log()
+{
+  logger -s -t ${daemon} -p daemon.info "$1"
+}
+
+oonf_get_layer3_device()
+{
+  local interface="$1"  # e.g. 'mywifi'
+  local status dev proto
+  local query="{ \"interface\" : \"$interface\" }"
+
+  status="$( ubus -S call network.interface status "$query" )" && {
+    json_load "$status"
+    json_get_var 'dev' l3_device
+    json_get_var 'proto' proto
+    case "$proto" in
+      pppoe)
+        # TODO: otherwise it segfaults
+        oonf_log "refusing to add '$interface', because of proto '$proto'"
+      ;;
+      *)
+        echo "$dev" # e.g. 'wlan0-1'
+      ;;
+    esac
+  }
+}
+
+oonf_add_devices_to_configuration()
+{
+  local i=0
+  local device_name= section= interface= single_interface=
+
+  # make a copy of configuration and
+  # add a 'name' (physical name) for all
+  # 'interface-names' (e.g. mywifi)
+  #
+  # olsrd2.@interface[2]=interface
+  # olsrd2.@interface[2].ifname='wan lan wlanadhoc wlanadhocRADIO1'
+
+  # /var is in ramdisc/tmpfs
+  cp /etc/config/${daemon} /var/etc/${daemon}_dev
+
+  while section="$( uci -q -c /etc/config get "${daemon}.@[$i]" )"; do {
+    echo "section: $section"
+
+    interface="$( uci -q -c /etc/config get "${daemon}.@[$i].ifname" )" || {
+      i=$(( $i + 1 ))
+      continue
+    }
+
+    case "$( uci -q get "${daemon}.@[$i].ignore" )" in
+      1|on|true|enabled|yes)
+        oonf_log "removing/ignore section '$section'"
+        uci -q -c /var/etc delete "${daemon}_dev.@[$j]"
+        i=$(( $i + 1 ))
+
+        continue
+      ;;
+    esac
+
+    for single_interface in $interface; do {
+      device_name="$( oonf_get_layer3_device "$single_interface" )"
+
+      echo "Interface: $single_interface = $device_name"
+
+      if [ ! -z "$device_name" ]
+      then
+        # add option 'name' for 'ifname' (e.g. 'mywifi')
+        uci -q -c /var/etc add_list "${daemon}_dev.@[$i].name=$device_name"
+      fi
+    } done
+    i=$(( $i + 1 ))
+  } done
+
+  uci -q -c /var/etc commit ${daemon}_dev
+
+  oonf_log "wrote '/var/etc/${daemon}_dev'"
+}
+
+oonf_reread_config()
+{
+  local pid
+  local pidfile='/var/run/${daemon}.pid'
+
+  if   [ -e "$pidfile" ]; then
+    read pid <"$pidfile"
+  elif pidfile="$( uci -q get '${daemon}.@global[0].pidfile' )"; then
+    read pid <"$pidfile"
+  fi
+
+  # if empty, ask kernel
+  pid="${pid:-$( pidof ${daemon} )}"
+
+  [ -n "$pid" ] && kill -SIGHUP $pid
+}
+
+start()
+{
+  oonf_add_devices_to_configuration
+
+  # produce coredumps
+  ulimit -c unlimited
+
+  service_start /usr/sbin/${daemon} --set global.fork=true --load uci:///var/etc/${daemon}_dev
+}
+
+stop()
+{
+  service_stop /usr/sbin/${daemon}
+}
+
+reload()
+{
+  oonf_add_devices_to_configuration
+  oonf_reread_config
+}
diff --git a/oonf-olsrd2/files/olsrd2.uci b/oonf-olsrd2/files/olsrd2.uci
new file mode 100644 (file)
index 0000000..9df4c7e
--- /dev/null
@@ -0,0 +1,40 @@
+config global
+       option 'failfast'       'no'
+       option 'pidfile'        '/var/run/olsrd2.pid'
+       option 'lockfile'       '/var/lock/olsrd2'
+
+config log
+       option 'syslog'         'true'
+       option 'stderr'         'true'
+#      option 'file'           '/var/log/olsrd2.log'
+#      option 'info'           'all'
+#      option 'debug'          'all'
+
+config telnet
+#      option 'port' '2009'
+
+config olsrv2
+# list 'lan' '::/0'
+# list 'lan' '0.0.0.0/0'
+
+config interface
+       option 'ifname' 'loopback'
+
+config interface
+       list 'ifname' 'WIFI'
+       list 'ifname' 'wlanadhoc'
+       list 'ifname' 'wlanadhocRADIO1'
+
+config interface
+       list 'ifname' 'wan'
+       option 'ignore' '1'
+#      option 'rx_bitrate' '100M'
+#      option 'tx_bitrate' '100M'
+#      option 'signal' '-20'
+
+config interface
+       list 'ifname' 'lan'
+       option 'ignore' '1'
+#      option 'rx_bitrate' '1G'
+#      option 'tx_bitrate' '1G'
+#      option 'signal' '-10'