diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-sec b/install/usr/share/swarmlab.io/sec/swarmlab-sec index 5acc431..5752c45 100755 --- a/install/usr/share/swarmlab.io/sec/swarmlab-sec +++ b/install/usr/share/swarmlab.io/sec/swarmlab-sec @@ -116,6 +116,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 +} + Wdir=$(pwd) if [ ! -f $Wdir/.env ]; then @@ -124,6 +138,14 @@ REGISTRY_ADDR=localhost REGISTRY_PORT=5000 IMAGE_NAME=$HYBRID_NETWORK SSH_PORT= +WEB_PORT=$(EPHEMERAL_PORT) +WEB_PORT1=$(EPHEMERAL_PORT) +WEB_PORT2=$(EPHEMERAL_PORT) +R_PORT1=$(EPHEMERAL_PORT) +R_PORT2=$(EPHEMERAL_PORT) +R_PORT3=$(EPHEMERAL_PORT) +R_PORT4=$(EPHEMERAL_PORT) +R_PORT5=$(EPHEMERAL_PORT) EOF fi @@ -378,6 +400,7 @@ services: user: root entrypoint: ["sec_bootstrap", "role=master", "sec_master_service_name=master", "sec_worker_service_name=worker"] ports: + - "\${R_PORT1}:3787" - "\${SSH_PORT}:22" networks: - ${HYBRID_NETWORK}