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
|
diff -r -U1 open-av4ms.raspbian.python2/debian/postinst open-av4ms.arch.python2/debian/postinst
--- open-av4ms.raspbian.python2/debian/postinst 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/debian/postinst 2023-01-09 17:18:22.169287768 +0100
@@ -21,32 +21,33 @@
configure)
- adduser www-data dialout
+ addgroup --system av4ms-server
+ adduser --system --ingroup av4ms-server av4ms-server
update-rc.d av4server defaults
- update-rc.d webserver defaults
+ update-rc.d av4webserver defaults
# Falls noch keine Passwort-Datei vorhanden, dann erzeugen
- if [ ! -f /home/www/Password.py ]; then
+ if [ ! -f /usr/share/open-av4ms/Password.py ]; then
echo "Erzeuge Passwort-Datei für Webserver"
- echo "Bitte /home/www/Password.py ggf. anpassen"
- mv -f /home/www/Password.py.dist /home/www/Password.py
+ echo "Bitte /usr/share/open-av4ms/Password.py ggf. anpassen"
+ mv -f /usr/share/open-av4ms/Password.py.dist /usr/share/open-av4ms/Password.py
fi
# Logverzeichnis anlegen
- if [ ! -d /var/log/av4server ]; then
- mkdir -p /var/log/av4server
- chown www-data /var/log/av4server
+ if [ ! -d /var/log/open-av4ms/av4server ]; then
+ mkdir -p /var/log/open-av4ms/av4server
+ chown av4ms-server:av4ms-server /var/log/open-av4ms/av4server
fi
# Aufzeichnungsverzeichnis anlegen
- if [ ! -d /home/www/av4logs ]; then
- mkdir /home/www/av4logs
+ if [ ! -d /var/log/open-av4ms/av4logs ]; then
+ mkdir /var/log/open-av4ms/av4logs
+ chown av4ms-server:av4ms-server /var/log/open-av4ms/av4logs
fi
# Shutdown für www-data ohne Passwort erlauben
- if fgrep -q 'www-data ALL= NOPASSWD: /sbin/shutdown' /etc/sudoers; then
+ if fgrep -q 'av4ms-server ALL= NOPASSWD: /sbin/shutdown' /etc/sudoers; then
:
else
- echo 'www-data ALL= NOPASSWD: /sbin/shutdown' >>/etc/sudoers
+ echo 'av4ms-server ALL= NOPASSWD: /sbin/shutdown' >>/etc/sudoers
fi
# Bytecompile aller Pythonscripte
- python -m py_compile /home/www/*.py
- chown -R www-data /home/www
+ python -m py_compile "/usr/lib/python$(python --version | awk '{print $2}' | awk -F. '{print $1"."$2}')/site-packages/open-av4ms"/*.py
# Server starten
service av4server start
- service webserver start
+ service av4webserver start
;;
@@ -56,3 +57,6 @@
;;
-
+ pre-remove)
+ delgroup av4ms-server
+ deluser av4ms-server
+ ;;
*)
diff -r -U1 open-av4ms.raspbian.python2/etc/av4server.conf open-av4ms.arch.python2/etc/av4server.conf
--- open-av4ms.raspbian.python2/etc/av4server.conf 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/av4server.conf 2023-01-09 17:18:22.169287768 +0100
@@ -2,3 +2,3 @@
device = /dev/ttyUSB0
-logdir = /home/www/av4logs
+logdir = /var/log/open-av4ms/av4logs
logfile = AV4.csv
@@ -6,2 +6,2 @@
compress = true
-rawrecord = false
\ No newline at end of file
+rawrecord = false
diff -r -U1 open-av4ms.raspbian.python2/etc/cron.weekly/av4ms-version open-av4ms.arch.python2/etc/cron.weekly/av4ms-version
--- open-av4ms.raspbian.python2/etc/cron.weekly/av4ms-version 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/cron.weekly/av4ms-version 2023-01-09 17:18:22.169287768 +0100
@@ -4,6 +4,5 @@
#
-wget -q --tries=10 --timeout=20 -O /home/www/static/av4vers.js 'http://av4ms.fahrner.name/js/av4vers.js'
+wget -q --tries=10 --timeout=20 -O /usr/share/open-av4ms/static/av4vers.js 'http://av4ms.fahrner.name/js/av4vers.js'
if [[ $? -eq 0 ]]; then
- chown www-data:www-data /home/www/static/av4vers.js
+ chown av4ms-server:av4ms-server /usr/share/open-av4ms/static/av4vers.js
fi
-
diff -r -U1 open-av4ms.raspbian.python2/etc/init.d/av4server open-av4ms.arch.python2/etc/init.d/av4server
--- open-av4ms.raspbian.python2/etc/init.d/av4server 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/init.d/av4server 2023-01-09 17:18:22.169287768 +0100
@@ -15,6 +15,6 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/home/www/av4server.py
+DAEMON=/usr/lib/open-av4ms/av4server.py
NAME=av4server
-DESC="av4 server"
-PIDFILE=/tmp/$NAME.pid
+DESC="AV4ms server"
+PIDFILE=/run/open-av4ms/av4server/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
diff -r -U1 open-av4ms.raspbian.python2/etc/init.d/pilocator open-av4ms.arch.python2/etc/init.d/pilocator
--- open-av4ms.raspbian.python2/etc/init.d/pilocator 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/init.d/pilocator 2023-01-09 17:18:22.169287768 +0100
@@ -15,6 +15,6 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/home/www/pilocatord.py
+DAEMON=/usr/lib/pilocator/pilocatord.py
NAME=pilocator
DESC="pilocator"
-PIDFILE=/tmp/$NAME.pid
+PIDFILE=/run/pilocator/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
diff -r -U1 open-av4ms.raspbian.python2/etc/init.d/webserver open-av4ms.arch.python2/etc/init.d/webserver
--- open-av4ms.raspbian.python2/etc/init.d/webserver 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/init.d/webserver 2023-01-09 17:18:22.169287768 +0100
@@ -2,3 +2,3 @@
### BEGIN INIT INFO
-# Provides: webserver
+# Provides: av4webserver
# Required-Start: $syslog $remote_fs $network
@@ -15,6 +15,6 @@
PATH=/sbin:/bin:/usr/sbin:/usr/bin
-DAEMON=/home/www/webserver.py
-NAME=webserver
-DESC="web server"
-PIDFILE=/tmp/$NAME.pid
+DAEMON=/usr/lib/open-av4ms/av4webserver.py
+NAME=av4webserver
+DESC="AV4ms web server"
+PIDFILE=/run/open-av4ms/av4server/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
diff -r -U1 open-av4ms.raspbian.python2/etc/logrotate.d/av4server open-av4ms.arch.python2/etc/logrotate.d/av4server
--- open-av4ms.raspbian.python2/etc/logrotate.d/av4server 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/etc/logrotate.d/av4server 2023-01-09 17:18:22.169287768 +0100
@@ -1,2 +1,2 @@
-/var/log/av4server/*.log {
+/var/log/open-av4ms/av4server/*.log {
weekly
@@ -5,3 +5,3 @@
compress
- delaycompress
+ delaycompress
notifempty
diff -r -U1 open-av4ms.raspbian.python2/home/www/av4analyse.py open-av4ms.arch.python2/home/www/av4analyse.py
--- open-av4ms.raspbian.python2/home/www/av4analyse.py 2023-01-09 17:35:29.509255632 +0100
+++ open-av4ms.arch.python2/home/www/av4analyse.py 2023-01-09 17:18:22.179287768 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
diff -r -U1 open-av4ms.raspbian.python2/home/www/av4logbuch.py open-av4ms.arch.python2/home/www/av4logbuch.py
--- open-av4ms.raspbian.python2/home/www/av4logbuch.py 2023-01-09 17:35:28.329255669 +0100
+++ open-av4ms.arch.python2/home/www/av4logbuch.py 2023-01-09 17:18:22.179287768 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
diff -r -U1 open-av4ms.raspbian.python2/home/www/av4server.py open-av4ms.arch.python2/home/www/av4server.py
--- open-av4ms.raspbian.python2/home/www/av4server.py 2023-01-09 17:35:27.129255707 +0100
+++ open-av4ms.arch.python2/home/www/av4server.py 2023-01-09 17:37:53.359251133 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
@@ -21,2 +21,3 @@
+sys.path.append('/usr/lib/python'+str(sys.version_info.major)+'.'+str(sys.version_info.minor)+'/site-packages/open-av4ms')
from av4analyse import Messwert, Analyse
@@ -25,3 +26,3 @@
-sys.path.insert(0, '/home/www/odslib')
+sys.path.append('/usr/lib/python'+str(sys.version_info.major)+'.'+str(sys.version_info.minor)+'/site-packages/open-av4ms/odslib')
import odslib
@@ -88,3 +89,3 @@
config = ConfigParser.RawConfigParser()
- config.read('/etc/av4server.conf')
+ config.read('/etc/open-av4ms/av4server.conf')
self.DeviceName = config.get('av4server','device')
@@ -264,3 +265,3 @@
fn = fn[:-4]
- fn = '/home/www/av4logs/' + fn + '.ods'
+ fn = '/var/log/open-av4ms/av4server/av4logs' + fn + '.ods'
@@ -523,37 +524,37 @@
global logger
- try:
- locale.setlocale(locale.LC_ALL, '')
- logger = logging.getLogger('av4server')
- hdlr = logging.handlers.TimedRotatingFileHandler('/var/log/av4server/av4server.log',\
- when='midnight',backupCount=7)
- formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
- hdlr.setFormatter(formatter)
- logger.addHandler(hdlr)
- logger.setLevel(logging.INFO)
-
- #Warten bis Netzwerk bereit ist
- logger.info("Waiting for Network")
- WaitForNetwork()
-
- # Pyro Server starten
- logger.info("Init Pyro Server")
- Pyro.core.initServer()
- logger.info("Initiate Pyro Daemon")
- pyrodaemon = Pyro.core.Daemon()
- logger.info("Connect to Pyro Daemon")
- uri=pyrodaemon.connect(AV4Server(),'AV4Server')
-
- # enter the service loop.
- print 'AV4Server is ready.'
- print 'The URI is: ',uri
-
- logger.info('The URI is: ' + uri.__str__())
- pyrodaemon.requestLoop()
- except SystemExit:
- sys.exit()
- except:
- f = open('/tmp/av4server.trace','w')
- traceback.print_exc(file=f)
- f.close()
- sys.exit()
+ # try: # Switch off exception handling, in order to be thrown an error to the terminal.
+ locale.setlocale(locale.LC_ALL, '')
+ logger = logging.getLogger('av4server')
+ hdlr = logging.handlers.TimedRotatingFileHandler('/var/log/open-av4ms/av4server/av4server.log',\
+ when='midnight',backupCount=7)
+ formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
+ hdlr.setFormatter(formatter)
+ logger.addHandler(hdlr)
+ logger.setLevel(logging.INFO)
+
+ #Warten bis Netzwerk bereit ist
+ logger.info("Waiting for Network")
+ WaitForNetwork()
+
+ # Pyro Server starten
+ logger.info("Init Pyro Server")
+ Pyro.core.initServer()
+ logger.info("Initiate Pyro Daemon")
+ pyrodaemon = Pyro.core.Daemon()
+ logger.info("Connect to Pyro Daemon")
+ uri=pyrodaemon.connect(AV4Server(),'AV4Server')
+
+ # enter the service loop.
+ print 'AV4Server is ready.'
+ print 'The URI is: ',uri
+
+ logger.info('The URI is: ' + uri.__str__())
+ pyrodaemon.requestLoop()
+ # except SystemExit:
+ # sys.exit()
+ # except:
+ # f = open('/tmp/av4server.trace','w')
+ # traceback.print_exc(file=f)
+ # f.close()
+ # sys.exit()
@@ -571,3 +572,3 @@
umask=0o002,
- pidfile = PidFile("/tmp/av4server.pid"),
+ pidfile = PidFile("/run/open-av4ms/av4server/av4server.pid"),
files_preserve = [sys.stdout,sys.stderr]
diff -r -U1 open-av4ms.raspbian.python2/home/www/odslib/odslib.py open-av4ms.arch.python2/home/www/odslib/odslib.py
--- open-av4ms.raspbian.python2/home/www/odslib/odslib.py 2023-01-09 17:35:43.179255205 +0100
+++ open-av4ms.arch.python2/home/www/odslib/odslib.py 2023-01-09 17:18:22.179287768 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
diff -r -U1 open-av4ms.raspbian.python2/home/www/Pages.py open-av4ms.arch.python2/home/www/Pages.py
--- open-av4ms.raspbian.python2/home/www/Pages.py 2023-01-09 17:35:25.599255755 +0100
+++ open-av4ms.arch.python2/home/www/Pages.py 2023-01-09 17:18:22.179287768 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
diff -r -U1 open-av4ms.raspbian.python2/home/www/Status.py open-av4ms.arch.python2/home/www/Status.py
--- open-av4ms.raspbian.python2/home/www/Status.py 2023-01-09 17:35:23.129255832 +0100
+++ open-av4ms.arch.python2/home/www/Status.py 2023-01-09 17:18:22.179287768 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
diff -r -U1 open-av4ms.raspbian.python2/home/www/webserver.py open-av4ms.arch.python2/home/www/webserver.py
--- open-av4ms.raspbian.python2/home/www/webserver.py 2023-01-09 17:35:18.939255963 +0100
+++ open-av4ms.arch.python2/home/www/webserver.py 2023-01-09 17:28:16.349269182 +0100
@@ -1,2 +1,2 @@
-#!/usr/bin/env python
+#!/usr/bin/env python2
#-*-coding: utf-8 -*-
@@ -5,6 +5,10 @@
from os import curdir, sep
+import pwd
+import grp
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
import daemon
+sys.path.append('/usr/lib/python'+str(sys.version_info.major)+'.'+str(sys.version_info.minor)+'/site-packages/open-av4ms')
from Pages import Pages
import base64
+sys.path.append('/etc/open-av4ms') # The password file is there.
import Password
@@ -164,4 +168,4 @@
if uid == 0: # root?
- os.setgid(33) # dann www-data
- os.setuid(33)
+ os.setgid(grp.getgrnam('av4ms-server').gr_gid) # av4ms-server
+ os.setuid(pwd.getpwnam('av4ms-server').pw_uid)
server.serve_forever()
@@ -172,5 +176,5 @@
context = daemon.DaemonContext(
- working_directory = '/home/www',
+ working_directory = '/usr/share/open-av4ms',
umask=0o002,
- pidfile = PidFile("/tmp/webserver.pid"),
+ pidfile = PidFile("/run/open-av4ms/av4server/av4webserver.pid"),
files_preserve = [sys.stdout,sys.stderr]
diff -r -U1 open-av4ms.raspbian.python2/usr/local/bin/av4config open-av4ms.arch.python2/usr/local/bin/av4config
--- open-av4ms.raspbian.python2/usr/local/bin/av4config 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/usr/local/bin/av4config 2023-01-09 17:18:22.179287768 +0100
@@ -6,3 +6,3 @@
-conffile = '/etc/av4server.conf'
+conffile = '/etc/open-av4ms/av4server.conf'
diff -r -U1 open-av4ms.raspbian.python2/usr/local/bin/av4update open-av4ms.arch.python2/usr/local/bin/av4update
--- open-av4ms.raspbian.python2/usr/local/bin/av4update 2023-01-09 17:17:31.789289344 +0100
+++ open-av4ms.arch.python2/usr/local/bin/av4update 2023-01-09 17:18:22.179287768 +0100
@@ -2,3 +2,3 @@
-beta="$1"
+beta="$1" # Can be 'beta', for example.
|