-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathstart-snapshot.sh
executable file
·66 lines (58 loc) · 1.71 KB
/
start-snapshot.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
#!/usr/bin/env bash
WAX_VERSION=v3.1.5wax01
SYNC_TO_BLOCK_HEIGHT=291445188
SNAPSHOT_URL=""
# Home inside docker
NODEOS_HOME=/root/.local/share/eosio/nodeos
# WAX data folder root on the host running this docker image
HOST_WAX_HOME=${HOST_WAX_HOME:-`pwd`}
function start_api_nodeos_from_snapshot {
mkdir -p $HOST_WAX_HOME/snapshotnodeos/data/
cd $HOST_WAX_HOME/snapshotnodeos/data/
rm *.bin
rm *.zst
wget $SNAPSHOT_URL
unzstd *.zst
rm *.zst
TGZ_FILES=( *.bin )
SNAPSHOT="${TGZ_FILES[0]}"
docker run -t --sig-proxy=true --name nodeos \
-v $HOST_WAX_HOME/snapshotnodeos/data:$NODEOS_HOME/data \
-v $HOST_WAX_HOME/snapshotnodeos/config:$NODEOS_HOME/config \
-p 0.0.0.0:8888:8888 \
-p 9876:9876 \
-d \
waxteam/waxnode:$WAX_VERSION \
sh -c \
"$NODEOS_HOME/config/start-snapshot.sh $SYNC_TO_BLOCK_HEIGHT $SNAPSHOT"
}
function start_api_nodeos_stardard {
docker run --sig-proxy=true --name nodeos \
-v $HOST_WAX_HOME/snapshotnodeos/data:$NODEOS_HOME/data \
-v $HOST_WAX_HOME/snapshotnodeos/config:$NODEOS_HOME/config \
-p 0.0.0.0:8888:8888 \
-p 9876:9876 \
-d \
waxteam/waxnode:$WAX_VERSION \
sh -c \
"$NODEOS_HOME/config/start.sh $SYNC_TO_BLOCK_HEIGHT"
}
while getopts t:u: flag
do
case "${flag}" in
t) SYNC_TO_BLOCK_HEIGHT=${OPTARG};;
u) SNAPSHOT_URL=${OPTARG};;
?)
echo "script usage: $(basename $0) [-s true/false] [-e true/false]" >&2
echo "options:"
echo "-t Sync to block height"
echo "-u Snapshot url"
exit 1
;;
esac
done
if [ "$SNAPSHOT_URL" == "" ]; then
start_api_nodeos_stardard
else
start_api_nodeos_from_snapshot
fi