forked from paritytech/extended-parachain-template
-
Notifications
You must be signed in to change notification settings - Fork 1
/
zombienet.sh
executable file
·77 lines (69 loc) · 2.08 KB
/
zombienet.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
77
#!/bin/bash
ZOMBIENET_V=v1.3.68
POLKADOT_V=v1.1.0
case "$(uname -s)" in
Linux*) MACHINE=Linux;;
Darwin*) MACHINE=Mac;;
*) exit 1
esac
if [ $MACHINE = "Linux" ]; then
ZOMBIENET_BIN=zombienet-linux-x64
elif [ $MACHINE = "Mac" ]; then
ZOMBIENET_BIN=zombienet-macos
fi
build_polkadot(){
echo "cloning polkadot repository..."
CWD=$(pwd)
mkdir -p bin
pushd /tmp
git clone https://github.com/paritytech/polkadot-sdk.git
pushd polkadot-sdk
git checkout release-polkadot-$POLKADOT_V
echo "building polkadot executable..."
cargo build --release --features fast-runtime
cp target/release/polkadot "$CWD/bin"
cp target/release/polkadot-execute-worker "$CWD/bin"
cp target/release/polkadot-prepare-worker "$CWD/bin"
popd
popd
}
zombienet_init() {
if [ ! -f $ZOMBIENET_BIN ]; then
echo "fetching zombienet executable..."
curl -LO https://github.com/paritytech/zombienet/releases/download/$ZOMBIENET_V/$ZOMBIENET_BIN
chmod +x $ZOMBIENET_BIN
fi
if [ ! -f bin/polkadot ] || [ ! -f bin/polkadot-execute-worker ] || [ ! -f bin/polkadot-prepare-worker ]; then
build_polkadot
fi
}
zombienet_spawn() {
zombienet_init
if [ ! -f target/release/parachain-template-node ]; then
echo "building parachain-template-node..."
cargo build --release
fi
echo "spawning polkadot-local relay chain plus parachain-template-node..."
./$ZOMBIENET_BIN spawn zombienet-config/rococo-local-config.toml -p native
}
print_help() {
echo "This is a shell script to automate the execution of zombienet."
echo ""
echo "$ ./zombienet.sh init # fetches zombienet and polkadot executables"
echo "$ ./zombienet.sh spawn # spawns a rococo-local relay chain plus parachain-template-node"
}
SUBCOMMAND=$1
case $SUBCOMMAND in
"" | "-h" | "--help")
print_help
;;
*)
shift
zombienet_${SUBCOMMAND} $@
if [ $? = 127 ]; then
echo "Error: '$SUBCOMMAND' is not a known SUBCOMMAND." >&2
echo "Run './zombienet.sh --help' for a list of known subcommands." >&2
exit 1
fi
;;
esac