forked from webvalley/fruitoscopy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
READ.ME
252 lines (158 loc) · 6.48 KB
/
READ.ME
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
To install the software on the Raspberry Pi you need to:
$ sudo apt-get install python-numpy python-scipy
$ sudo pip install flask scikit-learn
Follow the guide on http://elinux.org/RPI-Wireless-Hotspot to configure the Raspberry Pi as Hotspot (point n° 4 is not mandatory, since the raspberry server is made to work offline)
Clone the fruitoscopy repository (better in /home/pi/ )
git clone {{ insert here repository }}
Add to the /etc/rc.local these lines before the " exit 0 "
$ sudo ifconfig wlan0 192.168.42.1
$ sudo service udhcpd stop
$ sudo service udhcpd start
python /home/pi/fruitoscopy/rasp_app/main.py
(You have to execute the main.py that you have cloned from the GitHub repository, if the path where you have cloned the repo is different, use yours)
-------------------------------------
INSTALL GUNICORN AND NGINX
$ sudo apt-get install gunicorn nginx
#nano PROJ_PATH/wsgi.py
#__init__.py
$ sudo nano /usr/lib/systemd/system/rasp_app.service
[Unit]
Description=gunicorn daemon
Requires=rasp_app.sock
After=network.target
[Service]
PIDFile=/run/gunicorn/pid
User=root
Group=root
WorkingDirectory=/home/pi/fruitoscopy/rasp_app
ExecStart=/usr/local/bin/gunicorn --pid /run/gunicorn/pid wsgi
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
@@@@@@create /home/pi/fruitoscopy/rasp_app.sh
@@@@@@create /home/pi/gunicor_start.sh
$ sudo nano /usr/lib/systemd/system/rasp_app.sock
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn/socket
ListenStream=unix:rasp_app.sock
ListenStream=[::]:8000
[Install]
WantedBy=sockets.target
$ sudo chmod 660 /usr/lib/systemd/system/rasp_app.sock
$ sudo nano /etc/nginx/nginx.conf
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
$ sudo nano /etc/nginx/sites-available/rasp_app.conf
# Default server configuration
#
server {
listen 80;
root /var/www/html;
server_name fruitipy.fbk.eu;
location / {
include proxy_params;
proxy_pass http://127.0.0.1:8000;
}
}
$ sudo ln -s /etc/nginx/sites-available/rasp_app.conf /etc/nginx/sites-enabled/rasp_app.conf
$ sudo chmod 777 rasp_app.service
$ sudo chmod -R 777 /run/gunicorn/
$ sudo nano /etc/udhcpd.conf
# Sample udhcpd configuration file (/etc/udhcpd.conf)
# The start and end of the IP lease block
start 192.168.42.2 #default: 192.168.0.20
end 192.168.42.20 #default: 192.168.0.254
interface wlan0 #default: eth0
#max_leases 254 #default: 254
remaining yes #default: yes
#auto_time 7200 #default: 7200 (2 hours)
#decline_time 3600 #default: 3600 (1 hour)
#conflict_time 3600 #default: 3600 (1 hour)
#offer_time 60 #default: 60 (1 minute)
#min_lease 60 #defult: 60
#lease_file /var/lib/misc/udhcpd.leases #defualt: /var/lib/misc/udhcpd.leases
#pidfile /var/run/udhcpd.pid #default: /var/run/udhcpd.pid
#notify_file #default: (no script)
#notify_file dumpleases # <--- useful for debugging
#siaddr 192.168.0.22 #default: 0.0.0.0
#sname zorak #default: (none)
#boot_file /var/nfs_root #default: (none)
#Examles
opt dns 192.168.42.1
option subnet 255.255.255.0
opt router 192.168.42.1
opt wins 192.168.10.10
option dns 129.219.13.81 # appened to above DNS servers for a total of 3
option domain local
option lease 864000 # 10 days of seconds
-------------------------------------
INSTALL GUIDE FOR DNS REDIRECT TO fruitipy.fbk.eu
$ sudo apt-get install pdns-server dnsutils
$ sudo sed -i 's/# recursor=/recursor=8.8.8.8/g' /etc/powerdns/pdns.conf
$ sudo sed -i 's/allow-recursion=127.0.0.1/allow-recursion=127.0.0.1,192.168.0.0\/24/g' /etc/powerdns/pdns.conf
$ sudo service pdns restart
----> /etc/powerdns/bindbackend.conf
zone "fbk.eu" {
type master;
file "/etc/powerdns/bind/example.com.zone";
allow-update { none; };
};
$ sudo mkdir /etc/powerdns/bind
----> /etc/powerdns/bind/fbk.eu.zone
ORIGIN fbk.eu ; base for unqualified names
$TTL 1h ; default time-to-live
@ IN SOA ns.example.com hostmaster.example.com (
1; serial
1d; refresh
2h; retry
4w; expire
1h; minimum time-to-live
)
IN NS ns
IN A 192.168.42.1
ns IN A 192.168.42.1
fruitipy IN A 192.168.42.1
www IN CNAME fruitipy
$ sudo service pdns restart
$ sudo systemctl enable pdns.service
Francesco Ballerin - francesco@ballerin.it