#!/bin/bash PUBLIC_IP=$(ip address show dev $(route | grep '^default' | grep -o '[^ ]*$') | grep -o 'inet [0-9.]*' | grep -o '[^ ]*$') docker volume create soffid-pam-store >/dev/null docker volume create soffid-pam-launcher >/dev/null echo "=====================" echo "Creating store server" echo "=====================" docker create \ --network soffid.internal \ -v soffid-pam-store:/opt/soffid/tomee/data \ -p 8081:8080 \ --name soffid-pam-store \ soffid/pam-store >/dev/null docker start soffid-pam-store >/dev/null echo "Waiting for store server" # Wait for store server sleep 3 while ! curl http://localhost:8081/store/check -o /dev/null -s -S do sleep 3 done hostname=$(hostname) userid=$hostname-launcher if docker exec soffid-pam-store cat /opt/soffid/tomee/data/passwd then userid=$hostname-launcher-$(date '+%s') fi docker exec soffid-pam-store /opt/soffid/tomee/bin/add-user.sh $hostname-launcher launcher | while read prompt pass do echo "Creating launch server" docker create \ --network soffid.internal \ -v soffid-pam-launcher:/opt/soffid/tomee/launcher \ -v /var/run/docker.sock:/var/run/docker.sock \ -p 8082:8080 \ -e STORE_SERVER="http://$PUBLIC_IP:8081/" \ -e STORE_USER="$hostname-launcher" \ -e STORE_PASSWORD="$pass" \ --name soffid-pam-launcher \ soffid/pam-launcher >/dev/null done docker start soffid-pam-launcher >/dev/null docker exec soffid-pam-store /opt/soffid/tomee/bin/generate-key.sh docker exec soffid-pam-store /opt/soffid/tomee/bin/add-user.sh $hostname console | while read prompt pass do echo "=============================================================" echo "Process completed" echo "Notice: You must register the store server in Soffid console:" echo "User name: $hostname" echo "Password : $pass" done