forked from OpenBazaar/OpenBazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·330 lines (281 loc) · 10.8 KB
/
configure.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
#!/usr/bin/env bash
#
# configure.sh - Setup your OpenBazaar development environment in one step.
#
# If you are a Ubuntu or MacOSX user, and you've already checked out
# the OpenBazaar sourcecode from the git repository; you can try
# configuring/installing OpenBazaar by simply executing this script
# instead of following the build instructions in the OpenBazaar Wiki
# https://github.com/OpenBazaar/OpenBazaar/wiki/Build-Instructions
#
# This script will only get better as its tested on more development environments.
# If you can't modify it to make it better, please open an issue with a full
# error report at https://github.com/OpenBazaar/OpenBazaar/issues/new
#
#
UBUNTU_PACKAGES="python-pip build-essential rng-tools python-dev libjpeg-dev sqlite3 openssl alien libssl-dev python-virtualenv lintian libjs-jquery"
ARCH_PACKAGES="python2 python2-pip python2-virtualenv rng-tools libjpeg sqlite3 openssl"
RASPIARCH_PACKAGES="base-devel curl wget python2 python2-pip rng-tools libjpeg sqlite3 openssl libunistring"
RASPBIAN_PACKAGES="python-pip build-essential rng-tools alien openssl libssl-dev python-dev libjpeg-dev sqlite3 haveged"
PORTAGE_PACKAGES="dev-lang/python:2.7 dev-python/pip rng-tools gcc jpeg sqlite3 openssl dev-python/virtualenv"
FEDORA_PACKAGES="kernel-devel rng-tools openssl openssl-libs openssl-devel openjpeg openjpeg-devel make alien python2 python-pip python-virtualenv python-devel python-zmq zeromq3 zeromq3-devel pyOpenSSL"
SLACK_PACKAGES="python pysetuptools pip virtualenv rng-tools libjpeg sqlite openssl" # if you change this, check the installSlack function carefully
# exit on error
set -e
function command_exists {
# POSIX-compatible way to check if a command exists.
# usage: "if command_exists foo; then echo it exists; fi"
command -v "$1" > /dev/null
}
function make_env {
# Create a virtualenv for OpenBazaar.
# NOTE: we get env/bin/pip by doing this.
if [ ! -d "./env" ]; then
virtualenv --python=python2.7 env
fi
}
function brewDoctor {
if ! brew doctor; then
echo
echo "'brew doctor' did not exit cleanly! This may be okay. Read above."
echo
read -p "Press [Enter] to continue anyway or [ctrl + c] to exit and do what the doctor says..."
fi
}
function brewUpgrade {
echo "If your homebrew packages are outdated, we recommend upgrading them now. This may take some time."
echo "We will only upgrade the packages needed to run OpenBazaar"
read -r -p "Do you want to do this? [y/N] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]
then
if ! brew upgrade autoenv gpg openssl sqlite3 wget; then
echo
echo "There were errors when attempting 'brew upgrade', there could be issues with the installation of OpenBazaar."
echo
read -p "Press [Enter] to continue anyway or [ctrl + c] to exit and fix those errors."
fi
fi
}
function installMac {
ORIGINAL_CPPFLAGS=$CPPFLAGS
ORIGINAL_CXXFLAGS=$CXXFLAGS
ORIGINAL_DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
unset CPPFLAGS
unset CXXFLAGS
unset DYLD_LIBRARY_PATH
# Install brew if it is not installed, otherwise upgrade it.
if ! command_exists brew ; then
echo "Installing brew..."
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
else
echo "Updating, Upgrading and checking brew installation..."
brew update
brewDoctor
brewUpgrade
brew prune
fi
# Use brew's python 2.7, even if user has a system python.
# The brew version comes with pip and setuptools.
# If user already has brew installed python, then this won't do anything.
# Note we get pip for free by doing this, and can avoid future calls to sudo.
# brew convention abhors all things 'sudo' anyway.
brew install python
for dep in gpg sqlite3 wget openssl autoenv
do
if ! command_exists $dep ; then
brew install $dep
fi
done
# Install python's virtualenv if it is not installed.
if ! command_exists virtualenv ; then
pip install virtualenv
fi
make_env
# "To begin using the virtual environment, it needs to be activated:"
# http://docs.python-guide.org/en/latest/dev/virtualenvs/
# We have autoenv and an appropriate .env in our OB home dir,
# but we should activate the env just in case
# (e.g. for first time or non-Mac users).
source env/bin/activate
# Set compile flags for brew's openssl instead of using brew link --force
export CFLAGS="-I$(brew --prefix openssl)/include"
export LDFLAGS="-L$(brew --prefix openssl)/lib"
# Install python deps inside our virtualenv
./env/bin/pip install -r requirements.txt
# restore any previous build flags
export CPPFLAGS=$ORIGINAL_CPPFLAGS
export CXXFLAGS=$ORIGINAL_CXXFLAGS
export DYLD_LIBRARY_PATH=$ORIGINAL_DYLD_LIBRARY_PATH
}
function sudoMessage {
echo
echo "In order to install OpenBazaar, this script will install the following requirements in your system:"
echo " $*"
echo "Note: this script requires sudo for the installation."
echo
}
function doneMessage {
VERSION_FROM_CHANGELOG="$(head -1 changelog | awk '/openbazaar \(.*\..*\..*\)/ { print $2 }')"
echo
echo
echo
echo ' ____ ____ '
echo ' / __ \ | _ \ '
echo ' | | | |_ __ ___ _ __ | |_) | __ _ ______ _ __ _ _ __ '
echo ' | | | | _ \ / _ \ _ \ | _ < / _` |_ / _` |/ _` | __|'
echo ' | |__| | |_) | __/ | | | | |_) | (_| |/ / (_| | (_| | | '
echo ' \____/| .__/ \___|_| |_| |____/ \__,_/___\__,_|\__,_|_| '
echo ' | | '
echo ' |_| ' ##'
echo
echo " Release $VERSION_FROM_CHANGELOG"
echo
echo
echo "OpenBazaar configuration finished!"
echo "Run './openbazaar $1start; tail -F logs/production.log' to start OpenBazaar and output logs."
echo
echo
echo
}
function confirm {
# call with a prompt string or use a default Y
read -r -p "Are you sure? [Y/n] " response
if [[ $response =~ ^([yY][eE][sS]|[yY])$ ]]; then
return 0
else
return 1
fi
}
function installUbuntu {
sudoMessage ${UBUNTU_PACKAGES}
sudo apt-get --quiet update || echo 'apt-get update failed. Continuing...'
sudo apt-get --assume-yes install ${UBUNTU_PACKAGES}
make_env
./env/bin/pip install -r requirements.txt
}
function installArch {
sudoMessage ${ARCH_PACKAGES}
echo "Some packages and dependencies may fail to install if your package list is out of date."
echo "Would you like to upgrade your system now? "
if confirm ; then
sudo pacman --sync --refresh --sysupgrade
else
echo "Continuing."
fi
# sudo pacman --sync --needed base-devel
# Can conflict with multilib packages. Uncomment previous line if you don't already have base-devel installed
sudo pacman --sync --needed ${ARCH_PACKAGES}
make_env
./env/bin/pip install -r requirements.txt
}
function installRaspiArch {
sudoMessage ${RASPIARCH_PACKAGES}
# pacman --sync sudo
sudo pacman --sync --refresh
sudo pacman --sync --needed ${RASPIARCH_PACKAGES}
echo " "
echo "Notice : pip install requires 10~30 minutes to complete."
if confirm ; then
pip2 install -r requirements.txt
echo "Run OpenBazaar on Raspberry Pi Arch without HDMI/VideoOut"
echo "Type the following shell command to start."
echo " "
echo "IP=\$(/sbin/ifconfig eth0 | grep 'inet ' | awk '{print \$2}')"
echo "./openbazaar --disable-open-browser -k \$IP -q 8888 -p 12345 start; tail -F logs/production.log"
fi
}
function installRaspbian {
sudoMessage ${RASPBIAN_PACKAGES}
sudo apt-get --assume-yes install ${RASPBIAN_PACKAGES}
echo " "
echo "Notice : pip install requires 2~3 hours to complete."
if confirm ; then
sudo pip install --requirement requirements.txt
echo "Run OpenBazaar on Raspberry Pi Raspbian without HDMI/VideoOut"
echo "Type the following shell command to start."
echo " "
echo "IP=\$(/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print \$1}')"
echo "./openbazaar --disable-open-browser -k \$IP -q 8888 -p 12345 start; tail -F logs/production.log"
fi
}
function installPortage {
sudoMessage ${PORTAGE_PACKAGES}
sudo emerge --noreplace ${PORTAGE_PACKAGES}
make_env
./env/bin/pip install -r requirements.txt
}
function installFedora {
sudoMessage ${FEDORA_PACKAGES} bitcoin-release openssl-compat-bitcoin-libs
sudo yum --assumeyes install ${FEDORA_PACKAGES}
rpm --query bitcoin-release || sudo yum --assumeyes install http://linux.ringingliberty.com/bitcoin/f20/x86_64/bitcoin-release-1-6.noarch.rpm
sudo yum --assumeyes install openssl-compat-bitcoin-libs
make_env
./env/bin/pip install -r requirements.txt
}
function installSlack {
sudoMessage ${SLACK_PACKAGES}
sudo /usr/sbin/slackpkg update
if ! command_exists python; then
sudo /usr/sbin/slackpkg install python
fi
if [ ! -f /usr/sbin/sbopkg ]; then
echo "Please install sbopkg for ease of dependency installation from sbopkgs. "
"Be sure to run sbopkg and sync before retrying this install."
exit 1
else
if ! command_exists pip; then
sudo /usr/sbin/sbopkg -i pysetuptools # Required for pip
sudo /usr/sbin/sbopkg -i pip
fi
sudo pip install virtualenv
wget http://sourceforge.net/projects/gkernel/files/rng-tools/5/rng-tools-5.tar.gz
tar -xvf rng-tools-5.tar.gz
pushd rng-tools-5
./configure
make
sudo make install
popd
sudo /usr/sbin/slackpkg install libjpeg sqlite openssl
fi
make_env
./env/bin/pip install -r requirements.txt
}
echo "Detecting OS..."
if [[ $OSTYPE == darwin* ]] ; then
echo "Found OS X"
installMac
# There are still pysqlcipher issues on OS X.
# Suggest disabling sqlite-crypt until that is resolved.
doneMessage "--disable-sqlite-crypt "
elif [[ $OSTYPE == linux-gnu || $OSTYPE == linux-gnueabihf ]]; then
UNAME=$(uname -a)
echo "Found Linux (${UNAME})"
if [ -f /etc/arch-release ]; then
if [[ "$UNAME" =~ alarmpi ]]; then
echo "Found distribution Raspberry Pi Arch Linux"
installRaspiArch "$@"
else
echo "Found distribution Arch Linux"
installArch
fi
elif [ -f /etc/manjaro-release ]; then
echo "Found distribution Arch Linux"
installArch
elif [ -f /etc/gentoo-release ]; then
echo "Found distribution Gentoo"
installPortage
elif [ -f /etc/fedora-release ]; then
echo "Found distribution Fedora"
installFedora
elif [ -f /etc/slackware-version ]; then
echo "Found distribution Slack"
installSlack
elif grep Raspbian /etc/os-release ; then
echo "Found distribution Raspberry Pi Raspbian"
installRaspbian "$@"
else
echo "Found distribution Ubuntu or other"
installUbuntu
fi
doneMessage
fi