Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion net/hev-socks5-tunnel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
26 changes: 26 additions & 0 deletions net/hev-socks5-tunnel/files/90-hev-socks5-tunnel
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion net/hev-socks5-tunnel/files/hev-socks5-tunnel.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
config hev-socks5-tunnel 'config'
config instance
option enabled '0'
option conffile '/etc/hev-socks5-tunnel/main.yml'
30 changes: 17 additions & 13 deletions net/hev-socks5-tunnel/files/hev-socks5-tunnel.init
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Loading