Changeset 40997


Ignore:
Timestamp:
2014-06-04T09:19:51+02:00 (4 years ago)
Author:
blogic
Message:

igmpproxy: update init.d script to procd and add a hotplug script

Signed-off-by: John Crispin <blogic@…>

Location:
trunk/package/network/services/igmpproxy
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/package/network/services/igmpproxy/Makefile

    r40730 r40997  
    5252        $(INSTALL_DIR) $(1)/etc/init.d 
    5353        $(INSTALL_BIN) ./files/igmpproxy.init $(1)/etc/init.d/igmpproxy 
     54        $(INSTALL_DIR) $(1)/etc/hotplug.d/iface 
     55        $(INSTALL_BIN) ./files/igmpproxy.hotplug $(1)/etc/hotplug.d/iface/igmpproxy 
    5456        $(INSTALL_DIR) $(1)/usr/sbin 
    5557        $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/igmpproxy $(1)/usr/sbin/ 
  • trunk/package/network/services/igmpproxy/files/igmpproxy.init

    r31333 r40997  
    11#!/bin/sh /etc/rc.common 
    2 # Copyright (C) 2010-2012 OpenWrt.org 
     2# Copyright (C) 2010-2014 OpenWrt.org 
    33 
    44START=99 
    5 STOP=10 
    6  
    7 SERVICE_DAEMONIZE=1 
    8 SERVICE_WRITE_PID=1 
     5USE_PROCD=1 
     6PROG=/usr/sbin/igmpproxy 
     7CONFIGFILE=/var/etc/igmpproxy.conf 
    98 
    109# igmpproxy supports both a debug mode and verbosity, which are very useful 
     
    2221 
    2322OPTIONS="" 
     23UPSTREAM=0 
    2424 
    2525igmp_header() { 
     
    3535 
    3636igmp_add_phyint() { 
    37         local network direction altnets 
     37        local network direction altnets device up 
    3838 
    3939        config_get network $1 network 
     
    4141        config_get altnets $1 altnet 
    4242 
    43         device=$(uci_get_state network "$network" ifname "$network") 
    44         echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf 
     43        json_load "$(ifstatus $network)" 
     44        json_get_var device l3_device 
     45        json_get_var up up 
     46        [ -n "$device" -a "$up" = "1" ] || return; 
    4547 
    46         if [ -n "$altnets" ]; then 
    47                 local altnet 
    48                 for altnet in $altnets; do 
    49                         echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf 
    50                 done 
    51         fi 
     48        UPSTREAM=1 
     49 
     50        echo -e "\nphyint $device $direction ratelimit 0 threshold 1" >> /var/etc/igmpproxy.conf 
     51 
     52        if [ -n "$altnets" ]; then 
     53                local altnet 
     54                for altnet in $altnets; do 
     55                        echo -e "\taltnet $altnet" >> /var/etc/igmpproxy.conf 
     56                done 
     57        fi 
    5258} 
    5359 
    54 start() { 
     60service_triggers() { 
     61        procd_add_reload_trigger "igmpproxy" 
     62} 
     63 
     64start_service() { 
    5565        config_load igmpproxy 
     66 
    5667        config_foreach igmp_header igmpproxy 
    5768        config_foreach igmp_add_phyint phyint 
    58         service_start /usr/sbin/igmpproxy $OPTIONS /etc/igmpproxy.conf 
     69 
     70        [ $UPSTREAM = 1 ] || return 
     71 
     72        procd_open_instance 
     73        procd_set_param command $PROG 
     74        [ -n "$OPTIONS" ] && procd_append_param $OPTIONS 
     75        procd_append_param command $CONFIGFILE 
     76        procd_set_param file $CONFIGFILE 
     77        procd_set_param respawn 
     78        procd_close_instance 
    5979} 
    60  
    61 stop() { 
    62         service_stop /usr/sbin/igmpproxy 
    63 } 
Note: See TracChangeset for help on using the changeset viewer.