forked from OpenBazaar/OpenBazaar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·212 lines (187 loc) · 5 KB
/
run.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
#!/bin/bash
# set -x
usage()
{
cat << EOF
usage: $0 options
This script starts up the OpenBazaar client and server.
OPTIONS:
-h Help information
-o Seed Mode
-i Server Public IP
-p Server Public Port (default 12345)
-k Web Interface IP (default 127.0.0.1; use 0.0.0.0 for any)
-q Web Interface Port (default random)
-l Log file
-d Development mode
-n Number of Dev nodes to start up
-a Bitmessage API username
-b Bitmessage API password
-c Bitmessage API port
-u Market ID
-j Disable upnp
-s List of additional seeds
EOF
}
PYTHON="./env/bin/python"
if [ ! -x $PYTHON ]; then
echo "No python executable found at ${PYTHON}"
if which python2 2>/dev/null; then
PYTHON=python2
elif which python 2>/dev/null; then
PYTHON=python
else
echo "No python executable found anywhere"
exit
fi
fi
if [[ "$OSTYPE" == "darwin"* ]]; then
export DYLD_LIBRARY_PATH=$(brew --prefix openssl)/lib:${DYLD_LIBRARY_PATH}
fi
# Default values
SERVER_PORT=12345
LOGDIR=logs
DBDIR=db
DBFILE=ob.db
DEVELOPMENT=0
SEED_URI='seed.openbazaar.org seed2.openbazaar.org seed.openlabs.co seed.bizarre.company'
LOG_FILE=production.log
DISABLE_UPNP=0
# CRITICAL 50
# ERROR 40
# WARNING 30
# INFO 20
# DEBUG 10
# NOTSET 0
LOG_LEVEL=10
NODES=3
BM_USERNAME=brian
BM_PASSWORD=P@ssw0rd
BM_PORT=8442
HTTP_IP=127.0.0.1
HTTP_PORT=-1
# Tor Information
# - If you enable Tor here you will be operating a hidden
# service behind your Tor proxy (notional)
TOR_ENABLE=0
TOR_CONTROL_PORT=9051
TOR_SERVER_PORT=9050
TOR_COOKIE_AUTHN=1
TOR_HASHED_CONTROL_PASSWORD=
TOR_PROXY_IP=127.0.0.1
TOR_PROXY_PORT=7000
while getopts "hp:l:dn:a:b:c:u:oi:jk:q:s:" OPTION
do
case ${OPTION} in
h)
usage
exit 1
;;
p)
SERVER_PORT=$OPTARG
;;
l)
LOG_FILE=$OPTARG
;;
d)
DEVELOPMENT=1
;;
n)
NODES=$OPTARG
;;
a)
BM_USERNAME=$OPTARG
;;
b)
BM_PASSWORD=$OPTARG
;;
c)
BM_PORT=$OPTARG
;;
u)
MARKET_ID=$OPTARG
;;
o)
SEED_MODE=1
;;
i)
SERVER_IP=$OPTARG
;;
j)
DISABLE_UPNP=1
;;
k)
HTTP_IP=$OPTARG
;;
q)
HTTP_PORT=$OPTARG
;;
s)
SEED_URI_ADD=$OPTARG
;;
?)
usage
exit
;;
esac
done
SEED_URI+=" $SEED_URI_ADD"
HTTP_OPTS="-k $HTTP_IP -q $HTTP_PORT"
if [ -z "$SERVER_IP" ]; then
SERVER_IP=$(wget -qO- icanhazip.com)
fi
if [ ! -d "$LOGDIR" ]; then
mkdir $LOGDIR
fi
if [ ! -d "$DBDIR" ]; then
mkdir $DBDIR
fi
if [ "$DISABLE_UPNP" == 1 ]; then
echo "Disabling upnp"
DISABLE_UPNP="--disable_upnp"
else
DISABLE_UPNP=""
fi
echo "OpenBazaar is starting..."
if [ "$SEED_MODE" == 1 ]; then
echo "Seed Mode $SERVER_IP"
if [ ! -f $DBDIR/$DBFILE ]; then
echo "File $DBFILE does not exist. Running setup script."
$PYTHON node/setup_db.py db/ob.db
wait
fi
$PYTHON node/tornadoloop.py $SERVER_IP $HTTP_OPTS -p $SERVER_PORT $DISABLE_UPNP -s 1 --bmuser $BM_USERNAME --bmpass $BM_PASSWORD --bmport $BM_PORT -l $LOGDIR/production.log -u 1 --log_level $LOG_LEVEL &
elif [ "$DEVELOPMENT" == 0 ]; then
echo "Production Mode"
if [ ! -f $DBDIR/$DBFILE ]; then
echo "File $DBFILE does not exist. Running setup script."
export PYTHONPATH=$PYTHONPATH:`pwd`
$PYTHON node/setup_db.py db/ob.db
wait
fi
$PYTHON node/tornadoloop.py $SERVER_IP $HTTP_OPTS -p $SERVER_PORT $DISABLE_UPNP --bmuser $BM_USERNAME --bmpass $BM_PASSWORD --bmport $BM_PORT -S $SEED_URI -l $LOGDIR/production.log -u 1 --log_level $LOG_LEVEL &
else
# Primary Market - No SEED_URI specified
echo "Development Mode"
if [ ! -f $DBDIR/ob-dev.db ]; then
echo "File $DBFILE does not exist. Running setup script."
export PYTHONPATH=$PYTHONPATH:`pwd`
$PYTHON node/setup_db.py db/ob-dev.db
wait
fi
$PYTHON node/tornadoloop.py 127.0.0.1 $HTTP_OPTS $DISABLE_UPNP --database db/ob-dev.db -s 1 --bmuser $BM_USERNAME -d --bmpass $BM_PASSWORD --bmport $BM_PORT -l $LOGDIR/development.log -u 1 --log_level $LOG_LEVEL &
((NODES=NODES+1))
i=2
while [[ $i -le $NODES ]]
do
sleep 2
if [ ! -f db/ob-dev-$i.db ]; then
echo "File db/ob-dev-$i.db does not exist. Running setup script."
export PYTHONPATH=$PYTHONPATH:`pwd`
$PYTHON node/setup_db.py db/ob-dev-$i.db
wait
fi
$PYTHON node/tornadoloop.py 127.0.0.$i $HTTP_OPTS $DISABLE_UPNP --database db/ob-dev-$i.db -d --bmuser $BM_USERNAME --bmpass $BM_PASSWORD --bmport $BM_PORT -S 127.0.0.1 -l $LOGDIR/development.log -u $i --log_level $LOG_LEVEL &
((i=i+1))
done
fi