summaryrefslogtreecommitdiff
path: root/package
diff options
context:
space:
mode:
authorJohn Crispin <john@openwrt.org>2014-06-04 07:19:51 +0000
committerJohn Crispin <john@openwrt.org>2014-06-04 07:19:51 +0000
commit39798dc43b55016312c9f88199915419861a1d2d (patch)
tree8e2a36b62730637f01170f054f4b7cddcc2b029d /package
parent21b0a8d8a4661261a2f468627186755682a5845f (diff)
downloadmtk-20170518-39798dc43b55016312c9f88199915419861a1d2d.zip
mtk-20170518-39798dc43b55016312c9f88199915419861a1d2d.tar.gz
mtk-20170518-39798dc43b55016312c9f88199915419861a1d2d.tar.bz2
igmpproxy: update init.d script to procd and add a hotplug script
Signed-off-by: John Crispin <blogic@openwrt.org> SVN-Revision: 40997
Diffstat (limited to 'package')
-rw-r--r--package/network/services/igmpproxy/Makefile2
-rw-r--r--package/network/services/igmpproxy/files/igmpproxy.hotplug3
-rw-r--r--package/network/services/igmpproxy/files/igmpproxy.init54
3 files changed, 40 insertions, 19 deletions
diff --git a/package/network/services/igmpproxy/Makefile b/package/network/services/igmpproxy/Makefile
index 47b995b..027fcb9 100644
--- a/package/network/services/igmpproxy/Makefile
+++ b/package/network/services/igmpproxy/Makefile
@@ -51,6 +51,8 @@ define Package/igmpproxy/install
$(INSTALL_CONF) ./files/igmpproxy.config $(1)/etc/config/igmpproxy
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/igmpproxy.init $(1)/etc/init.d/igmpproxy
+ $(INSTALL_DIR) $(1)/etc/hotplug.d/iface
+ $(INSTALL_BIN) ./files/igmpproxy.hotplug $(1)/etc/hotplug.d/iface/igmpproxy
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/igmpproxy $(1)/usr/sbin/
endef
diff --git a/package/network/services/igmpproxy/files/igmpproxy.hotplug b/package/network/services/igmpproxy/files/igmpproxy.hotplug
new file mode 100644
index 0000000..ebe353a
--- /dev/null
+++ b/package/network/services/igmpproxy/files/igmpproxy.hotplug
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+/etc/init.d/igmpproxy reload
diff --git a/package/network/services/igmpproxy/files/igmpproxy.init b/package/network/services/igmpproxy/files/igmpproxy.init
index a45978f..75d111f 100644
--- a/package/network/services/igmpproxy/files/igmpproxy.init
+++ b/package/network/services/igmpproxy/files/igmpproxy.init
@@ -1,11 +1,10 @@
#!/bin/sh /etc/rc.common
-# Copyright (C) 2010-2012 OpenWrt.org
+# Copyright (C) 2010-2014 OpenWrt.org
START=99
-STOP=10
-
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
+USE_PROCD=1
+PROG=/usr/sbin/igmpproxy
+CONFIGFILE=/var/etc/igmpproxy.conf
# igmpproxy supports both a debug mode and verbosity, which are very useful
# when something isn't working.
@@ -21,6 +20,7 @@ SERVICE_WRITE_PID=1
# OPTIONS="-v" - be verbose, this will write aditional information to syslog
OPTIONS=""
+UPSTREAM=0
igmp_header() {
local quickleave
@@ -34,30 +34,46 @@ igmp_header() {
}
igmp_add_phyint() {
- local network direction altnets
+ local network direction altnets device up
config_get network $1 network
config_get direction $1 direction
config_get altnets $1 altnet
- device=$(uci_get_state network "$network" ifname "$network")
- echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf
+ json_load "$(ifstatus $network)"
+ json_get_var device l3_device
+ json_get_var up up
+ [ -n "$device" -a "$up" = "1" ] || return;
+
+ UPSTREAM=1
+
+ echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf
+
+ if [ -n "$altnets" ]; then
+ local altnet
+ for altnet in $altnets; do
+ echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf
+ done
+ fi
+}
- if [ -n "$altnets" ]; then
- local altnet
- for altnet in $altnets; do
- echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf
- done
- fi
+service_triggers() {
+ procd_add_reload_trigger "igmpproxy"
}
-start() {
+start_service() {
config_load igmpproxy
+
config_foreach igmp_header igmpproxy
config_foreach igmp_add_phyint phyint
- service_start /usr/sbin/igmpproxy $OPTIONS /etc/igmpproxy.conf
-}
-stop() {
- service_stop /usr/sbin/igmpproxy
+ [ $UPSTREAM = 1 ] || return
+
+ procd_open_instance
+ procd_set_param command $PROG
+ [ -n "$OPTIONS" ] && procd_append_param $OPTIONS
+ procd_append_param command $CONFIGFILE
+ procd_set_param file $CONFIGFILE
+ procd_set_param respawn
+ procd_close_instance
}