This repository has been archived by the owner on Oct 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_start.sh
executable file
·76 lines (57 loc) · 1.89 KB
/
build_start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
###################################################################################
# #
# Lotus Devnet Start Script - Marcel Wuersten - 2022 - University of Bern #
# #
###################################################################################
killall k3s-server
k3s server --docker > /dev/null 2>&1 &
# Build the docker image
docker image build -t marcelwuersten/filecoin-lotus:latest -f lotus.dockerfile .
# Apply deployment
k3s kubectl apply -f ./deploy
echo "Applied deployment"
# Scale the number of nodes
echo "Scale param is $1"
# If given argument and it's an integer us it
if [[ $1 =~ ^[0-9]+$ ]]; then
scale="$1"
# if it's my poor notebook, default to 3
elif [[ $(hostname) == 'marcel-ThinkPad-X1' ]]; then
scale="3"
# else default to 8 nodes
else
scale="8"
fi
# Definei the network topology
echo "network param is $2"
if [[ $2 =~ "ring" ]] || [[ $2 =~ "full" ]] || [[ $2 =~ "tree" ]]; then
topology="$2"
# default to start topology if no valid value is given
else
topology="star"
fi
echo "Network topology set to $topology"
# Wait for the redis node
echo "Wait for redis"
sleep 30
kubectl wait --for=condition=ready pod -l app=redisnode
# Scale the lotus nodes
echo "scale to ${scale}"
kubectl scale --replicas="${scale}" -f ./deploy/lotus.yaml
# Save values in redis for the nodes to read
./redis-cli/rediscli w nettopology "$topology"
./redis-cli/rediscli w fil-nodes "$(($scale - 1))"
if [[ $3 =~ "true" ]]; then
./redis-cli/rediscli w SingleBlock "true"
fi
# Wait for all nodes
echo "Wait for all node ready"
for i in $(seq 0 $(($scale - 1)))
do
# sleep until the node reports it self as started
while ! ./redis-cli/rediscli r lotus-node-${i}-started; do
sleep 1
done
done
echo "All nodes ready"