2023-09-05 21:14:40 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
base="shared/1-data-1-empty"
|
2023-09-06 19:55:05 +00:00
|
|
|
|
2024-07-12 13:30:21 +00:00
|
|
|
ipNet="10.6.9.0/24"
|
|
|
|
|
2023-09-05 21:14:40 +00:00
|
|
|
primus_base="$base/primus"
|
2023-09-06 19:55:05 +00:00
|
|
|
primus_ip="10.6.9.1"
|
|
|
|
|
2023-09-05 21:14:40 +00:00
|
|
|
secondus_base="$base/secondus"
|
2023-09-06 19:55:05 +00:00
|
|
|
secondus_ip="10.6.9.2"
|
2023-09-05 21:14:40 +00:00
|
|
|
|
2023-09-06 19:06:03 +00:00
|
|
|
function as_primus {
|
2023-09-06 19:55:05 +00:00
|
|
|
current_ip="$primus_ip"
|
2023-09-06 19:06:03 +00:00
|
|
|
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$primus_base")"
|
|
|
|
}
|
|
|
|
|
|
|
|
function as_secondus {
|
2023-09-06 19:55:05 +00:00
|
|
|
current_ip="$secondus_ip"
|
2023-09-06 19:06:03 +00:00
|
|
|
eval "$($SHELL "$UTILS/shared-daemon-env.sh" "$secondus_base")"
|
|
|
|
}
|
|
|
|
|
2023-09-05 21:14:40 +00:00
|
|
|
# Even if it's already intialized, we want to put the caller in primus'
|
|
|
|
# environment
|
2023-09-06 19:06:03 +00:00
|
|
|
as_primus
|
2023-09-05 21:14:40 +00:00
|
|
|
|
2024-06-10 16:56:36 +00:00
|
|
|
secondus_bootstrap="$(pwd)/secondus-bootstrap.json"
|
2023-09-05 21:14:40 +00:00
|
|
|
|
|
|
|
if [ ! -d "$XDG_RUNTIME_DIR/isle" ]; then
|
2024-07-06 13:36:48 +00:00
|
|
|
echo "Initializing shared single node network"
|
2023-09-05 21:14:40 +00:00
|
|
|
|
|
|
|
mkdir a
|
|
|
|
mkdir b
|
|
|
|
mkdir c
|
|
|
|
|
|
|
|
cat >daemon.yml <<EOF
|
|
|
|
vpn:
|
|
|
|
public_addr: 127.0.0.1:60000
|
|
|
|
tun:
|
|
|
|
device: isle-primus
|
|
|
|
storage:
|
|
|
|
allocations:
|
|
|
|
- data_path: a/data
|
|
|
|
meta_path: a/meta
|
2024-06-11 12:54:26 +00:00
|
|
|
capacity: 1
|
2023-09-05 21:14:40 +00:00
|
|
|
- data_path: b/data
|
|
|
|
meta_path: b/meta
|
2024-06-11 12:54:26 +00:00
|
|
|
capacity: 1
|
2023-09-05 21:14:40 +00:00
|
|
|
- data_path: c/data
|
|
|
|
meta_path: c/meta
|
2024-06-11 12:54:26 +00:00
|
|
|
capacity: 1
|
2023-09-05 21:14:40 +00:00
|
|
|
EOF
|
|
|
|
|
2024-07-09 09:43:17 +00:00
|
|
|
isle daemon -l debug --config-path 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
|
|
|
|
|
2023-09-05 21:14:40 +00:00
|
|
|
echo "Creating 1-data-1-empty network"
|
2024-07-09 09:43:17 +00:00
|
|
|
isle network create \
|
2023-09-05 21:14:40 +00:00
|
|
|
--domain shared.test \
|
|
|
|
--hostname primus \
|
2024-07-12 13:30:21 +00:00
|
|
|
--ip-net "$ipNet" \
|
2023-09-05 21:14:40 +00:00
|
|
|
--name "testing" \
|
2024-06-10 16:56:36 +00:00
|
|
|
> admin.json
|
2023-09-05 21:14:40 +00:00
|
|
|
|
|
|
|
echo "Creating secondus bootstrap"
|
|
|
|
isle admin create-bootstrap \
|
2024-06-10 16:56:36 +00:00
|
|
|
--admin-path admin.json \
|
2023-09-05 21:14:40 +00:00
|
|
|
--hostname secondus \
|
2023-09-06 19:55:05 +00:00
|
|
|
--ip "$secondus_ip" \
|
2023-09-05 21:14:40 +00:00
|
|
|
> "$secondus_bootstrap"
|
|
|
|
|
|
|
|
(
|
2023-09-06 19:06:03 +00:00
|
|
|
as_secondus
|
2023-09-05 21:14:40 +00:00
|
|
|
|
|
|
|
cat >daemon.yml <<EOF
|
|
|
|
vpn:
|
|
|
|
tun:
|
|
|
|
device: isle-secondus
|
|
|
|
EOF
|
|
|
|
|
2024-07-07 10:44:49 +00:00
|
|
|
isle daemon -l debug -c daemon.yml >daemon.log 2>&1 &
|
2023-09-05 21:14:40 +00:00
|
|
|
pid="$!"
|
2024-07-06 13:36:48 +00:00
|
|
|
$SHELL "$UTILS/register-cleanup.sh" "$pid" "1-data-1-empty-node-network/secondus"
|
2024-07-07 10:44:49 +00:00
|
|
|
|
|
|
|
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"
|
2023-09-05 21:14:40 +00:00
|
|
|
)
|
|
|
|
fi
|