]> git.99rst.org Git - openwrt-packages.git/commitdiff
hev-socks5-tunnel: allow multiple instances
authorSergei S. <redacted>
Sun, 2 Aug 2026 15:56:02 +0000 (19:56 +0400)
committerAlexandru Ardelean <redacted>
Sun, 9 Aug 2026 08:43:20 +0000 (11:43 +0300)
Add support for running multiple service instances.
- switch UCI config from a single named section to "instance" sections
- update the procd init script to start multiple instances
- migrate existing single-instance configurations during package upgrade (uci-defaults script)
- bump PKG_RELEASE

Signed-off-by: Sergei S. <redacted>
net/hev-socks5-tunnel/Makefile
net/hev-socks5-tunnel/files/90-hev-socks5-tunnel [new file with mode: 0644]
net/hev-socks5-tunnel/files/hev-socks5-tunnel.config
net/hev-socks5-tunnel/files/hev-socks5-tunnel.init

index 7baf6d8e863688f4ed76e9b3544979cad0ef8f9a..4b22aeb48703bc6f1b4b61219c7275fc9d0804d9 100644 (file)
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=hev-socks5-tunnel
 PKG_VERSION:=2.17.0
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=https://github.com/heiher/hev-socks5-tunnel/releases/download/$(PKG_VERSION)
@@ -48,6 +48,9 @@ define Package/hev-socks5-tunnel/install
 
        $(INSTALL_DIR) $(1)/etc/init.d/
        $(INSTALL_BIN) ./files/hev-socks5-tunnel.init $(1)/etc/init.d/hev-socks5-tunnel
+
+       $(INSTALL_DIR) $(1)/etc/uci-defaults
+       $(INSTALL_BIN) ./files/90-hev-socks5-tunnel $(1)/etc/uci-defaults/90-hev-socks5-tunnel
 endef
 
 $(eval $(call BuildPackage,hev-socks5-tunnel))
diff --git a/net/hev-socks5-tunnel/files/90-hev-socks5-tunnel b/net/hev-socks5-tunnel/files/90-hev-socks5-tunnel
new file mode 100644 (file)
index 0000000..76be9ed
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+# Upgrade single-instance configuration to multi-instance format.
+
+if [ -f /etc/config/hev-socks5-tunnel ] && \
+       ! uci -q get hev-socks5-tunnel.@instance[0] >/dev/null 2>&1 && \
+       uci -q get hev-socks5-tunnel.config >/dev/null 2>&1
+then
+       printf "Upgrading hev-socks5-tunnel configuration... "
+       conf_enabled="$(uci -q get hev-socks5-tunnel.config.enabled)"
+       conf_conffile="$(uci -q get hev-socks5-tunnel.config.conffile)"
+
+       if ! uci -q batch <<-EOF
+               delete hev-socks5-tunnel.config
+               add hev-socks5-tunnel instance
+               set hev-socks5-tunnel.@instance[-1].enabled='${conf_enabled:-0}'
+               set hev-socks5-tunnel.@instance[-1].conffile='${conf_conffile:-/etc/hev-socks5-tunnel/main.yml}'
+               commit hev-socks5-tunnel
+       EOF
+       then
+               printf "failed.\n"
+               exit 1
+       fi
+       printf "done.\n"
+fi
+
+exit 0
index fd6de1b284d0abea30d6d84f5975d48f413537b7..2c47ecf85842ff0351f40579e0af0d481286b79b 100644 (file)
@@ -1,3 +1,3 @@
-config hev-socks5-tunnel 'config'
+config instance
        option enabled '0'
        option conffile '/etc/hev-socks5-tunnel/main.yml'
index 7cd524c8a40643468a5e93b75e1827d669d7f213..70939345ff90162fc7135d472691ced69ce24117 100644 (file)
@@ -6,29 +6,33 @@ START=99
 CONF="hev-socks5-tunnel"
 PROG="/usr/bin/hev-socks5-tunnel"
 
-start_service() {
-       config_load "$CONF"
-
-       local enabled
-       config_get_bool enabled "config" "enabled" "0"
-       [ "$enabled" -eq "1" ] || return 1
-
-       local conffile
-       config_get conffile "config" "conffile"
-
-       procd_open_instance "$CONF"
+start_instance() {
+       local enabled conffile
+       config_get_bool enabled "$1" enabled 0
+       [ "$enabled" -eq 1 ] || return 0
+       config_get conffile "$1" conffile
+
+       if [ ! -f "$conffile" ]; then
+               logger -t "$CONF" -p daemon.err "instance '$1' not started, conffile not found: '$conffile'"
+               return 1
+       fi
+
+       procd_open_instance "$1"
        procd_set_param command "$PROG" "$conffile"
        procd_set_param file "$conffile"
-
        procd_set_param limits core="unlimited"
        procd_set_param limits nofile="1000000 1000000"
        procd_set_param stdout 1
        procd_set_param stderr 1
        procd_set_param respawn
-
        procd_close_instance
 }
 
+start_service() {
+       config_load "$CONF"
+       config_foreach start_instance instance
+}
+
 service_triggers() {
        procd_add_reload_trigger "$CONF"
 }
git clone https://git.99rst.org/PROJECT