forked from Bobalot/sx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-sx.sh
executable file
·418 lines (405 loc) · 11.5 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
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
#!/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
if [ "$#" = "1" ]; then
if [[ "$1" = /* ]]; then
#Absolute path
INSTALL_PREFIX=$1
elif [ "$1" = "--help" ]; then
echo " [+] Install script help:"
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 " <bash install-sx.sh PATH/...>"
echo " This script will install libbitcoin, libwallet, obelisk and sx tools."
echo " The standard path for the installation is /usr/local/"
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 or be provided an install prefix." 1>&2
echo
echo "<sudo bash install-sx.sh>"
echo "<bash install-sx.sh PATH/...>"
echo
exit
fi
SRC_DIR=$INSTALL_PREFIX/src
export PKG_CONFIG_PATH=$INSTALL_PREFIX/lib/pkgconfig
mkdir -p $SRC_DIR
mkdir -p $PKG_CONFIG_PATH
#
strip_spaces(){
echo $* | awk '$1=$1'
}
continue_or_exit(){
read -p "Continue installation? [y/N] " -r
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
}
install_dependencies(){
flavour_id=`cat /etc/*-release | egrep -i "^ID=" | cut -f 2 -d "="`
echo " Flavour: $flavour_id."
echo
if [ "$flavour_id" = "debian" ]; then
D_DEPENDENCIES="\
git build-essential autoconf apt-utils libtool \
libboost-all-dev pkg-config libcurl4-openssl-dev \
libleveldb-dev libconfig++-dev libncurses5-dev wget"
if [ "$ROOT_INSTALL" = 1 ]; then
apt-get -y remove libzmq*
apt-get -y install $D_DEPENDENCIES
else
echo "Run this command before continuing:"
echo
echo " sudo apt-get remove libzmq*"
echo " sudo apt-get -y install $(strip_spaces $D_DEPENDENCIES)"
echo
continue_or_exit
fi
elif [ "$flavour_id" = "ubuntu" ]; then
U_DEPENDENCIES="\
git build-essential autoconf apt-utils libtool \
pkg-config libcurl4-openssl-dev libleveldb-dev \
libconfig++8-dev libncurses5-dev libboost$U_BOOST-all-dev wget"
if [ "$ROOT_INSTALL" = 1 ]; then
apt-get -y remove libzmq*
# Ubuntu dependencies (some people have libboost1.53-dev installed,
# mine 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"
apt-get -y install $U_DEPENDENCIES
else
echo "Run this command before continuing:"
echo
echo " sudo apt-get remove libzmq*"
echo " sudo apt-get -y install $(strip_spaces $U_DEPENDENCIES)"
echo
continue_or_exit
fi
elif [ "$flavour_id" = "fedora" ]; then
F_DEPENDENCIES="\
gcc-c++ git autoconf libtool boost-devel pkgconfig \
libcurl-devel openssl-devel leveldb-devel libconfig \
libconfig-devel ncurses-devel wget"
if [ "$ROOT_INSTALL" = 1 ]; then
yum -y install $F_DEPENDENCIES
else
echo "Run this command before continuing:"
echo
echo "yum -y install $(strip_spaces $F_DEPENDENCIES)"
echo
continue_or_exit
fi
elif [ "$flavour_id" = "arch" ]; then
A_DEPENDENCIES="\
gcc git autoconf libtool boost pkg-config curl openssl \
leveldb libconfig ncurses wget"
if [ "$ROOT_INSTALL" = 1 ]; then
pacman -S --asdeps --needed --noconfirm $A_DEPENDENCIES
else
echo "Run this command before continuing:"
echo
echo "pacman -S --asdeps --needed --noconfirm $(strip_spaces $A_DEPENDENCIES)"
echo
continue_or_exit
fi
else
echo
echo " [+] ERROR: GNU/Linux flavour not supported: $flavour_id" 1>&2
echo
echo " Please, review the script."
echo
exit
fi
}
install_libsodium(){
cd $SRC_DIR
if [ -d "libsodium-git" ]; then
echo
echo " --> Updating libsodium..."
echo
cd libsodium-git
git remote set-url origin https://github.com/jedisct1/libsodium
git pull --rebase
else
echo
echo " --> Downloading libsodium from git..."
echo
git clone https://github.com/jedisct1/libsodium libsodium-git
fi
cd $SRC_DIR/libsodium-git
echo
echo " --> Beginning build process now...."
echo
./autogen.sh
./configure --prefix $INSTALL_PREFIX
make
make check
make install
$RUN_LDCONFIG
echo
echo " o/ libsodium now installed."
echo
}
install_libzmq(){
cd $SRC_DIR
if [ -d "zeromq-4.0.4" ]; then
echo
echo " --> Updating libzmq..."
echo
else
echo
echo " --> Downloading libzmq from git..."
echo
wget http://download.zeromq.org/zeromq-4.0.4.tar.gz
tar zxf zeromq-4.0.4.tar.gz
fi
cd $SRC_DIR/zeromq-4.0.4
echo
echo " --> Beginning build process now...."
echo
./autogen.sh
./configure --prefix $INSTALL_PREFIX --with-libsodium=$INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ libzmq now installed."
echo
}
install_czmq(){
cd $SRC_DIR
if [ -d "czmq-2.2.0" ]; then
echo
echo " --> Updating czmq..."
echo
else
echo
echo " --> Downloading czmq from git..."
echo
wget http://download.zeromq.org/czmq-2.2.0.tar.gz
tar zxf czmq-2.2.0.tar.gz
fi
cd $SRC_DIR/czmq-2.2.0
echo
echo " --> Beginning build process now...."
echo
./configure --prefix $INSTALL_PREFIX --with-libsodium=$INSTALL_PREFIX --with-libzmq=$INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ czmq now installed."
echo
}
install_libczmqpp(){
cd $SRC_DIR
if [ -d "czmqpp-git" ]; then
echo
echo " --> Updating czmq++..."
echo
cd czmqpp-git
git remote set-url origin https://github.com/zeromq/czmqpp
git pull --rebase
else
echo
echo " --> Downloading czmq++ from git..."
echo
git clone https://github.com/zeromq/czmqpp czmqpp-git
fi
cd $SRC_DIR/czmqpp-git
echo
echo " --> Beginning build process now...."
echo
autoreconf -i
./configure --prefix $INSTALL_PREFIX
make
make install
$RUN_LDCONFIG
echo
echo " o/ czmq++ now installed."
echo
}
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/libbitcoin/libbitcoin.git
git pull --rebase
else
echo
echo " --> Downloading libbitcoin from git..."
echo
git clone https://github.com/libbitcoin/libbitcoin.git libbitcoin-git
fi
cd $SRC_DIR/libbitcoin-git
echo
echo " --> Beginning 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/libbitcoin/libwallet.git
git pull --rebase
else
echo
echo " --> Downloading Libwallet from git..."
echo
git clone https://github.com/libbitcoin/libwallet.git libwallet-git
fi
cd $SRC_DIR/libwallet-git
echo
echo " --> Beginning 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/libbitcoin/obelisk.git
git pull --rebase
else
echo
echo " --> Downloading obelisk..."
echo
git clone https://github.com/libbitcoin/obelisk.git obelisk-git
fi
cd $SRC_DIR/obelisk-git
echo
echo " --> Beginning 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 " --> Beginning 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 an obelisk node, you will to run obworker."
echo " Run <sudo bash $SRC_DIR/obelisk-git/scripts/setup.sh> to create, configure and start the daemons."
echo
}
install_dependencies
install_libsodium
install_libzmq
install_czmq
install_libczmqpp
install_libbitcoin
install_libwallet
install_obelisk
install_sx
show_finish_install_info