forked from fystack/mpcium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_identities.sh
More file actions
executable file
·59 lines (53 loc) · 1.66 KB
/
setup_identities.sh
File metadata and controls
executable file
·59 lines (53 loc) · 1.66 KB
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
#!/bin/bash
# Number of nodes to create (default is 3)
NUM_NODES=3
echo "🚀 Setting up Node Identities..."
# Create node directories and copy config files
echo "📁 Creating node directories..."
for i in $(seq 0 $((NUM_NODES-1))); do
mkdir -p "node$i/identity"
if [ ! -f "node$i/config.yaml" ]; then
cp config.yaml "node$i/"
fi
if [ ! -f "node$i/peers.json" ]; then
cp peers.json "node$i/"
fi
done
# Generate identity for each node
echo "🔑 Generating identities for each node..."
for i in $(seq 0 $((NUM_NODES-1))); do
echo "📝 Generating identity for node$i..."
cd "node$i"
mpcium-cli generate-identity --node "node$i"
cd ..
done
# Distribute identity files to all nodes
echo "🔄 Distributing identity files across nodes..."
for i in $(seq 0 $((NUM_NODES-1))); do
for j in $(seq 0 $((NUM_NODES-1))); do
if [ $i != $j ]; then
echo "📋 Copying node${i}_identity.json to node$j..."
cp "node$i/identity/node${i}_identity.json" "node$j/identity/"
fi
done
done
echo "✨ Node identities setup complete!"
echo
echo "📂 Created folder structure:"
echo "├── node0"
echo "│ ├── config.yaml"
echo "│ ├── identity/"
echo "│ └── peers.json"
echo "├── node1"
echo "│ ├── config.yaml"
echo "│ ├── identity/"
echo "│ └── peers.json"
echo "└── node2"
echo " ├── config.yaml"
echo " ├── identity/"
echo " └── peers.json"
echo
echo "✅ You can now start your nodes with:"
echo "cd node0 && mpcium start -n node0"
echo "cd node1 && mpcium start -n node1"
echo "cd node2 && mpcium start -n node2"