forked from steemit/steem
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsteemd.run
78 lines (61 loc) · 1.92 KB
/
steemd.run
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
78
#!/bin/bash
export HOME="/var/lib/steemd"
STEEMD="/usr/local/steemd-default/bin/steemd"
if [[ "$USE_WAY_TOO_MUCH_RAM" ]]; then
STEEMD="/usr/local/steemd-full/bin/steemd"
fi
chown -R steemd:steemd $HOME
# seed nodes come from doc/seednodes.txt which is
# installed by docker into /etc/steemd/seednodes.txt
SEED_NODES="$(cat /etc/steemd/seednodes.txt | awk -F' ' '{print $1}')"
ARGS=""
# if user did not pass in any desired
# seed nodes, use the ones above:
if [[ -z "$STEEMD_SEED_NODES" ]]; then
for NODE in $SEED_NODES ; do
ARGS+=" --seed-node=$NODE"
done
fi
# if user did pass in desired seed nodes, use
# the ones the user specified:
if [[ ! -z "$STEEMD_SEED_NODES" ]]; then
for NODE in $STEEMD_SEED_NODES ; do
ARGS+=" --seed-node=$NODE"
done
fi
if [[ ! -z "$STEEMD_WITNESS_NAME" ]]; then
ARGS+=" --witness=\"$STEEMD_WITNESS_NAME\""
fi
if [[ ! -z "$STEEMD_MINER_NAME" ]]; then
ARGS+=" --miner=[\"$STEEMD_MINER_NAME\",\"$STEEMD_PRIVATE_KEY\"]"
ARGS+=" --mining-threads=$(nproc)"
fi
if [[ ! -z "$STEEMD_PRIVATE_KEY" ]]; then
ARGS+=" --private-key=$STEEMD_PRIVATE_KEY"
fi
# overwrite local config with image one
cp /etc/steemd/config.ini $HOME/config.ini
chown steemd:steemd $HOME/config.ini
if [[ ! -d $HOME/blockchain ]]; then
if [[ -e /var/cache/steemd/blocks.tbz2 ]]; then
# init with blockchain cached in image
ARGS+=" --replay-blockchain"
mkdir -p $HOME/blockchain/database
cd $HOME/blockchain/database
tar xvjpf /var/cache/steemd/blocks.tbz2
chown -R steemd:steemd $HOME/blockchain
fi
fi
# without --data-dir it uses cwd as datadir(!)
# who knows what else it dumps into current dir
cd $HOME
# slow down restart loop if flapping
sleep 1
exec chpst -usteemd \
$STEEMD \
--rpc-endpoint=0.0.0.0:8090 \
--p2p-endpoint=0.0.0.0:2001 \
--data-dir=$HOME \
$ARGS \
$STEEMD_EXTRA_OPTS \
2>&1