summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheJackiMonster <thejackimonster@gmail.com>2021-05-03 10:28:49 +0200
committerTheJackiMonster <thejackimonster@gmail.com>2021-05-03 10:28:49 +0200
commitae3ce5eaf5df138e41337c7cf4d964a031b3008d (patch)
tree41a23246e5a0cd9591cd0733a9887e54fadcbce0
parent5831a14819679c841db1f7cbd78d42aef3f61b06 (diff)
-added binary check to netjail and set stunserver fixed
Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
-rwxr-xr-xcontrib/scripts/netjail/netjail_core.sh14
-rwxr-xr-xcontrib/scripts/netjail/netjail_setup_internet.sh19
2 files changed, 26 insertions, 7 deletions
diff --git a/contrib/scripts/netjail/netjail_core.sh b/contrib/scripts/netjail/netjail_core.sh
index a3271a3e4..cbf25434b 100755
--- a/contrib/scripts/netjail/netjail_core.sh
+++ b/contrib/scripts/netjail/netjail_core.sh
@@ -44,6 +44,20 @@ netjail_check() {
fi
}
+netjail_check_bin() {
+ PROGRAM=$1
+
+ MATCH=$(ls $(echo $PATH | tr ":" "\n") | grep "^$PROGRAM\$" | tr "\n" " " | awk '{ print $1 }')
+
+ # quit if the required binary $PROGRAM can not be
+ # found in the used $PATH.
+
+ if [ "$MATCH" != "$PROGRAM" ]; then
+ echo "Required binary not found: $PROGRAM" >&2
+ exit 1
+ fi
+}
+
netjail_print_name() {
printf "%s%02x%02x" $1 $2 ${3:-0}
}
diff --git a/contrib/scripts/netjail/netjail_setup_internet.sh b/contrib/scripts/netjail/netjail_setup_internet.sh
index 94aec007e..7ff25c014 100755
--- a/contrib/scripts/netjail/netjail_setup_internet.sh
+++ b/contrib/scripts/netjail/netjail_setup_internet.sh
@@ -18,6 +18,16 @@ netjail_check $(($LOCAL_M * $GLOBAL_N))
# Starts optionally 'stunserver' on "92.68.150.$(($GLOBAL_N + 1))":
STUN=$(netjail_opt '--stun' $@)
+if [ $STUN -gt 0 ]; then
+ netjail_check_bin stunserver
+
+ shift 1
+
+ STUN_NODE=$(netjail_print_name "S" 254)
+fi
+
+netjail_check_bin $1
+
LOCAL_GROUP="192.168.15"
GLOBAL_GROUP="92.68.150"
@@ -60,13 +70,8 @@ WAITING=""
KILLING=""
if [ $STUN -gt 0 ]; then
- shift 1
-
- S=$(($GLOBAL_N + 1))
- STUN_NODE=$(netjail_print_name "S" $S)
-
netjail_node $STUN_NODE
- netjail_node_link_bridge $STUN_NODE $NETWORK_NET "$GLOBAL_GROUP.$S" 24
+ netjail_node_link_bridge $STUN_NODE $NETWORK_NET "$GLOBAL_GROUP.254" 24
netjail_node_exec $STUN_NODE 0 1 stunserver &
KILLING="$!"
@@ -90,7 +95,7 @@ for PID in $KILLING; do netjail_kill $PID; done
wait
if [ $STUN -gt 0 ]; then
- STUN_NODE=$(netjail_print_name "S" $(($GLOBAL_N + 1)))
+ STUN_NODE=$(netjail_print_name "S" 254)
netjail_node_unlink_bridge $STUN_NODE $NETWORK_NET
netjail_node_clear $STUN_NODE