forked from highfidelity/eos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheosio-tn_roll.sh
executable file
·92 lines (80 loc) · 2.02 KB
/
eosio-tn_roll.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/bin/bash
#
# eosio-tn_roll is used to have all of the instances of the EOS daemon on a host brought down
# so that the underlying executable image file (the "text file") can be replaced. Then
# all instances are restarted.
# usage: eosio-tn_roll.sh [arglist]
# arglist will be passed to the node's command line. First with no modifiers
# then with --replay and then a third time with --resync
#
# The data directory and log file are set by this script. Do not pass them on
# the command line.
#
# In most cases, simply running ./eosio-tn_roll.sh is sufficient.
#
if [ -z "$EOSIO_HOME" ]; then
echo EOSIO_HOME not set - $0 unable to proceed.
exit -1
fi
cd $EOSIO_HOME
if [ -z "$EOSIO_NODE" ]; then
DD=`ls -d var/lib/node_[012]?`
ddcount=`echo $DD | wc -w`
if [ $ddcount -gt 1 ]; then
DD="all"
fi
OFS=$((${#DD}-2))
export EOSIO_NODE=${DD:$OFS}
else
DD=var/lib/node_$EOSIO_NODE
if [ ! \( -d $DD \) ]; then
echo no directory named $PWD/$DD
cd -
exit -1
fi
fi
prog=""
RD=""
for p in eosd eosiod nodeos; do
prog=$p
RD=bin
if [ -f $RD/$prog ]; then
break;
else
RD=programs/$prog
if [ -f $RD/$prog ]; then
break;
fi
fi
prog=""
RD=""
done
if [ \( -z "$prog" \) -o \( -z "$RD" \) ]; then
echo unable to locate binary for eosd or eosiod or nodeos
exit 1
fi
SDIR=staging/eos
if [ ! -e $SDIR/$RD/$prog ]; then
echo $SDIR/$RD/$prog does not exist
exit 1
fi
if [ -e $RD/$prog ]; then
s1=`md5sum $RD/$prog | sed "s/ .*$//"`
s2=`md5sum $SDIR/$RD/$prog | sed "s/ .*$//"`
if [ "$s1" == "$s2" ]; then
echo $HOSTNAME no update $SDIR/$RD/$prog
exit 1;
fi
fi
echo DD = $DD
bash $EOSIO_HOME/scripts/eosio-tn_down.sh
cp $SDIR/$RD/$prog $RD/$prog
if [ $DD = "all" ]; then
for EOSIO_RESTART_DATA_DIR in `ls -d var/lib/node_??`; do
bash $EOSIO_HOME/scripts/eosio-tn_up.sh $*
done
else
bash $EOSIO_HOME/scripts/eosio-tn_up.sh $*
fi
unset EOSIO_RESTART_DATA_DIR
cd -