forked from Bobalot/sx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-sx.sh
executable file
·253 lines (246 loc) · 7.49 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
#!/bin/bash
#
# Script to install libbitcoin, libwallet, obelisk and sx tools.
#
# Install dependencies and compiles the source code from git for Debian 7 / Ubuntu 13.10 or Fedora GNU/Linux distributions.
#
# Requires sudo.
#
# To execute this script, run:
# <sudo bash install-sx.sh>
#
# To read help instructions run:
# <sudo bash install-sx.sh --help>
#
#
set -e
echo
echo " [+] Welcome to S(pesmilo)X(changer)."
echo
sleep 0.3
if [ "$#" = "1" ]; then
if [[ "$1" = /* ]]; then
#Absolute path
INSTALL_PREFIX=$1
elif [ "$1" = "--help" ]; then
echo
echo " [+] Install script help:"
echo " Requires sudo."
echo " --> To execute this script type:"
echo " <sudo bash install-sx.sh>"
echo " --> To execute this script and install at a specific path type:"
echo " <sudo bash install-sx.sh PATH/...>"
echo " This script will install libbitcoin, libwallet, obelisk and sx tools."
echo " The standard path to the source instalation is /usr/local/src."
echo " The stardard path for the conf files is /etc."
echo
exit
else
#Relative path
RELATIVE=`pwd`
INSTALL_PREFIX=$RELATIVE/$1
fi
CONF_DIR=$INSTALL_PREFIX/etc
RUN_LDCONFIG=
ROOT_INSTALL=0
elif [ `id -u` = "0" ]; then
INSTALL_PREFIX=/usr/local
CONF_DIR=/etc
RUN_LDCONFIG=ldconfig
ROOT_INSTALL=1
else
echo
echo "[+] ERROR: This script must be run as root." 1>&2
echo
echo "<sudo bash install-sx.sh>"
echo
exit
fi
SRC_DIR=$INSTALL_PREFIX/src
PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig
mkdir -p $SRC_DIR
mkdir -p $PKG_CONFIG_PATH
#
install_dependencies(){
flavour_id=`cat /etc/*-release | egrep -i "^ID=" | cut -f 2 -d "="`
echo " Flavour: $flavour_id."
echo
if [ "$flavour_id" = "debian" ]; then
if [ "$ROOT_INSTALL" = 1 ]; then
# Debian dependencies
D_DEPENDENCIES="git build-essential autoconf apt-utils libtool libboost-all-dev pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++-dev libncurses5-dev"
sleep 0.5
apt-get -y install $D_DEPENDENCIES
fi
elif [ "$flavour_id" = "ubuntu" ]; then
if [ "$ROOT_INSTALL" = 1 ]; then
# Ubuntu dependencies (some people have libboost1.53-dev installed, determine which is installed rather than error out. Defaults onto 1.49)
for BOOST_VER in 1.49 1.53 ; do
dpkg -s "libboost$BOOST_VER-dev" >/dev/null 2>&1 && U_BOOST=$BOOST_VER
done
[[ $U_BOOST && ${U_BOOST-x} ]] && echo "Found libboost $U_BOOST" || export U_BOOST=1.49 ; echo "Defaulting to libboost $U_BOOST"
U_DEPENDENCIES="git build-essential autoconf apt-utils libtool pkg-config libcurl4-openssl-dev libleveldb-dev libzmq-dev libconfig++8-dev libncurses5-dev libboost$U_BOOST-all-dev"
sleep 0.5
apt-get -y install $U_DEPENDENCIES
fi
elif [ "$flavour_id" = "fedora" ]; then
if [ "$ROOT_INSTALL" = 1 ]; then
# Fedora dependencies
F_DEPENDENCIES="gcc-c++ git autoconf libtool boost-devel pkgconfig libcurl-devel openssl-devel leveldb-devel zeromq zeromq3 zeromq-devel libconfig libconfig-devel ncurses-devel"
sleep 0.5
yum -y install $F_DEPENDENCIES
fi
else
echo
echo " [+] ERROR: No GNU/Linux flavour properly detected: $flavour_id" 1>&2
echo
echo " Please, review the script."
echo
exit
fi
}
install_libbitcoin(){
cd $SRC_DIR
if [ -d "libbitcoin-git" ]; then
echo
echo " --> Updating Libbitcoin..."
echo
cd libbitcoin-git
git remote set-url origin https://github.com/spesmilo/libbitcoin.git
git pull --rebase
else
echo
echo " --> Downloading Libbitcoin from git..."
echo
git clone https://github.com/spesmilo/libbitcoin.git libbitcoin-git
fi
cd $SRC_DIR/libbitcoin-git
echo
echo " --> Beggining build process now...."
echo
autoreconf -i
./configure --enable-leveldb --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ Libbitcoin now installed."
echo
}
install_libwallet(){
cd $SRC_DIR
if [ -d "libwallet-git" ]; then
echo
echo " --> Updating Libwallet..."
echo
cd libwallet-git
git remote set-url origin https://github.com/spesmilo/libwallet.git
git pull --rebase
else
echo
echo " --> Downloading Libwallet from git..."
echo
git clone https://github.com/spesmilo/libwallet.git libwallet-git
fi
cd $SRC_DIR/libwallet-git
echo
echo " --> Beggining build process now...."
echo
autoreconf -i
./configure --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ Libwallet now installed."
echo
}
install_obelisk(){
cd $SRC_DIR
if [ -d "obelisk-git" ]; then
echo
echo " --> Updating Obelisk..."
echo
cd obelisk-git
git remote set-url origin https://github.com/spesmilo/obelisk.git
git pull --rebase
else
echo
echo " --> Downloading obelisk..."
echo
git clone https://github.com/spesmilo/obelisk.git obelisk-git
fi
cd $SRC_DIR/obelisk-git
echo
echo " --> Beggining build process now..."
echo
autoreconf -i
./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ Obelisk now installed."
echo
}
install_sx(){
BIN_DIR=$INSTALL_PREFIX/bin
rm -rf $BIN_DIR/sx-*
cd $SRC_DIR
if [ -d "sx-git" ]; then
echo
echo " --> Updating SX..."
echo
cd sx-git
git remote set-url origin https://github.com/spesmilo/sx.git
git pull --rebase
else
echo
echo " --> Downloading SX from git..."
echo
git clone https://github.com/spesmilo/sx.git sx-git
fi
cd $SRC_DIR/sx-git
echo
echo " --> Beggining build process now...."
echo
autoreconf -i
./configure --sysconfdir $CONF_DIR --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ SX tools now installed."
echo
}
show_finish_install_info(){
echo " --> Installation finished!"
if [ "$ROOT_INSTALL" = "1" ]; then
echo
echo " Config Files are in: $CONF_DIR"
echo " obelisk configuration files: $CONF_DIR/obelisk/*.cfg"
echo " sx configuration file: ~/.sx.cfg (see $INSTALL_PREFIX/share/sx/sx.cfg for an example config file)"
echo
echo " Documentation 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
elif [ "$ROOT_INSTALL" = "0" ]; then
echo
echo " Add these lines to your ~/.bashrc"
echo " export LD_LIBRARY_PATH=$INSTALL_PREFIX/lib"
echo " export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig"
echo " export PATH=\$PATH:$INSTALL_PREFIX/bin"
fi
echo
echo " To setup a obelisk node, you will need obworker and obbalancer daemons running."
echo " Run <sudo bash $SRC_DIR/obelisk-git/scripts/setup.sh> to create, configure and start the daemons."
echo
}
install_dependencies
install_libbitcoin
install_libwallet
install_obelisk
install_sx
show_finish_install_info