diff --git a/install/usr/share/swarmlab.io/sec/bin/start-nginx.sh b/install/usr/share/swarmlab.io/sec/bin/start-nginx.sh new file mode 100755 index 0000000..fd591f6 --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/bin/start-nginx.sh @@ -0,0 +1,2 @@ +#!/bin/sh +/usr/bin/supervisord -n -c /etc/supervisor/supervisord.conf diff --git a/install/usr/share/swarmlab.io/sec/bin/swarmlab-nmap b/install/usr/share/swarmlab.io/sec/bin/swarmlab-nmap new file mode 100755 index 0000000..5f54ecf --- /dev/null +++ b/install/usr/share/swarmlab.io/sec/bin/swarmlab-nmap @@ -0,0 +1,6 @@ +#/bin/sh + +#ip=`nslookup hybrid-mpi_master_1.hybrid-mpi_hybrid-mpi | grep Addr | cut -d':' -f2 | grep -v 127.0.` +ip=`nslookup $NODENAME | grep Addr | cut -d':' -f2 | grep -v 127.0.` +nmap -sn -oG - $ip/24 | grep Up | grep $NODENETWORK | cut -d ' ' -f 2 + diff --git a/install/usr/share/swarmlab.io/sec/swarmlab-sec b/install/usr/share/swarmlab.io/sec/swarmlab-sec index 71e62ac..3efd5bc 100755 --- a/install/usr/share/swarmlab.io/sec/swarmlab-sec +++ b/install/usr/share/swarmlab.io/sec/swarmlab-sec @@ -80,6 +80,19 @@ 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 @@ -88,6 +101,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 @@ -312,6 +333,7 @@ fi /bin/mkdir -p $Wdir/project +/bin/mkdir -p $Wdir/logs /bin/cp -f $DIR/project/mpich-3.2.tar.gz $Wdir /bin/cp -rf $DIR/project/bin $Wdir/project /bin/cp -rf $DIR/project/examples $Wdir/project @@ -321,6 +343,7 @@ fi /bin/cp -f $DIR/$hostnames_get $Wdir/$hostnames_get /bin/cp -f $DIR/ROOT_PASSWORD $Wdir/ROOT_PASSWORD /bin/cp -rf $DIR/.vimrc $Wdir/.vimrc +/bin/cp -rf $DIR/bin $Wdir /bin/cp -rf $DIR/install-vim-plugin.sh $Wdir/install-vim-plugin.sh @@ -344,11 +367,13 @@ 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} volumes: - $Wdir/project:/project + - $Wdir/bin/ttyd.x86_64:/usr/bin/ttyd worker: