-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupgrade.sh
73 lines (59 loc) · 1.64 KB
/
upgrade.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
#!/bin/bash
index=$(curl -s https://snapshot-de.mydefichain.com/index.txt | tail -1)
file="https://snapshot-de.mydefichain.com/${index}"
DFI_FOLDER=$HOME
DFI_RELEASE=$1
DFI_SNAPSHOT=$2
DONE="[\e[32mDONE\e[39m]"
if [[ $# -lt 1 ]];
then
echo "Usage: $0 [release] [snapshot]"
echo "release - Release number like 2.6.2"
echo "snapshot - true if you like to restore from current snapshot"
exit 2
fi
echo -n "Downloading binary and checking SHA256: "
cd $DFI_FOLDER
wget -q https://github.com/DeFiCh/ain/releases/download/v${DFI_RELEASE}/defichain-${DFI_RELEASE}-x86_64-pc-linux-gnu.tar.gz
wget -q https://github.com/DeFiCh/ain/releases/download/v${DFI_RELEASE}/defichain-${DFI_RELEASE}-x86_64-pc-linux-gnu.tar.gz.SHA256
sha256sum -c defichain-${DFI_RELEASE}-x86_64-pc-linux-gnu.tar.gz.SHA256 > /dev/null
if [ $? -ne 0 ]; then
echo "FAILED CHECKSUM!"
exit 1
fi
echo -e $DONE
echo -n "Disable CRON: "
crontab -l > $DFI_FOLDER/cron_tmp
echo "" | crontab -
echo -e $DONE
echo -n "Stop dfid: "
PIDS=$(pidof defid)
if [ -n "$PIDS" ];
then
kill $PIDS
while [ -n "$PIDS" ]; do
sleep 1
PIDS=$(pidof defid)
done
fi
echo -e $DONE
echo -n "Updating defi node v.${DFI_RELEASE}: "
tar xzf defichain-${DFI_RELEASE}-x86_64-pc-linux-gnu.tar.gz
cp defichain-${DFI_RELEASE}/bin/* .defi/
rm -rf defichain-${DFI_RELEASE}*
echo -e $DONE
if [ "$DFI_SNAPSHOT" == "true" ];
then
echo -n "Setup from snapshot: "
cd .defi
rm -rf anchors/ burn/ blocks/ chainstate/ enhancedcs/ history/ spv
wget -q $file
tar xzf $index
rm -rf *.tar.gz
echo -e $DONE
fi
echo -n "Enable CRON: "
crontab $DFI_FOLDER/cron_tmp
rm $DFI_FOLDER/cron_tmp
echo -e $DONE
echo ".:[ DONE ]:."