-
Notifications
You must be signed in to change notification settings - Fork 19
/
install.sh
executable file
·357 lines (331 loc) · 11.2 KB
/
install.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
#!/bin/bash
#
# A simple bash script to install darkwallet desktop client at localhost.
#
# You should not run the script as root. Just run as normal user.
# $ bash darkwallet_desktop.sh
#
# sudo should only be used to install dependences.
#
unset LANG
FIRST_INSTALL=true
# check if are running as root. You shoul avoid starting this script as sudo or root.
WHOAMI(){
if [[ $(id -u) -ne 0 ]] ; then
echo "[+] Check if sudo or root: OK..."
else
echo "You shoul avoid starting this script as sudo or root."
echo "Just run as normal user."
echo " $ bash dw-desktop-dev.sh"
exit 1
fi
}
# Installing dependences to download, compile and install libbitcoin. NPM, python3, sqlipher and pip3 are also needed.
DEPENDENCIES(){
sudo apt -y install build-essential autoconf automake libtool pkg-config git libboost-all-dev npm tor torsocks libpython3.5 libpython3.5-dev sqlcipher libsqlcipher-dev python3-pip libffi-dev python3-pycparser dh-autoreconf
}
# Create directory for local installation. Setting variables: DW_DSKTP | DW_LOG
# Another install path can be used changing DW_DSKTP variable (example: changing "export DW_DSKTP=$HOME/darkwallet_desktop" by "export DW_DSKTP=$HOME/workspace/darkwallet").
DW_CREATE_DIR(){
DW_DSKTP=$HOME/darkwallet_desktop
DW_LOG=$DW_DSKTP/debug.log
if [ ! -d $DW_DSKTP ]; then
mkdir -p $DW_DSKTP
touch $DW_LOG
else
echo "$DW_DSKTP exists. Leaving withot changes."
FIRST_INSTALL=false
fi
}
# Create directiory for local installation. Setting environment variables: PKG_CONFIG_PATH | LD_LIBRARY_PATH | USR_LOCAL_PATH
# Change "USR_LOCAL_PATH" to select a different path. (example: changing "export USR_LOCAL_PATH=$DW_DSKTP/usr" to "export USR_LOCAL_PATH=$HOME/usr")
USR_LOCAL_ENV(){
DW_DSKTP=$HOME/darkwallet_desktop
if [ ! -d $DW_DSKTP/usr ]; then
mkdir -p $DW_DSKTP/usr
USR_LOCAL_PATH=$DW_DSKTP/usr
PKG_CONFIG_PATH=$USR_LOCAL_PATH/lib/pkgconfig/
LD_LIBRARY_PATH=$USR_LOCAL_PATH/lib
elif [ -d $DW_DSKTP/usr ]; then
USR_LOCAL_PATH=$DW_DSKTP/usr
PKG_CONFIG_PATH=$USR_LOCAL_PATH/lib/pkgconfig/
LD_LIBRARY_PATH=$USR_LOCAL_PATH/lib
echo "$USR_LOCAL_PATH exists. Leaving withot changes."
else
exit 1
fi
}
# Install libsodium from https://github.com/jedisct1/libsodium.git
INSTALL_SODIUM(){
echo "INSTALL_SODIUM" >> $DW_LOG
echo "INSTALL_SODIUM"
if [ ! -d $DW_DSKTP/libsodium ]; then
cd $DW_DSKTP
git clone https://github.com/jedisct1/libsodium.git
cd $DW_DSKTP/libsodium
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH >> $DW_LOG
make -j2 install >> $DW_LOG
elif [ -d $DW_DSKTP/libsodium ]; then
echo "libsodium found. Leave without change."
else
exit 1
fi
}
# Install libsecp256k1 from bitcoin-core:
INSTALL_secp256k1(){
echo "INSTALL_secp256k1" >> $DW_LOG
echo "INSTALL_secp256k1"
if [ ! -d $DW_DSKTP/secp256k1 ]; then
cd $DW_DSKTP
git clone https://github.com/bitcoin-core/secp256k1.git
cd $DW_DSKTP/secp256k1
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH --enable-module-recovery >> $DW_LOG
make -j2 install >> $DW_LOG
elif [ -d $DW_DSKTP/secp256k1 ]; then
echo "libsecp256k1 found. Leave without change."
else
exit 1
fi
}
# Install/Update libbitcoin:
INSTALL_LIBITCOIN(){
echo "INSTALL_LIBITCOIN" >> $DW_LOG
echo "INSTALL_LIBITCOIN"
if [ ! -d $DW_DSKTP/libbitcoin ]; then
cd $DW_DSKTP
git clone https://github.com/libbitcoin/libbitcoin.git
cd $DW_DSKTP/libbitcoin
# Checkout recent commit of libbitcoin that works
# with libbitcoin-c
git checkout f9ff27a2
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH >> $DW_LOG
make -j2 install >> $DW_LOG
elif [ -d $DW_DSKTP/libbitcoin ]; then
rm -rf $DW_DSKTP/libbitcoin
cd $DW_DSKTP
git clone https://github.com/libbitcoin/libbitcoin.git
cd $DW_DSKTP/libbitcoin
git checkout f9ff27a2b
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH >> $DW_LOG
make -j2 install >> $DW_LOG
else
exit 1
fi
}
# Install/Update libbitcoin-c:
INSTALL_LIBBITCOINC(){
echo "INSTALL_LIBBITCOINC" >> $DW_LOG
echo "INSTALL_LIBBITCOINC"
if [ ! -d $DW_DSKTP/libbitcoin-c ]; then
cd $DW_DSKTP
git clone https://github.com/libbitcoin/libbitcoin-c.git
cd $DW_DSKTP/libbitcoin-c
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH >> $DW_LOG
make -j2 install >> $DW_LOG
elif [ -d $DW_DSKTP/libbitcoin-c ]; then
rm -rf $DW_DSKTP/libbitcoin-c
cd $DW_DSKTP
git clone https://github.com/libbitcoin/libbitcoin-c.git
cd $DW_DSKTP/libbitcoin-c
./autogen.sh >> $DW_LOG
./configure --prefix $USR_LOCAL_PATH >> $DW_LOG
make -j2 install >> $DW_LOG
else
exit 1
fi
}
# Install/Update python-libbitcoin:
INSTALL_PY_LIBBTC(){
echo "INSTALL_PY_LIBBTC" >> $DW_LOG
echo "INSTALL_PY_LIBBTC"
if [ ! -d $DW_DSKTP/python-libbitcoin ]; then
cd $DW_DSKTP
git clone https://github.com/libbitcoin/python-libbitcoin.git
cd $DW_DSKTP/python-libbitcoin/libbitcoin/bc
python3 bc_build.py >> $DW_LOG
export PYTHONPATH=$DW_DSKTP/python-libbitcoin
elif [ $DW_DSKTP/python-libbitcoin ]; then
unset PYTHONPATH
rm -rf $DW_DSKTP/python-libbitcoin
cd $DW_DSKTP
git clone https://github.com/libbitcoin/python-libbitcoin.git
cd $DW_DSKTP/python-libbitcoin
cd $DW_DSKTP/python-libbitcoin/libbitcoin/bc
python3 bc_build.py >> $DW_LOG
export PYTHONPATH=$DW_DSKTP/python-libbitcoin
else
exit 1
fi
}
# Python dependencies:---------------------------------------
# Install python cffi 1.9.1.
INSTALL_PY_CFFI(){
echo "INSTALL_PY_CFFI" >> $DW_LOG
echo "INSTALL_PY_CFFI"
sudo pip3 install cffi
}
# Install pyzmq:
INSTALL_PYZMQ(){
echo "INSTALL_PYZMQ" >> $DW_LOG
echo "INSTALL_PYZMQ"
sudo pip3 install pyzmq >> $DW_LOG
}
# Install python tornado:
INSTALL_TORNADO(){
echo "INSTALL_TORNADO" >> $DW_LOG
echo "INSTALL_TORNADO"
sudo pip3 install tornado >> $DW_LOG
}
# Install python websockets:
INSTALL_WEBSOCKETS(){
echo "INSTALL_WEBSOCKETS" >> $DW_LOG
echo "INSTALL_WEBSOCKETS"
sudo pip3 install websockets >> $DW_LOG
}
# Install pysqlcipher:
INSTALL_PYSQLCIPHER(){
echo "INSTALL_PYSQLCIPHER" >> $DW_LOG
echo "INSTALL_PYSQLCIPHER"
sudo pip3 install pysqlcipher3 >> $DW_LOG
}
# Install python peewee:
INSTALL_PEEWEE(){
echo "INSTALL_PEEWEE" >> $DW_LOG
echo "INSTALL_PEEWEE"
sudo pip3 install peewee >> $DW_LOG
}
#-----------------------------------------------------------
# Install/Update darkwallet daemon:
INSTALL_DARKWALLET(){
echo "INSTALL_DARKWALLET" >> $DW_LOG
echo "INSTALL_DARKWALLET"
if [ ! -d $DW_DSKTP/darkwallet ]; then
cd $DW_DSKTP
git clone https://github.com/DissentDifference/DarkWallet.git
mv $DW_DSKTP/DarkWallet $DW_DSKTP/darkwallet
elif [ -d $DW_DSKTP/darkwallet ]; then
rm $DW_DSKTP/darkwallet
cd $DW_DSKTP
git clone https://github.com/DissentDifference/DarkWallet.git
mv $DW_DSKTP/DarkWallet $DW_DSKTP/darkwallet
else
exit 1
fi
}
# Install/update darkwallet electron-ui
INSTALL_ELECTRON_GUI(){
echo "INSTALL_ELECTRON_GUI" >> $DW_LOG
echo "INSTALL_ELECTRON_GUI"
if [ ! -d $DW_DSKTP/darkwallet-electron-ui ]; then
cd $DW_DSKTP
git clone https://github.com/thirdicrypto/darkwallet-electron-ui.git
cd $DW_DSKTP/darkwallet-electron-ui
npm install
npm install immutability-helper ws bufferutil utf-8-validate
elif [ -d $DW_DSKTP/darkwallet-electron-ui ]; then
rm $DW_DSKTP/darkwallet-electron-ui
cd $DW_DSKTP
git clone https://github.com/thirdicrypto/darkwallet-electron-ui.git
cd $DW_DSKTP/darkwallet-electron-ui
npm install
npm install immutability-helper ws bufferutil utf-8-validate
else
exit 1
fi
}
# Include a darkwallet.desktop Icon to ~/.local:
INCLUDE_0(){
mkdir -p $HOME/.local/share/icons/hicolor/128x128/
cp $DW_DSKTP/darkwallet-electron-ui/resources/images/icon_128.png $HOME/.local/share/icons/hicolor/128x128/darkwallet_icon_128.png
mkdir -p $HOME/.local/share/applications
touch $HOME/.local/share/applications/darkwallet.desktop
DESKTOP_FILE=$HOME/.local/share/applications/darkwallet.desktop
echo "[Desktop Entry]" > $DESKTOP_FILE
echo "Version=1.0" >> $DESKTOP_FILE
echo "Name=Darkwallet" >> $DESKTOP_FILE
echo "Comment=Darkwallet - the bitcoin power wallet." >> $DESKTOP_FILE
echo "Exec=$DW_DSKTP/run.sh" >> $DESKTOP_FILE
echo "Path=$DW_DSKTP" >> $DESKTOP_FILE
echo "Icon=$HOME/.local/share/icons/hicolor/128x128/darkwallet_icon_128.png" >> $DESKTOP_FILE
echo "Terminal=false" >> $DESKTOP_FILE
echo "Type=Application" >> $DESKTOP_FILE
echo "Categories=Utility;Application;Development;Internet;Bitcoin;" >> $DESKTOP_FILE
chmod +x $DESKTOP_FILE
touch $DW_DSKTP/run.sh
RUNSH=$DW_DSKTP/run.sh
echo "#!/bin/bash" > $RUNSH
echo "# Script to start DW desktop" >> $RUNSH
echo "" >> $RUNSH
echo "EXPORT_VARS(){" >> $RUNSH
echo " export PKG_CONFIG_PATH=$USR_LOCAL_PATH/lib/pkgconfig/" >> $RUNSH
echo " export LD_LIBRARY_PATH=$USR_LOCAL_PATH/lib" >> $RUNSH
echo " export PYTHONPATH=$DW_DSKTP/python-libbitcoin" >> $RUNSH
echo "}" >> $RUNSH
echo "" >> $RUNSH
echo "START_DAEMON(){" >> $RUNSH
echo " python3 $DW_DSKTP/darkwallet/darkwallet-daemon.py &" >> $RUNSH
echo "}" >> $RUNSH
echo "" >> $RUNSH
echo "START_WALLET(){" >> $RUNSH
echo " cd $DW_DSKTP/darkwallet-electron-ui" >> $RUNSH
echo " npm run dev" >> $RUNSH
echo "}" >> $RUNSH
echo "" >> $RUNSH
echo "DAEMON_MUST_DIE(){" >> $RUNSH
echo " DMD=$(ps -aux | grep darkwallet-daemon.py | grep -v grep | awk '{print $2}')"
echo " kill -SIGINT $(echo $DMD)" >> $RUNSH
echo "}" >> $RUNSH
echo "" >> $RUNSH
echo "EXPORT_VARS" >> $RUNSH
echo "START_DAEMON" >> $RUNSH
echo " if [ $? = "0" ];then" >> $RUNSH
echo " START_WALLET" >> $RUNSH
echo " else" >> $RUNSH
echo " echo \'error\'" >> $RUNSH
echo " exit 1" >> $RUNSH
echo " fi" >> $RUNSH
echo "DAEMON_MUST_DIE" >> $RUNSH
chmod +x $RUNSH
}
# Finish :D
FINISH(){
echo "FINISH" >> $DW_LOG
echo ""
echo "[+] Logs at $DW_LOG"
echo ""
}
# Run installation script:
WHOAMI
DW_CREATE_DIR
USR_LOCAL_ENV
if [ $FIRST_INSTALL == true ]; then
DEPENDENCIES
INSTALL_PY_CFFI
INSTALL_PYZMQ
INSTALL_TORNADO
INSTALL_WEBSOCKETS
INSTALL_PYSQLCIPHER
INSTALL_PEEWEE
INSTALL_SODIUM
INSTALL_secp256k1
INSTALL_LIBITCOIN
INSTALL_LIBBITCOINC
INSTALL_PY_LIBBTC
INSTALL_DARKWALLET
INSTALL_ELECTRON_GUI
INCLUDE_0
FINISH
else
INSTALL_LIBITCOIN
INSTALL_LIBBITCOINC
INSTALL_PY_LIBBTC
INSTALL_DARKWALLET
INSTALL_ELECTRON_GUI
FINISH
fi
exit 0