forked from OpenBazaar/OpenBazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·289 lines (251 loc) · 9.6 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
#!/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
#
#
# 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 {
# 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..."
ORIGINAL_CPPFLAGS=$CPPFLAGS
export CPPFLAGS=
brew update
brewDoctor
brewUpgrade
brew prune
export CPPFLAGS=$ORIGINAL_CPPFLAGS
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 zmq 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
}
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 installUbuntu {
sudo apt-get --quiet update || echo 'apt-get update failed. Continuing...'
sudo apt-get --assume-yes install python-pip build-essential python-zmq rng-tools \
python-dev libjpeg-dev sqlite3 openssl \
alien libssl-dev python-virtualenv lintian libjs-jquery
make_env
./env/bin/pip install -r requirements.txt
}
function installArch {
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 python2 python2-pip python2-virtualenv python2-pyzmq rng-tools libjpeg sqlite3 openssl
make_env
./env/bin/pip install -r requirements.txt
}
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 installRaspiArch {
# pacman --sync sudo
sudo pacman --sync --refresh
sudo pacman --sync --needed base-devel curl wget python2 python2-pip rng-tools libjpeg sqlite3 openssl libunistring
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 {
sudo apt-get --assume-yes install python-pip build-essential rng-tools alien \
openssl libssl-dev python-dev libjpeg-dev sqlite3
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 {
sudo emerge --noreplace dev-lang/python:2.7 dev-python/pip pyzmq rng-tools gcc jpeg sqlite3 openssl dev-python/virtualenv
make_env
./env/bin/pip install -r requirements.txt
}
function installFedora {
sudo yum --assumeyes install kernel-devel rng-tools openssl openssl-libs openssl-devel openjpeg openjpeg-devel make alien
sudo yum --assumeyes install python2 python-pip python-virtualenv python-devel python-zmq zeromq3 zeromq3-devel pyOpenSSL
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 {
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
PYZVAR=$(grep "pyzmq" requirements.txt) # Get pip version.
/usr/bin/pip install --user "$PYZVAR"
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
}
if [[ $OSTYPE == darwin* ]] ; then
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)
if [ -f /etc/arch-release ]; then
if [[ "$UNAME" =~ alarmpi ]]; then
echo "$UNAME"
echo Found Raspberry Pi Arch Linux
installRaspiArch "$@"
else
installArch
fi
elif [ -f /etc/manjaro-release ]; then
installArch
elif [ -f /etc/gentoo-release ]; then
installPortage
elif [ -f /etc/fedora-release ]; then
installFedora
elif [ -f /etc/slackware-version ]; then
installSlack
elif grep Raspbian /etc/os-release ; then
echo Found Raspberry Pi Raspbian
installRaspbian "$@"
else
installUbuntu
fi
doneMessage
fi