From: Dirk Brenken Date: Wed, 26 Aug 2026 15:03:37 +0000 (+0200) Subject: shunt: init fixes X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=a353d906fec1f43ac86a0ba5b44b59b0a11a4b60;p=openwrt-packages.git shunt: init fixes - fixed crash loops as the shipped example policy is disabled - fixed restart/reload glitches with already stopped services - bumped version to 0.1.5-r2 Signed-off-by: Dirk Brenken Co-authored-by: Claude Signed-off-by: Dirk Brenken --- diff --git a/net/shunt/Makefile b/net/shunt/Makefile index c2862e7ab..caba5916f 100644 --- a/net/shunt/Makefile +++ b/net/shunt/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=shunt PKG_VERSION:=0.1.5 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_LICENSE:=GPL-3.0-or-later PKG_LICENSE_FILES:= PKG_MAINTAINER:=Dirk Brenken diff --git a/net/shunt/files/shunt.init b/net/shunt/files/shunt.init index b5fa29277..004257026 100644 --- a/net/shunt/files/shunt.init +++ b/net/shunt/files/shunt.init @@ -14,16 +14,23 @@ if [ -z "${IPKG_INSTROOT}" ]; then "stop") "${shunt_init}" running || exit 0 ;; + "restart" | "reload") + if ! "${shunt_init}" running; then + exec "${shunt_init}" start + fi + ;; esac fi start_service() { - procd_open_instance "shunt" - procd_set_param command /usr/sbin/shunt run - procd_set_param respawn 300 5 3 - procd_set_param stdout 0 - procd_set_param stderr 1 - procd_close_instance + if "${shunt_init}" enabled; then + procd_open_instance "shunt" + procd_set_param command /usr/sbin/shunt run + procd_set_param respawn 300 5 3 + procd_set_param stdout 0 + procd_set_param stderr 1 + procd_close_instance + fi } stop_service() { diff --git a/net/shunt/files/shunt.uc b/net/shunt/files/shunt.uc index 9444d0527..eb9466013 100755 --- a/net/shunt/files/shunt.uc +++ b/net/shunt/files/shunt.uc @@ -353,14 +353,15 @@ function run() { dbg = verbose || state.cfg.global.debug; if (!state.cfg.global.enabled) { - log('notice', 'disabled in config'); - return 0; + log('notice', 'disabled in config - running idle; enable and reload to start'); + state.cfg.policies = []; + state.matcher = match_compile([]); + state.nft = nft_compile([]); + state.route = route_compile([], state.nft.marks); } - if (!length(state.nft.marks)) { - log('err', 'no usable policy - not starting, run `shunt check` for the reasons'); - return 2; - } + if (!length(state.nft.marks)) + log('warn', 'no usable policy - running idle; configure a policy and reload, `shunt check` shows the reasons'); if (state.cfg.global.rp_filter_manage) rp_filter_apply(state.cfg.policies); @@ -526,7 +527,7 @@ function run() { let socks = []; - if (state.cfg.global.snoop) { + if (state.cfg.global.snoop && length(state.nft.marks)) { let socket = null; for (let dev in state.cfg.global.snoop_devices) {