From 814bd711b6f7799e476e4d50493e64828baccc4c Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 31 Oct 2015 22:55:09 +0000 Subject: [PATCH] logging command --- Makefile | 4 ++ man/freedombone-logging.1.gz | Bin 0 -> 549 bytes src/freedombone-controlpanel | 12 ++++-- src/freedombone-logging | 76 +++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 3 deletions(-) create mode 100644 man/freedombone-logging.1.gz create mode 100755 src/freedombone-logging diff --git a/Makefile b/Makefile index 98165fb9..939828b1 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ install: install -m 755 src/${APP}-meshweb ${DESTDIR}${PREFIX}/bin/meshweb install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin install -m 755 src/${APP}-controlpanel ${DESTDIR}${PREFIX}/bin/control + install -m 755 src/${APP}-logging ${DESTDIR}${PREFIX}/bin mkdir -m 755 -p ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-keydrive.1.gz ${DESTDIR}${PREFIX}/share/man/man1 @@ -66,6 +67,7 @@ install: install -m 644 man/${APP}-xmpp-pass.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-mesh.1.gz ${DESTDIR}${PREFIX}/share/man/man1 install -m 644 man/${APP}-controlpanel.1.gz ${DESTDIR}${PREFIX}/share/man/man1 + install -m 644 man/${APP}-logging.1.gz ${DESTDIR}${PREFIX}/share/man/man1 uninstall: rm -f ${PREFIX}/share/man/man1/${APP}.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-keydrive.1.gz @@ -92,6 +94,7 @@ uninstall: rm -f ${PREFIX}/share/man/man1/${APP}-xmpp-pass.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-mesh.1.gz rm -f ${PREFIX}/share/man/man1/${APP}-controlpanel.1.gz + rm -f ${PREFIX}/share/man/man1/${APP}-logging.1.gz rm -rf ${PREFIX}/share/${APP} rm -f ${PREFIX}/bin/${APP} rm -f ${PREFIX}/bin/zeronetavahi @@ -121,6 +124,7 @@ uninstall: rm -f ${PREFIX}/bin/${APP}-meshweb rm -f ${PREFIX}/bin/meshweb rm -f ${PREFIX}/bin/${APP}-controlpanel + rm -f ${PREFIX}/bin/${APP}-logging clean: rm -f \#* \.#* debian/*.substvars debian/*.log rm -fr deb.* debian/${APP} diff --git a/man/freedombone-logging.1.gz b/man/freedombone-logging.1.gz new file mode 100644 index 0000000000000000000000000000000000000000..de082449289b271adb24d107dcd3d93aa14e2f79 GIT binary patch literal 549 zcmV+=0^0o_iwFRmMm1Id1AS9nZ__Xoeb2AB%F94nQ@ROhR0z?I&`z{#)us#~UYz76 zv1{Ll4MQ_2ZHLFs~ScSUyoo_IJkN~3`* zM+>Sg6ih*m@QCIB-eTniRH3EB-2ax)hH`<@wnBnv-(oF;D`&jrr0gZ+-h~d0s%)!X z2ipUA1FkX197rlrgdaQ{?U=9xmLxhZ(YEehH7IoOP9SS|*c3_0R0)#p1A#lRTxx;f z2wce526~RjtJVujQWp+Xm`UI#r?~02$#T6&w_$P+zP^!>iXt-qsXxzdx|;=|4Qetj zBo4D{ zH>;8TQH|_PYGiLvi$w=(i3827?aS{B3C$F?#;4<)?6Uc46Gv0ZVM)#zCgFWf`N!~d z$nnA^exEq{5GA>Z*0c3+ww{e4oxHobO0RE@=#;zg7A&iA4AbS{s(A2?oIZXnD>H8v n^gS!BzTJO8o{`z1-7bz@515aS_b*((bFb(Z!uxKxas&VX&bSMK literal 0 HcmV?d00001 diff --git a/src/freedombone-controlpanel b/src/freedombone-controlpanel index e60e7703..97be91d0 100755 --- a/src/freedombone-controlpanel +++ b/src/freedombone-controlpanel @@ -313,6 +313,10 @@ function restore_data_remote { any_key } +function logging_on_off { + and_key +} + function restore_gpg_key { select_user if [ ! $SELECTED_USERNAME ]; then @@ -331,7 +335,7 @@ function menu_top_level { trap "rm -f $data" 0 1 2 5 15 dialog --backtitle "Freedombone Control Panel" \ --title "Control Panel" \ - --radiolist "Choose an operation:" 22 70 15 \ + --radiolist "Choose an operation:" 24 70 15 \ 1 "Backup data to USB drive" off \ 2 "Restore data from USB drive" off \ 3 "Restore from remote backup" off \ @@ -346,7 +350,8 @@ function menu_top_level { 12 "Backup GPG key to USB drive (master keydrive)" off \ 13 "Backup GPG key to USB drive (fragment keydrive)" off \ 14 "Restore GPG key from USB drive" off \ - 15 "Exit" on 2> $data + 15 "Turn logging on/off" off \ + 16 "Exit" on 2> $data sel=$? case $sel in 1) exit 1;; @@ -367,7 +372,8 @@ function menu_top_level { 12) create_keydrive_master;; 13) create_keydrive_fragment;; 14) restore_gpg_key;; - 15) break;; + 15) logging_on_off;; + 16) break;; esac done } diff --git a/src/freedombone-logging b/src/freedombone-logging new file mode 100755 index 00000000..a7c2e5b9 --- /dev/null +++ b/src/freedombone-logging @@ -0,0 +1,76 @@ +#!/bin/bash +# +# .---. . . +# | | | +# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-. +# | | (.-' (.-' ( | ( )| | | | )( )| | (.-' +# ' ' --' --' -' - -' ' ' -' -' -' ' - --' +# +# Freedom in the Cloud +# +# Turn logging on or off + +# License +# ======= +# +# Copyright (C) 2015 Bob Mottram +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +if [ ! "$1" ]; then + exit 1 +fi + +if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then + if [ -d /etc/nginx ]; then + for filename in /etc/nginx/sites-available/* ; do + filename_domain=$(echo "$filename" | awk -F '/' '{print $5}') + sed -i 's|access_log.*|access_log /var/log/nginx/$filename_domain.access.log;|g' $filename + sed -i 's|warn_log.*|warn_log /var/log/nginx/$filename_domain.warn.log;|g' $filename + sed -i "s|error_log.*|error_log /var/log/nginx/$filename_domain.err.log;|g" $filename + done + fi + if [ -f /etc/init.d/spamassassin ]; then + sed -i 's|DOPTIONS="-s null -d --pidfile=$PIDFILE"|DOPTIONS="-d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin + fi + if [ -d /etc/prosody ]; then + sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosofy/prosody.cfg.lua + sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosofy/prosody.cfg.lua + fi +else + if [ -d /etc/nginx ]; then + for filename in /etc/nginx/sites-available/* ; do + sed -i 's|access_log.*|access_log off;|g' $filename + sed -i 's|warn_log.*|warn_log off;|g' $filename + sed -i 's|error_log.*|error_log off;|g' $filename + done + fi + if [ -f /etc/init.d/spamassassin ]; then + sed -i 's|DOPTIONS="-d --pidfile=$PIDFILE"|DOPTIONS="-s null -d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin + fi + if [ -d /etc/prosody ]; then + sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosofy/prosody.cfg.lua + sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosofy/prosody.cfg.lua + fi +fi + +if [ -d /etc/nginx ]; then + service php5-fpm restart + service nginx restart +fi +if [ -f /etc/init.d/spamassassin ]; then + service spamassassin restart +fi + +exit 0