diff options
author | Felix Fietkau <nbd@openwrt.org> | 2015-12-04 17:44:00 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2015-12-04 17:44:00 +0000 |
commit | 754b8de44d9866ab4c6ffbf42ebcd564ece94a66 (patch) | |
tree | 58bf2c5d67d1788b4d289031912f9ff69a412012 /package/network | |
parent | 93b848d14fa1cbc18332c6d2f485b1c1ea7ac96d (diff) | |
download | master-187ad058-754b8de44d9866ab4c6ffbf42ebcd564ece94a66.tar.gz master-187ad058-754b8de44d9866ab4c6ffbf42ebcd564ece94a66.tar.bz2 master-187ad058-754b8de44d9866ab4c6ffbf42ebcd564ece94a66.zip |
br2684ctl: convert init script to procd, add hotplug/reload support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/trunk@47765 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/network')
-rw-r--r-- | package/network/utils/linux-atm/Makefile | 3 | ||||
-rw-r--r-- | package/network/utils/linux-atm/files/atm.hotplug | 1 | ||||
-rwxr-xr-x | package/network/utils/linux-atm/files/br2684ctl | 65 |
3 files changed, 34 insertions, 35 deletions
diff --git a/package/network/utils/linux-atm/Makefile b/package/network/utils/linux-atm/Makefile index d9402c3c16..51e604c0bb 100644 --- a/package/network/utils/linux-atm/Makefile +++ b/package/network/utils/linux-atm/Makefile @@ -178,8 +178,9 @@ define Package/atm-diagnostics/install endef define Package/br2684ctl/install - $(INSTALL_DIR) $(1)/etc/init.d/ + $(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/hotplug.d/atm $(INSTALL_BIN) ./files/br2684ctl $(1)/etc/init.d/ + $(INSTALL_DATA) ./files/atm.hotplug $(1)/etc/hotplug.d/atm/00-trigger $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/br2684ctl $(1)/usr/sbin/ endef diff --git a/package/network/utils/linux-atm/files/atm.hotplug b/package/network/utils/linux-atm/files/atm.hotplug new file mode 100644 index 0000000000..68fb96d3ac --- /dev/null +++ b/package/network/utils/linux-atm/files/atm.hotplug @@ -0,0 +1 @@ +ubus call service event '{ "type": "hotplug.atm", "data": { "name": "'"$DEVICENAME"'" } }' diff --git a/package/network/utils/linux-atm/files/br2684ctl b/package/network/utils/linux-atm/files/br2684ctl index 30b1a44e27..ad45a553d0 100755 --- a/package/network/utils/linux-atm/files/br2684ctl +++ b/package/network/utils/linux-atm/files/br2684ctl @@ -1,13 +1,9 @@ #!/bin/sh /etc/rc.common START=50 - -SERVICE_DAEMONIZE=1 -SERVICE_WRITE_PID=1 +USE_PROCD=1 start_daemon() { - . /lib/functions/network.sh - local cfg="$1" local atmdev @@ -44,46 +40,47 @@ start_daemon() { local sendsize config_get sendsize "$cfg" sendsize - local circuit="$atmdev.$vpi.$vci" + found= + for device in /sys/class/atm/*; do + [ -d "$device" ] || break + [ "$(cat $device/atmindex)" = "$atmdev" ] || continue + found=1 + break + done - network_defer_device "nas$unit" + [ -n "$found" ] || return - SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \ - service_start /usr/sbin/br2684ctl \ + local circuit="$atmdev.$vpi.$vci" + + procd_open_instance + procd_set_param command \ + /usr/sbin/br2684ctl \ -c "$unit" -e "$encaps" -p "$payload" \ -a "$circuit" ${qos:+-q "$qos"} ${sendsize:+-s "$sendsize"} - sleep 1 - - network_ready_device "nas$unit" + procd_close_instance } -stop_daemon() { - local cfg="$1" - - local atmdev - config_get atmdev "$cfg" atmdev 0 - - local unit - config_get unit "$cfg" unit 0 +service_running() { + . /lib/functions/network.sh - local vpi - config_get vpi "$cfg" vpi 8 + sleep 1 + for path in /sys/class/net/nas*; do + dev="${path##*/}" + network_ready_device "$dev" + done +} - local vci - config_get vci "$cfg" vci 35 +service_triggers() { + local script=$(readlink "$initscript") + local name=$(basename ${script:-$initscript}) - local circuit="$atmdev.$vpi.$vci" - - SERVICE_PID_FILE="/var/run/br2684ctl-$circuit.pid" \ - service_stop /usr/sbin/br2684ctl + procd_open_trigger + procd_add_raw_trigger hotplug.atm 2000 /etc/init.d/$name reload + procd_add_config_trigger "config.change" "$file" /etc/init.d/$name reload + procd_close_trigger } -start() { +start_service() { config_load network config_foreach start_daemon atm-bridge } - -stop() { - config_load network - config_foreach stop_daemon atm-bridge -} |