Add config file and use procd.

Signed-off-by: Álvaro Fernández Rojas <nolt...@gmail.com>
---
diff --git a/net/udpxy/Makefile b/net/udpxy/Makefile
index f9ac4fc..97a5618 100644
--- a/net/udpxy/Makefile
+++ b/net/udpxy/Makefile
@@ -11,7 +11,7 @@ PKG_NAME:=udpxy
 PKG_REV:=1.0.23
 PKG_TAG:=9
 PKG_VERSION:=$(PKG_REV)-$(PKG_TAG)
-PKG_RELEASE:=2
+PKG_RELEASE:=3
 
 PKG_SOURCE:=$(PKG_NAME).$(PKG_REV)-$(patsubst %,%-prod,$(PKG_TAG)).tar.gz
 PKG_SOURCE_URL:=http://www.udpxy.com/download/1_23
@@ -24,18 +24,22 @@ include $(INCLUDE_DIR)/package.mk
 define Package/udpxy
   SECTION:=net
   CATEGORY:=Network
-  TITLE:=convert UDP IPTV streams into http stream
+  TITLE:=Convert UDP IPTV streams into HTTP streams
   URL:=http://www.udpxy.com/index-en.html
 endef
 
 define Package/udpxy/description
-       udproxy makes it possible to convert UDP IPTV streams into http
-       streams which can be viewed even over wlans. http streams do
+       udproxy makes it possible to convert UDP IPTV streams into HTTP
+       streams which can be viewed even over WLANs. HTTP streams do
        not generate huge amounts of multicast traffic, so a sd stream
-       only takes about 300k. interesting for peoply who have IPTV at
+       only takes about 300k. Interesting for peoply who have IPTV at
        home and do not want to rent multiple decoders from their
-       provider but just use their own streaming client for example
-       popcornhour/mediatomb/vlc/etc.
+       provider but just use their own streaming client (for example
+       popcornhour/mediatomb/vlc).
+endef
+
+define Package/udpxy/conffiles
+/etc/config/udpxy
 endef
 
 MAKE_FLAGS += \
@@ -43,7 +47,8 @@ MAKE_FLAGS += \
        ALL_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)"
 
 define Package/udpxy/install
-       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/etc/init.d $(1)/etc/config
+       $(INSTALL_CONF) ./files/udpxy.conf $(1)/etc/config/udpxy
        $(INSTALL_BIN) ./files/udpxy.init $(1)/etc/init.d/udpxy
        $(INSTALL_DIR) $(1)/usr/bin
        $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/udpxy $(1)/usr/bin/
diff --git a/net/udpxy/files/udpxy.conf b/net/udpxy/files/udpxy.conf
new file mode 100644
index 0000000..5ef2e27
--- /dev/null
+++ b/net/udpxy/files/udpxy.conf
@@ -0,0 +1,13 @@
+config udpxy
+       option verbose '0'
+       option status '1'
+       option bind '0.0.0.0'
+       option port '4022'
+       option source '0.0.0.0'
+       option max_clients '3'
+       option log_file '/var/log/udpxy'
+       option buffer_size '2048'
+       option buffer_messages '1'
+       option buffer_time '1'
+       option nice_increment '0'
+       option mcsub_renew '0'
diff --git a/net/udpxy/files/udpxy.init b/net/udpxy/files/udpxy.init
index 41d7481..183a200 100644
--- a/net/udpxy/files/udpxy.init
+++ b/net/udpxy/files/udpxy.init
@@ -1,27 +1,61 @@
 #!/bin/sh /etc/rc.common
+# Copyright (C) 2006-2014 OpenWrt.org
 
-# To open multicast traffic, add the following rule at the end of
-# /etc/config/firewall file:
-#
-# config 'rule'
-#     option 'target' 'ACCEPT'
-#     option '_name' 'multicast'
-#     option 'src' 'wan'
-#     option 'proto' 'all'
-#     option 'dest_ip' '224.0.0.0/4'
+START=50
+USE_PROCD=1
 
-START=99
-STOP=10
+udpxy_parse() {
+       local cfg="$1"
 
-SERVICE_DAEMONIZE=1
-SERVICE_WRITE_PID=1
+       local cfg_verbose
+       local cfg_status
+       local cfg_mcsub_renew
+       local cfg_bind
+       local cfg_port
+       local cfg_source
+       local cfg_max_clients
+       local cfg_log_file
+       local cfg_buffer_size
+       local cfg_buffer_messages
+       local cfg_buffer_time
+       local cfg_nice_increment
+       local cfg_mcsub_renew
 
-OPTIONS="-T -S -p 4022"
+       config_get_bool cfg_verbose $cfg 'verbose' 0
+       config_get_bool cfg_status $cfg 'status' 1
+       config_get cfg_bind $cfg 'bind' '0.0.0.0'
+       config_get cfg_port $cfg 'port' '4022'
+       config_get cfg_source $cfg 'source' '0.0.0.0'
+       config_get cfg_max_clients $cfg 'max_clients' '3'
+       config_get cfg_log_file $cfg 'log_file' '/var/log/udpxy'
+       config_get cfg_buffer_size $cfg 'buffer_size' '2048'
+       config_get cfg_buffer_messages $cfg 'buffer_messages' '1'
+       config_get cfg_buffer_time $cfg 'buffer_time' '1'
+       config_get cfg_nice_increment $cfg 'nice_increment' '0'
+       config_get cfg_mcsub_renew $cfg 'mcsub_renew' 0
 
-start() {
-       service_start /usr/bin/udpxy $OPTIONS
+       procd_open_instance
+
+       procd_set_param command /usr/bin/udpxy
+       procd_append_param command -T
+       [ "$cfg_verbose" -eq 1 ] && procd_append_param command -v
+       [ "$cfg_status" -eq 1 ] && procd_append_param command -S
+       procd_append_param command -a $cfg_bind
+       procd_append_param command -p $cfg_port
+       procd_append_param command -m $cfg_source
+       procd_append_param command -c $cfg_max_clients
+       procd_append_param command -l $cfg_log_file
+       [ "$cfg_nice_increment" -ge 4096 ] && procd_append_param command -B 
$cfg_buffer_size
+       procd_append_param command -R $cfg_buffer_messages
+       procd_append_param command -H $cfg_buffer_time
+       [ "$cfg_nice_increment" -ne 0 ] && procd_append_param command -n 
$cfg_nice_increment
+       procd_append_param command -M $cfg_mcsub_renew
+
+       procd_set_param respawn
+       procd_close_instance
 }
 
-stop() {
-       service_stop /usr/bin/udpxy
+start_service() {
+       config_load udpxy
+       config_foreach udpxy_parse udpxy
 }
_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel

Reply via email to