-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathinstall-sx.sh
executable file
·147 lines (135 loc) · 3.75 KB
/
install-sx.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
set -e
echo "Welcome to the S(pesmilo)X(change)"
echo
if [ $# -eq 1 ]; then
if [[ "$1" = /* ]]; then
# Absolute path.
INSTALL_PREFIX=$1
else
# Relative path.
INSTALL_PREFIX=$(pwd)/$1
fi
CONF_DIR=$INSTALL_PREFIX/etc/
RUN_LDCONFIG=
ROOT_INSTALL=0
elif [ "$(id -u)" -eq "0" ]; then
INSTALL_PREFIX=/usr/local/
CONF_DIR=/etc/
RUN_LDCONFIG=ldconfig
ROOT_INSTALL=1
else
echo "Error: This script must be run as root." 1>&2
echo
echo " $ sudo bash ./install-sx.sh" 1>&2
echo
exit 1
fi
echo " ***********************************************************************"
echo " * sx command line utilities - Empower The Sysadmin With Bitcoin Tools *"
echo " ***********************************************************************"
echo
echo "Installation commencing NOW ($INSTALL_PREFIX)."
DEPENDENCIES="git build-essential autoconf libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev"
function pkg_is_installed
{
dpkg -s $1 > /dev/null
if [ $? -eq 0 ]; then
echo 1
else
echo 0
fi
}
if [ $ROOT_INSTALL -eq 1 ]; then
echo "Installing dependencies..."
apt-get install $DEPENDENCIES
fi
for pkg in $DEPENDENCIES; do
if [ $(pkg_is_installed $pkg) -eq 0 ]; then
echo
echo "Error: $pkg is not installed!"
echo
echo "Run the following command:"
echo
echo " $ sudo apt-get install $DEPENDENCIES"
echo
exit 1
fi
done
SRC_DIR=$INSTALL_PREFIX/src/
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig/
mkdir -p $SRC_DIR
cd $SRC_DIR
if [ -d "libbitcoin-git" ]; then
echo "Updating libbitcoin..."
cd libbitcoin-git
git pull --rebase
else
echo "Downloading libbitcoin..."
git clone https://github.com/spesmilo/libbitcoin.git libbitcoin-git
cd libbitcoin-git
fi
echo "Beginning build process now..."
autoreconf -i
./configure --enable-leveldb --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo "libbitcoin now installed."
cd $SRC_DIR
if [ -d "obelisk-git" ]; then
echo "Updating obelisk.."
cd obelisk-git
git remote set-url origin https://github.com/spesmilo/obelisk.git
git pull --rebase
else
echo "Downloading obelisk..."
git clone https://github.com/spesmilo/obelisk.git obelisk-git
cd obelisk-git
fi
echo "Beginning build process now..."
autoreconf -i
./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo "obelisk now installed."
# Old sx put binaries in bin/sx-*
BIN_DIR=$INSTALL_PREFIX/bin/
rm -f $BIN_DIR/sx-*
cd $SRC_DIR
if [ -d "sx-git" ]; then
echo "Updating sx..."
cd sx-git
git remote set-url origin https://github.com/spesmilo/sx.git
git pull --rebase
else
echo "Downloading sx..."
git clone https://github.com/spesmilo/sx.git sx-git
cd sx-git
fi
echo "Beginning build process now..."
autoreconf -i
./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX
make
make install
echo "sx now installed."
echo
echo "Config files are in $CONF_DIR/"
echo " obelisk cfg: $CONF_DIR/obelisk/*.cfg"
echo " sx cfg: ~/.sx.cfg (see $INSTALL_PREFIX/share/sx/sx.cfg for an"
echo " example config file."
echo
echo "Documentation is available /usr/local/doc/"
echo " libbitcoin doc: $INSTALL_PREFIX/share/doc/libbitcoin/"
echo " obelisk doc: $INSTALL_PREFIX/share/doc/obelisk/"
echo " sx doc: $INSTALL_PREFIX/share/doc/sx/"
echo
if [ $ROOT_INSTALL -eq 0 ]; then
echo "Add these lines to your ~/.bashrc"
echo
echo " export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib/"
echo " export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig/"
echo " export PATH=\$PATH:$INSTALL_PREFIX/bin/"
echo
fi