mirror of
https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
synced 2024-11-15 01:05:42 +00:00
37 lines
1.2 KiB
Bash
Executable File
37 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
SWARM_MANAGER_IP=""
|
|
SWARM_WORKER_NUMBER=4
|
|
|
|
if [ -z ${SWARM_MANAGER_IP} ]; then
|
|
# See https://stackoverflow.com/a/25851186
|
|
SWARM_MANAGER_IP=$(ip route get 1 | awk '{print $(NF-2);exit}')
|
|
fi
|
|
|
|
echo "Leave possible swarm and down all services..."
|
|
docker swarm leave --force > /dev/null 2>&1
|
|
docker-compose --file dind_swarm.yml down > /dev/null 2>&1
|
|
|
|
|
|
echo "Start storage container"
|
|
docker-compose --file dind_swarm.yml up --detach storage
|
|
sleep 3
|
|
|
|
echo "Mount network storage to host system..."
|
|
sudo mkdir -p /mnt/opaque
|
|
sudo mount -t cifs -o gid=${USER},password=opaque,uid=${USER},user=opaque,vers=3.0 //localhost/opaque_storage /mnt/opaque
|
|
|
|
echo "Start worker service(s)"
|
|
docker-compose --file dind_swarm.yml up --detach --scale worker=${SWARM_WORKER_NUMBER} worker viz
|
|
sleep 5
|
|
|
|
echo "Init Docker swarm..."
|
|
docker swarm init --advertise-addr ${SWARM_MANAGER_IP} > /dev/null 2>&1
|
|
|
|
echo "Add workers to swarm..."
|
|
SWARM_WORKER_TOKEN=$(docker swarm join-token -q worker)
|
|
for i in $(seq 1 ${SWARM_WORKER_NUMBER}); do
|
|
echo "[opaque_worker_${i}]"
|
|
docker-compose --file dind_swarm.yml exec --index=${i} worker docker swarm join --token ${SWARM_WORKER_TOKEN} ${SWARM_MANAGER_IP}:2377
|
|
done
|