-
Notifications
You must be signed in to change notification settings - Fork 3
/
upgrade.sh
executable file
·62 lines (51 loc) · 1.5 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
#!/bin/bash
if [ "`id -u`" != "0" ]; then
echo "ERROR: This script must be run as root." 1>&2
exit 1
fi
if [ ! -f "lib/install.sh" ]; then
echo "Unable to source installation functions." 1>&2
exit 1
fi
. lib/install.sh
prompt_for_variant
latest_version=`get_latest_version "${VARIANT}"`
current_version=''
if [ -f '.version' ]; then
current_version=`cat .version | head -n1`
current_variant=`cat .version | tail -n1`
fi
if [ -z "${latest_version}" ]; then
echo "ERROR: Unable to determine the latest version from the web." 1>&2
exit 1
fi
if [ "${current_version}" != "${latest_version}" ]; then
echo "Current: ${current_version} ${current_variant}"
echo "Latest: ${latest_version} ${VARIANT}"
VERSION="${latest_version}"
echo "Upgrading to: ${latest_version} ${VARIANT}"
/etc/init.d/bitcoind status 1>/dev/null 2>/dev/null
if [ "$?" -eq 0 ]; then
echo "Shutting down the Bitcoin Daemon"
/etc/init.d/bitcoind stop
fi
echo "Downloading ${VERSION}"
download_bitcoind "${VARIANT}"
echo "Installing binary files..."
install_binaries "${VARIANT}"
# Start BitcoinQT Daemon
echo "Starting Bitcoin Daemon..."
/etc/init.d/bitcoind start
sleep 3
/etc/init.d/bitcoind status
echo "${VERSION}" > .version
echo "${VARIANT}" >> .version
exit 0
else
if [[ "${USE_XT}" -eq 1 ]]; then
echo "Up to date. (${latest_version})"
else
echo "Up to date. (v${latest_version})"
fi
exit 0
fi