set -e base="shared/1-data-1-empty" ipNet="10.6.9.0/24" primus_base="$base/primus" primus_ip="10.6.9.1" secondus_base="$base/secondus" secondus_ip="10.6.9.2" function as_primus { current_ip="$primus_ip" eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$primus_base")" } function as_secondus { current_ip="$secondus_ip" eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$secondus_base")" } # Even if it's already intialized, we want to put the caller in primus' # environment as_primus secondus_bootstrap="$(pwd)/secondus-bootstrap.json" if [ ! -d "$XDG_RUNTIME_DIR/isle" ]; then echo "Initializing shared single node network" mkdir a mkdir b mkdir c cat >daemon.yml <daemon.log 2>&1 & pid="$!" $SHELL "$UTILS/register-cleanup.sh" "$pid" "1-data-1-empty-node-network/primus" echo "Waiting for primus daemon (process $pid) to start" while ! [ -e "$ISLE_DAEMON_HTTP_SOCKET_PATH" ]; do sleep 1; done echo "Creating 1-data-1-empty network" isle network create \ --domain shared.test \ --hostname primus \ --ip-net "$ipNet" \ --name "testing" \ > admin.json echo "Creating secondus bootstrap" isle hosts create \ --admin-path admin.json \ --hostname secondus \ --ip "$secondus_ip" \ > "$secondus_bootstrap" ( as_secondus cat >daemon.yml <daemon.log 2>&1 & pid="$!" $SHELL "$UTILS/register-cleanup.sh" "$pid" "1-data-1-empty-node-network/secondus" echo "Waiting for secondus daemon (process $!) to start" while ! [ -e "$ISLE_DAEMON_HTTP_SOCKET_PATH" ]; do sleep 1; done echo "Joining secondus to the network" isle network join -b "$secondus_bootstrap" ) fi