From 8de37eb6c91fa548ef2c0c463f9d626ed05a9949 Mon Sep 17 00:00:00 2001 From: RadekSabacky Date: Wed, 19 Nov 2025 13:43:24 +0100 Subject: [PATCH] / move ensure_jq where needed --- .../nym-node-setup/network-tunnel-manager.sh | 47 ++++++++++--------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/scripts/nym-node-setup/network-tunnel-manager.sh b/scripts/nym-node-setup/network-tunnel-manager.sh index 8413af1742..799ee4f6d2 100644 --- a/scripts/nym-node-setup/network-tunnel-manager.sh +++ b/scripts/nym-node-setup/network-tunnel-manager.sh @@ -12,24 +12,6 @@ if [ "$(id -u)" -ne 0 ]; then exit 1 fi -echo "checking for jq..." - -if command -v jq >/dev/null 2>&1; then - echo -e "${GREEN}jq is already installed${NC}" - # continue script execution -else - echo -e "${YELLOW}jq not found, installing...${NC}" - apt-get update -y - DEBIAN_FRONTEND=noninteractive apt-get install -y jq - - if command -v jq >/dev/null 2>&1; then - echo -e "${GREEN}jq installed successfully${NC}" - else - echo -e "${RED}failed to install jq${NC}" - exit 1 - fi -fi - ############################################################################### # basic config ############################################################################### @@ -51,7 +33,6 @@ detect_uplink_interface() { fi } - # uplink device detection, can be overridden NETWORK_DEVICE="${NETWORK_DEVICE:-}" if [[ -z "$NETWORK_DEVICE" ]]; then @@ -79,6 +60,25 @@ NC='\033[0m' # shared helpers ############################################################################### +ensure_jq() { + echo "checking for jq..." + + if command -v jq >/dev/null 2>&1; then + echo "jq is already installed" + else + echo "jq not found, installing..." + apt-get update -y + DEBIAN_FRONTEND=noninteractive apt-get install -y jq + + if command -v jq >/dev/null 2>&1; then + echo "jq installed successfully" + else + echo "failed to install jq" + exit 1 + fi + fi +} + install_iptables_persistent() { if ! dpkg -s iptables-persistent >/dev/null 2>&1; then echo -e "${YELLOW}installing iptables-persistent${NC}" @@ -283,9 +283,6 @@ remove_duplicate_rules() { echo "duplicate rule scan completed for $interface" } - - - apply_iptables_rules() { local interface=$1 echo "applying iptables rules for $interface using uplink $NETWORK_DEVICE" @@ -349,6 +346,7 @@ perform_pings() { } joke_through_tunnel() { + ensure_jq local interface=$1 local green="\033[0;32m" local reset="\033[0m" @@ -905,6 +903,11 @@ test_forward_chain_hook() { test_default_reject_rule() { echo -e "${YELLOW}testing default reject rule position in ${NYM_CHAIN}${NC}" + # not sure this will really check that it is on end + if iptables -L "$NYM_CHAIN" | grep -q "REJECT"; then + echo "default reject present in ipv4 chain" + else + echo "default reject missing in ipv4 chain" local last_rule_v4 last_rule_v4=$(iptables -S "$NYM_CHAIN" | awk '/^-A /{rule=$0} END{print rule}') if [[ "$last_rule_v4" != "-A $NYM_CHAIN -j REJECT --reject-with icmp-port-unreachable" ]]; then