dropbear: Add procd interface triggers when interface config is specified
authorJohn Crispin <john@openwrt.org>
Fri, 29 Apr 2016 11:35:15 +0000 (11:35 +0000)
committerJohn Crispin <john@openwrt.org>
Fri, 29 Apr 2016 11:35:15 +0000 (11:35 +0000)
A dropbear instance having an interface config won't start if the interface is down as no
IP address is available.
Adding interface triggers for each configured interface executing the dropbear reload script
will start the dropbear instance when the interface is up.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
SVN-Revision: 49272

package/network/services/dropbear/Makefile
package/network/services/dropbear/files/dropbear.init

index 39ab04bb54c734489e9c5c42bb7bce1fa0b971b9..f48c2b5b2cef65a7ff3eeac5fcbaeed2d8278f6a 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dropbear
 PKG_VERSION:=2015.71
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:= \
index 03745c995b23c691b6de8a3b82893fa1b339d483..5c3345d40c3dda9eca2ed690c911741b3623b35c 100755 (executable)
@@ -106,6 +106,12 @@ keygen()
        chmod 0700 /etc/dropbear
 }
 
+load_interfaces()
+{
+       config_get interface "$1" Interface
+       interfaces=" ${interface} ${interfaces}"
+}
+
 start_service()
 {
        [ -s /etc/dropbear/dropbear_rsa_host_key ] || keygen
@@ -119,7 +125,21 @@ start_service()
 
 service_triggers()
 {
-       procd_add_reload_trigger "dropbear"
+       local interfaces
+
+       procd_open_trigger
+       procd_add_config_trigger "config.change" "dropbear" /etc/init.d/dropbear reload
+
+       config_load "${NAME}"
+       config_foreach load_interfaces dropbear
+
+       [ -n "${interfaces}" ] & {
+               for n in $interfaces ; do
+                       procd_add_interface_trigger "interface.*" $n /etc/init.d/dropbear reload
+               done
+       }
+       procd_close_trigger
+
        procd_add_validation validate_section_dropbear
 }