Unified openwrt init files for OONF 122/head
authorHenning Rogge <hrogge@gmail.com>
Thu, 6 Aug 2015 19:43:33 +0000 (21:43 +0200)
committerHenning Rogge <hrogge@gmail.com>
Thu, 6 Aug 2015 19:43:33 +0000 (21:43 +0200)
12 files changed:
oonf-dlep-proxy/Makefile
oonf-dlep-proxy/files/dlep_proxy.hotplug
oonf-dlep-proxy/files/dlep_proxy.init
oonf-dlep-radio/Makefile
oonf-dlep-radio/files/dlep_radio.hotplug
oonf-dlep-radio/files/dlep_radio.init
oonf-init-scripts/Makefile [new file with mode: 0644]
oonf-init-scripts/files/oonf_hotplug.sh [new file with mode: 0755]
oonf-init-scripts/files/oonf_init.sh [new file with mode: 0755]
oonf-olsrd2/Makefile
oonf-olsrd2/files/olsrd2.hotplug
oonf-olsrd2/files/olsrd2.init

index 9a6cd2fa53f2ba41ee24169ef080dfc1a7b174f1..3f02c5dd6aa66bae017da855c5bd445fdbfc92f0 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=oonf-dlep-proxy
-PKG_VERSION:=0.9.1-r1
+PKG_VERSION:=0.9.1-r2
 PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
 PKG_RELEASE:=$(PKG_REV)
 
@@ -40,7 +40,7 @@ endef
 define Package/oonf-dlep-proxy
        $(call Package/oonf-git/template) 
        TITLE:= Build DLEP Radio+Router Agent
-       DEPENDS:=+librt +libnl-tiny +libuci
+       DEPENDS:=+librt +libnl-tiny +libuci +oonf-init-scripts
        VERSION:=$(PKG_VERSION)
 endef
 
index e42e646715edbafce958641908e056282846e383..3ebe1b7d1be5aec5c84fefae299f17d5be16aca9 100755 (executable)
@@ -1,12 +1,5 @@
 #!/bin/sh
 
-daemon=dlep_proxy
+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
+. /lib/functions/oonf_hotplug.sh
index fddbf0176612fbbcf83609c11d9ccc1dc6aaf83e..c47ff84000a850962312c748cf8eed163e95441e 100755 (executable)
@@ -1,124 +1,6 @@
 #!/bin/sh /etc/rc.common
 
 START=82
+DAEMON='dlep_proxy'
 
-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
-}
+. /lib/functions/oonf_init.sh
index 4fb91242c54baafac53df9e78fa46fc01a03adfb..f0db64fd8e980221b416b43085943fe0d194be18 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=oonf-dlep-radio
-PKG_VERSION:=0.9.1-r1
+PKG_VERSION:=0.9.1-r2
 PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
 PKG_RELEASE:=$(PKG_REV)
 
@@ -40,7 +40,7 @@ endef
 define Package/oonf-dlep-radio
        $(call Package/oonf-git/template) 
        TITLE:= Build DLEP Radio Agent
-       DEPENDS:=+librt +libnl-tiny +libuci
+       DEPENDS:=+librt +libnl-tiny +libuci +oonf-init-scripts
        VERSION:=$(PKG_VERSION)
 endef
 
index 87d1dbee07ee546478f187f198fbd0d3d125d698..b7146a4f9429438a4b58cd0ab7ca4ccf1db075c1 100755 (executable)
@@ -1,12 +1,5 @@
 #!/bin/sh
 
-daemon=dlep_radio
+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
+. /lib/functions/oonf_hotplug.sh
index be22ed1f684831113d0aeede2b39acec96e48256..c660a216b4873e961359b2d5e2ce75919537507f 100755 (executable)
@@ -1,124 +1,6 @@
 #!/bin/sh /etc/rc.common
 
 START=82
+DAEMON='dlep_radio'
 
-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
-}
+. /lib/functions/oonf_init.sh
diff --git a/oonf-init-scripts/Makefile b/oonf-init-scripts/Makefile
new file mode 100644 (file)
index 0000000..fd1aa06
--- /dev/null
@@ -0,0 +1,36 @@
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=oonf-init-scripts
+PKG_VERSION:=0.9.1-r2
+PKG_RELEASE:=1
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/oonf-init-scripts
+       SECTION:=net
+       CATEGORY:=Network
+       MAINTAINER:=Henning Rogge <hrogge@gmail.com>
+       SUBMENU:=OLSR.org network framework
+       URL:=http://www.olsr.org/
+       TITLE:= Common OONF startup scripts
+       VERSION:=$(PKG_VERSION)
+endef
+
+define Build/Prepare
+       mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Configure
+endef
+
+define Build/Compile
+endef
+
+define Package/oonf-init-scripts/install
+       $(INSTALL_BIN)  -D ./files/oonf_init.sh            $(1)/lib/functions/oonf_init.sh
+       $(INSTALL_BIN)  -D ./files/oonf_hotplug.sh         $(1)/lib/functions/oonf_hotplug.sh
+endef
+
+$(eval $(call BuildPackage,oonf-init-scripts))
diff --git a/oonf-init-scripts/files/oonf_hotplug.sh b/oonf-init-scripts/files/oonf_hotplug.sh
new file mode 100755 (executable)
index 0000000..b230b94
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+
+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-init-scripts/files/oonf_init.sh b/oonf-init-scripts/files/oonf_init.sh
new file mode 100755 (executable)
index 0000000..1c7b414
--- /dev/null
@@ -0,0 +1,120 @@
+#!/bin/sh
+
+. /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
+  uci export ${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
+}
index 4651f94292273055aec68a885c505adc8fd5976a..9c23ac7ab4c2557b5b30516d77a2c7f0fd8421d8 100644 (file)
@@ -1,7 +1,7 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=oonf-olsrd2
-PKG_VERSION:=0.9.1-r1
+PKG_VERSION:=0.9.1-r2
 PKG_REV:=eab3845089bc2410a3c115fb8274572b16a0e47d
 PKG_RELEASE:=$(PKG_REV)
 
@@ -40,7 +40,7 @@ endef
 define Package/oonf-olsrd2
        $(call Package/oonf-git/template) 
        TITLE:= Build Olsrd V2 Routing Agent
-       DEPENDS:=+librt +libnl-tiny +libuci
+       DEPENDS:=+librt +libnl-tiny +libuci +oonf-init-scripts
        VERSION:=$(PKG_VERSION)
 endef
 
index a67de86b0e96c90b36545c0122d2c06618e45d06..3a277cebba51f3ef377b1b2ea61954115935962f 100755 (executable)
@@ -1,12 +1,5 @@
 #!/bin/sh
 
-daemon=olsrd2
+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
+. /lib/functions/oonf_hotplug.sh
index 3f3b667acb2256633e8a510b557b6a2720547244..debae9883258b821a5ea0aecebe879ddc84e29eb 100755 (executable)
@@ -1,124 +1,6 @@
 #!/bin/sh /etc/rc.common
 
 START=82
+DAEMON='olsrd2'
 
-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
-}
+. /lib/functions/oonf_init.sh