diff --git a/check-open.sh b/check-open.sh new file mode 100755 index 0000000..13e6abd --- /dev/null +++ b/check-open.sh @@ -0,0 +1,15 @@ +function EPHEMERAL_PORT() { + LOW_BOUND=49152 + RANGE=16384 + while true; do + CANDIDATE=$[$LOW_BOUND + ($RANDOM % $RANGE)] + (echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo $CANDIDATE + break + fi + done +} + +port=$(EPHEMERAL_PORT) +echo $port diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-sec b/install/usr/share/swarmlab.io/sec/swarmlab-sec index f549c43..263f92d 100755 --- a/install/usr/share/swarmlab.io/sec/swarmlab-sec +++ b/install/usr/share/swarmlab.io/sec/swarmlab-sec @@ -83,6 +83,20 @@ DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )" # # ---------------------------------------------- +function EPHEMERAL_PORT() { + LOW_BOUND=49152 + RANGE=16384 + while true; do + CANDIDATE=$[$LOW_BOUND + ($RANDOM % $RANGE)] + (echo "" >/dev/tcp/127.0.0.1/${CANDIDATE}) >/dev/null 2>&1 + if [ $? -ne 0 ]; then + echo $CANDIDATE + break + fi + done +} + +servicesshport=$(EPHEMERAL_PORT) Wdir=$(pwd) @@ -91,7 +105,7 @@ cat << EOF > $Wdir/.env REGISTRY_ADDR=localhost REGISTRY_PORT=5000 IMAGE_NAME=$HYBRID_NETWORK -SSH_PORT= +SSH_PORT=$servicesshport EOF fi @@ -274,8 +288,8 @@ services: - NET_ADMIN user: root entrypoint: ["sec_bootstrap", "role=workerservice", "sec_master_service_name=masterservice", "sec_worker_service_name=workerservice"] - ports: - - "\${SSH_PORT}:22" + #ports: + # - "\${SSH_PORT}:22" networks: - ${HYBRID_NETWORK} volumes: