Bob Mottram 9 лет назад
Родитель
Сommit
814bd711b6
4 измененных файлов: 89 добавлений и 3 удалений
  1. 4
    0
      Makefile
  2. Двоичные данные
      man/freedombone-logging.1.gz
  3. 9
    3
      src/freedombone-controlpanel
  4. 76
    0
      src/freedombone-logging

+ 4
- 0
Makefile Просмотреть файл

@@ -40,6 +40,7 @@ install:
40 40
 	install -m 755 src/${APP}-meshweb ${DESTDIR}${PREFIX}/bin/meshweb
41 41
 	install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin
42 42
 	install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control
43
+	install -m 755 src/${APP}-logging ${DESTDIR}${PREFIX}/bin
43 44
 	mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1
44 45
 	install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1
45 46
 	install -m 644 man/${APP}-keydrive.1.gz ${DESTDIR}${PREFIX}/share/man/man1
@@ -66,6 +67,7 @@ install:
66 67
 	install -m 644 man/${APP}-xmpp-pass.1.gz ${DESTDIR}${PREFIX}/share/man/man1
67 68
 	install -m 644 man/${APP}-mesh.1.gz ${DESTDIR}${PREFIX}/share/man/man1
68 69
 	install -m 644 man/${APP}-controlpanel.1.gz ${DESTDIR}${PREFIX}/share/man/man1
70
+	install -m 644 man/${APP}-logging.1.gz ${DESTDIR}${PREFIX}/share/man/man1
69 71
 uninstall:
70 72
 	rm -f ${PREFIX}/share/man/man1/${APP}.1.gz
71 73
 	rm -f ${PREFIX}/share/man/man1/${APP}-keydrive.1.gz
@@ -92,6 +94,7 @@ uninstall:
92 94
 	rm -f ${PREFIX}/share/man/man1/${APP}-xmpp-pass.1.gz
93 95
 	rm -f ${PREFIX}/share/man/man1/${APP}-mesh.1.gz
94 96
 	rm -f ${PREFIX}/share/man/man1/${APP}-controlpanel.1.gz
97
+	rm -f ${PREFIX}/share/man/man1/${APP}-logging.1.gz
95 98
 	rm -rf ${PREFIX}/share/${APP}
96 99
 	rm -f ${PREFIX}/bin/${APP}
97 100
 	rm -f ${PREFIX}/bin/zeronetavahi
@@ -121,6 +124,7 @@ uninstall:
121 124
 	rm -f ${PREFIX}/bin/${APP}-meshweb
122 125
 	rm -f ${PREFIX}/bin/meshweb
123 126
 	rm -f ${PREFIX}/bin/${APP}-controlpanel
127
+	rm -f ${PREFIX}/bin/${APP}-logging
124 128
 clean:
125 129
 	rm -f \#* \.#* debian/*.substvars debian/*.log
126 130
 	rm -fr deb.* debian/${APP}

Двоичные данные
man/freedombone-logging.1.gz Просмотреть файл


+ 9
- 3
src/freedombone-controlpanel Просмотреть файл

@@ -313,6 +313,10 @@ function restore_data_remote {
313 313
     any_key
314 314
 }
315 315
 
316
+function logging_on_off {
317
+    and_key
318
+}
319
+
316 320
 function restore_gpg_key {
317 321
     select_user
318 322
     if [ ! $SELECTED_USERNAME ]; then
@@ -331,7 +335,7 @@ function menu_top_level {
331 335
         trap "rm -f $data" 0 1 2 5 15
332 336
         dialog --backtitle "Freedombone Control Panel" \
333 337
                --title "Control Panel" \
334
-               --radiolist "Choose an operation:" 22 70 15 \
338
+               --radiolist "Choose an operation:" 24 70 15 \
335 339
                1 "Backup data to USB drive" off \
336 340
                2 "Restore data from USB drive" off \
337 341
                3 "Restore from remote backup" off \
@@ -346,7 +350,8 @@ function menu_top_level {
346 350
                12 "Backup GPG key to USB drive (master keydrive)" off \
347 351
                13 "Backup GPG key to USB drive (fragment keydrive)" off \
348 352
                14 "Restore GPG key from USB drive" off \
349
-               15 "Exit" on 2> $data
353
+               15 "Turn logging on/off" off \
354
+               16 "Exit" on 2> $data
350 355
         sel=$?
351 356
         case $sel in
352 357
             1) exit 1;;
@@ -367,7 +372,8 @@ function menu_top_level {
367 372
             12) create_keydrive_master;;
368 373
             13) create_keydrive_fragment;;
369 374
             14) restore_gpg_key;;
370
-            15) break;;
375
+            15) logging_on_off;;
376
+            16) break;;
371 377
         esac
372 378
     done
373 379
 }

+ 76
- 0
src/freedombone-logging Просмотреть файл

@@ -0,0 +1,76 @@
1
+#!/bin/bash
2
+#
3
+# .---.                  .              .
4
+# |                      |              |
5
+# |--- .--. .-.  .-.  .-.|  .-. .--.--. |.-.  .-. .--.  .-.
6
+# |    |   (.-' (.-' (   | (   )|  |  | |   )(   )|  | (.-'
7
+# '    '     --'  --'  -' -  -' '  '   -' -'   -' '   -  --'
8
+#
9
+#                    Freedom in the Cloud
10
+#
11
+# Turn logging on or off
12
+
13
+# License
14
+# =======
15
+#
16
+# Copyright (C) 2015 Bob Mottram <bob@robotics.uk.to>
17
+#
18
+# This program is free software: you can redistribute it and/or modify
19
+# it under the terms of the GNU General Public License as published by
20
+# the Free Software Foundation, either version 3 of the License, or
21
+# (at your option) any later version.
22
+#
23
+# This program is distributed in the hope that it will be useful,
24
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
25
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26
+# GNU General Public License for more details.
27
+#
28
+# You should have received a copy of the GNU General Public License
29
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
30
+
31
+if [ ! "$1" ]; then
32
+    exit 1
33
+fi
34
+
35
+if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
36
+  if [ -d /etc/nginx ]; then
37
+      for filename in /etc/nginx/sites-available/* ; do
38
+          filename_domain=$(echo "$filename" | awk -F '/' '{print $5}')
39
+          sed -i 's|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g' $filename
40
+          sed -i 's|warn_log.*|warn_log /var/log/nginx/$filename_domain.warn.log;|g' $filename
41
+          sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log;|g" $filename
42
+      done
43
+  fi
44
+  if [ -f /etc/init.d/spamassassin ]; then
45
+      sed -i 's|DOPTIONS="-s null -d --pidfile=$PIDFILE"|DOPTIONS="-d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
46
+  fi
47
+  if [ -d /etc/prosody ]; then
48
+      sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosofy/prosody.cfg.lua
49
+      sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosofy/prosody.cfg.lua
50
+  fi
51
+else
52
+  if [ -d /etc/nginx ]; then
53
+      for filename in /etc/nginx/sites-available/* ; do
54
+          sed -i 's|access_log.*|access_log off;|g' $filename
55
+          sed -i 's|warn_log.*|warn_log off;|g' $filename
56
+          sed -i 's|error_log.*|error_log off;|g' $filename
57
+      done
58
+  fi
59
+  if [ -f /etc/init.d/spamassassin ]; then
60
+      sed -i 's|DOPTIONS="-d --pidfile=$PIDFILE"|DOPTIONS="-s null -d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
61
+  fi
62
+  if [ -d /etc/prosody ]; then
63
+      sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosofy/prosody.cfg.lua
64
+      sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosofy/prosody.cfg.lua
65
+  fi
66
+fi
67
+
68
+if [ -d /etc/nginx ]; then
69
+    service php5-fpm restart
70
+    service nginx restart
71
+fi
72
+if [ -f /etc/init.d/spamassassin ]; then
73
+    service spamassassin restart
74
+fi
75
+
76
+exit 0