From b2637476d40bf759dc2d70c5180acadd60f83c94 Mon Sep 17 00:00:00 2001 From: Nicolas Thill Date: Thu, 17 Nov 2011 10:47:26 +0000 Subject: [PATCH] packages/frickin: use uci config SVN-Revision: 29216 --- net/frickin/Makefile | 14 ++++----- net/frickin/files/frickin.config | 13 ++++++++ net/frickin/files/frickin.default | 16 ---------- net/frickin/files/frickin.init | 52 ++++++++++++++++++++++++++++--- 4 files changed, 68 insertions(+), 27 deletions(-) create mode 100644 net/frickin/files/frickin.config delete mode 100644 net/frickin/files/frickin.default diff --git a/net/frickin/Makefile b/net/frickin/Makefile index 6675953abe..c934cdf163 100644 --- a/net/frickin/Makefile +++ b/net/frickin/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=frickin PKG_VERSION:=1.3 -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz PKG_SOURCE_URL:=@SF/frickin @@ -31,10 +31,6 @@ define Package/frickin/description Translation (NAT). endef -define Package/frickin/conffiles -/etc/default/frickin -endef - define Build/Configure $(MAKE) -C $(PKG_BUILD_DIR) \ $(TARGET_CONFIGURE_OPTS) \ @@ -43,12 +39,16 @@ define Build/Configure endef define Package/frickin/install - $(INSTALL_DIR) $(1)/etc/default - $(INSTALL_DATA) ./files/frickin.default $(1)/etc/default/frickin + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/frickin.config $(1)/etc/config/frickin $(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_BIN) ./files/frickin.init $(1)/etc/init.d/frickin $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/frickin $(1)/usr/sbin/ endef +define Package/frickin/conffiles +/etc/config/frickin +endef + $(eval $(call BuildPackage,frickin)) diff --git a/net/frickin/files/frickin.config b/net/frickin/files/frickin.config new file mode 100644 index 0000000000..32141cde95 --- /dev/null +++ b/net/frickin/files/frickin.config @@ -0,0 +1,13 @@ +package 'frickin' + +config 'frickin' + option enabled 0 + + # listen on the specified IP address + option listen_ip '192.168.1.1' + + # connect to the specified IP address + option server_ip '192.168.1.253' + + # set the maximum number of simultaneous connections +# option conn_limit 20 diff --git a/net/frickin/files/frickin.default b/net/frickin/files/frickin.default deleted file mode 100644 index 9f55d5bad2..0000000000 --- a/net/frickin/files/frickin.default +++ /dev/null @@ -1,16 +0,0 @@ -# ip address of the server the proxy should connect to -TARGET_IP=192.168.1.2 - -# ip address the proxy should listen to for incoming connections -#LISTEN_IP=192.168.1.1 - -# maximum number of simultaneous connections -#PROXY_CONN_MAX=20 - -# user the proxy should run as -#PROXY_USER=root - -[ -n "$TARGET_IP" ] && OPTIONS="$OPTIONS -s $TARGET_IP" -[ -n "$LISTEN_IP" ] && OPTIONS="$OPTIONS -l $LISTEN_IP" -[ -n "$PROXY_CONN_MAX" ] && OPTIONS="$OPTIONS -c $PROXY_CONN_MAX" -[ -n "$PROXY_USER" ] && OPTIONS="$OPTIONS -u $PROXY_USER" diff --git a/net/frickin/files/frickin.init b/net/frickin/files/frickin.init index 3e90470ff3..c002513cab 100644 --- a/net/frickin/files/frickin.init +++ b/net/frickin/files/frickin.init @@ -6,13 +6,57 @@ START=50 SERVICE_DAEMONIZE=1 SERVICE_WRITE_PID=1 -DEFAULT=/etc/default/frickin +append_string() { + local var="$1" + local section="$2" + local option="$3" + local val="$4" + local _val + config_get _val "$section" "$option" + [ -n "$_val" ] && append "$var" "$val $_val" +} + +section_enabled() { + local enabled + config_get_bool enabled "$1" 'enabled' 0 + [ $enabled -gt 0 ] +} + +start_instance() { + local section="$1" + local args + + section_enabled "$section" || return 1 + + append_string args "$section" 'listen_ip' '-l' + append_string args "$section" 'server_ip' '-s' + append_string args "$section" 'conn_limit' '-c' + + SERVICE_PID_FILE="/var/run/frickin-${section}.pid" + service_start /usr/sbin/frickin $args +} + +stop_instance() { + local section="$1" + local id + local if + + section_enabled "$section" || return 1 + + SERVICE_PID_FILE="/var/run/frickin-${section}.pid" + service_stop /usr/sbin/frickin +} start() { - [ -f $DEFAULT ] && . $DEFAULT - service_start /usr/sbin/frickin $OPTIONS + include /lib/network + scan_interfaces + config_load 'frickin' + config_foreach start_instance 'frickin' } stop() { - service_stop /usr/sbin/frickin + include /lib/network + scan_interfaces + config_load 'frickin' + config_foreach stop_instance 'frickin' } -- 2.30.2