|
@@ -40,6 +40,48 @@ WEBSERVER_LOG_LEVEL='warn'
|
40
|
40
|
# Also the shred command can be very slow on Beaglebone Black
|
41
|
41
|
REMOVE_FILES_COMMAND='rm -rf'
|
42
|
42
|
|
|
43
|
+APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
|
44
|
+for f in $APP_FILES
|
|
45
|
+do
|
|
46
|
+ source $f
|
|
47
|
+done
|
|
48
|
+
|
|
49
|
+APPS_AVAILABLE=()
|
|
50
|
+
|
|
51
|
+function logging_get_app_names {
|
|
52
|
+ FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
|
53
|
+
|
|
54
|
+ for filename in $FILES
|
|
55
|
+ do
|
|
56
|
+ app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
|
57
|
+ if grep -q "logging_on_" ${filename}; then
|
|
58
|
+ if grep -q "logging_off_" ${filename}; then
|
|
59
|
+ APPS_AVAILABLE+=("${app_name}")
|
|
60
|
+ fi
|
|
61
|
+ fi
|
|
62
|
+ done
|
|
63
|
+}
|
|
64
|
+
|
|
65
|
+function turn_logging_on {
|
|
66
|
+ logging_get_app_names
|
|
67
|
+
|
|
68
|
+ for a in "${APPS_AVAILABLE[@]}"
|
|
69
|
+ do
|
|
70
|
+ echo $"Turning on logging for ${a}"
|
|
71
|
+ logging_on_${a}
|
|
72
|
+ done
|
|
73
|
+}
|
|
74
|
+
|
|
75
|
+function turn_logging_off {
|
|
76
|
+ logging_get_app_names
|
|
77
|
+
|
|
78
|
+ for a in "${APPS_AVAILABLE[@]}"
|
|
79
|
+ do
|
|
80
|
+ echo $"Turning off logging for ${a}"
|
|
81
|
+ logging_off_${a}
|
|
82
|
+ done
|
|
83
|
+}
|
|
84
|
+
|
43
|
85
|
function turn_off_rsys_logging {
|
44
|
86
|
sed -i 's|mail,news.none.*|mail,news.none /dev/null|g' /etc/rsyslog.conf
|
45
|
87
|
sed -i 's|auth,authpriv.\*.*|auth,authpriv.\* /dev/null|g' /etc/rsyslog.conf
|
|
@@ -83,12 +125,8 @@ if [ ! "$1" ]; then
|
83
|
125
|
fi
|
84
|
126
|
|
85
|
127
|
if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
|
86
|
|
- if [ -f /var/lib/matrix/homeserver.yaml ]; then
|
87
|
|
- sed -i 's|log_file:.*|log_file: /etc/matrix/homeserver.log|g' /var/lib/matrix/homeserver.yaml
|
88
|
|
- if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then
|
89
|
|
- sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml
|
90
|
|
- fi
|
91
|
|
- fi
|
|
128
|
+ turn_logging_on
|
|
129
|
+
|
92
|
130
|
if [ -f /etc/fail2ban/fail2ban.conf ]; then
|
93
|
131
|
sed -i 's|loglevel.*|loglevel = 3|g' /etc/fail2ban/fail2ban.conf
|
94
|
132
|
sed -i 's|logtarget.*|logtarget = /var/log/fail2ban.log|g' /etc/fail2ban/fail2ban.conf
|
|
@@ -105,9 +143,6 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
|
105
|
143
|
sed -i 's|#Log notice file.*|Log notice file /var/log/tor/notices.log|g' /etc/tor/torrc
|
106
|
144
|
sed -i 's|Log notice file.*|Log notice file /var/log/tor/notices.log|g' /etc/tor/torrc
|
107
|
145
|
fi
|
108
|
|
- if [ -f /etc/mumble-server.ini ]; then
|
109
|
|
- sed -i 's|logfile=.*|logfile=/var/log/mumble-server.log|g' /etc/mumble-server.ini
|
110
|
|
- fi
|
111
|
146
|
if [ -f /etc/php/7.0/fpm/php-fpm.conf ]; then
|
112
|
147
|
sed -i 's|error_log =.*|error_log = /var/log/php-fpm.log|g' /etc/php/7.0/fpm/php-fpm.conf
|
113
|
148
|
fi
|
|
@@ -126,15 +161,6 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
|
126
|
161
|
if [ -f /etc/init.d/spamassassin ]; then
|
127
|
162
|
sed -i 's|DOPTIONS="-s null -d --pidfile=$PIDFILE"|DOPTIONS="-d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
|
128
|
163
|
fi
|
129
|
|
- if [ -d /etc/prosody ]; then
|
130
|
|
- if [ ! -d /var/log/prosody ]; then
|
131
|
|
- mkdir /var/log/prosody
|
132
|
|
- chown root:adm /var/log/prosody
|
133
|
|
- fi
|
134
|
|
- sed -i 's|info = "/dev/null";|info = "/var/log/prosody/prosody.log";|g' /etc/prosody/prosody.cfg.lua
|
135
|
|
- sed -i 's|error = "/dev/null";|error = "/var/log/prosody/prosody.err";|g' /etc/prosody/prosody.cfg.lua
|
136
|
|
- sed -i 's|levels = { "error" }; to = "/dev/null";|levels = { "error" }; to = "syslog";|g' /etc/prosody/prosody.cfg.lua
|
137
|
|
- fi
|
138
|
164
|
if [ -d /etc/exim4 ]; then
|
139
|
165
|
if [ ! -d /var/log/exim4 ]; then
|
140
|
166
|
mkdir /var/log/exim4
|
|
@@ -158,29 +184,12 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
|
158
|
184
|
fi
|
159
|
185
|
turn_on_rsys_logging
|
160
|
186
|
else
|
161
|
|
- if [ -f /var/lib/matrix/homeserver.yaml ]; then
|
162
|
|
- sed -i 's|log_file:.*|log_file: /dev/null|g' /var/lib/matrix/homeserver.yaml
|
163
|
|
- if ! grep -q "#log_config:" /var/lib/matrix/homeserver.yaml; then
|
164
|
|
- sed -i 's|log_config:|#log_config:|g' /var/lib/matrix/homeserver.yaml
|
165
|
|
- fi
|
166
|
|
- if [ -f /etc/matrix/homeserver.log ]; then
|
167
|
|
- $REMOVE_FILES_COMMAND /etc/matrix/homeserver.log
|
168
|
|
- fi
|
169
|
|
- if [ -f /etc/matrix/homeserver.log.1 ]; then
|
170
|
|
- $REMOVE_FILES_COMMAND /etc/matrix/homeserver.log.1
|
171
|
|
- fi
|
172
|
|
- fi
|
|
187
|
+ rurn_logging_off
|
|
188
|
+
|
173
|
189
|
if [ -d /etc/tor ]; then
|
174
|
190
|
sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
|
175
|
191
|
sed -i 's|Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
|
176
|
192
|
fi
|
177
|
|
- if [ -f /etc/mumble-server.ini ]; then
|
178
|
|
- sed -i 's|logfile=.*|logfile=/dev/null|g' /etc/mumble-server.ini
|
179
|
|
- if [ -d /var/log/mumble-server ]; then
|
180
|
|
- $REMOVE_FILES_COMMAND /var/log/mumble-server/*
|
181
|
|
- rm -rf /var/log/mumble-server
|
182
|
|
- fi
|
183
|
|
- fi
|
184
|
193
|
if [ -d /var/log/radicale ]; then
|
185
|
194
|
$REMOVE_FILES_COMMAND /var/log/radicale/*
|
186
|
195
|
rm -rf /var/log/radicale
|
|
@@ -202,13 +211,6 @@ else
|
202
|
211
|
if [ -f /etc/init.d/spamassassin ]; then
|
203
|
212
|
sed -i 's|DOPTIONS="-d --pidfile=$PIDFILE"|DOPTIONS="-s null -d --pidfile=$PIDFILE"|g' /etc/init.d/spamassassin
|
204
|
213
|
fi
|
205
|
|
- if [ -d /etc/prosody ]; then
|
206
|
|
- sed -i 's|info = "/var/log/prosody/prosody.log";|info = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
207
|
|
- sed -i 's|error = "/var/log/prosody/prosody.err";|error = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
208
|
|
- sed -i 's|levels = { "error" }; to = "syslog";|levels = { "error" }; to = "/dev/null";|g' /etc/prosody/prosody.cfg.lua
|
209
|
|
- $REMOVE_FILES_COMMAND /var/log/prosody/*
|
210
|
|
- rm -rf /var/log/prosody
|
211
|
|
- fi
|
212
|
214
|
if [ -d /etc/exim4 ]; then
|
213
|
215
|
sed -i 's|MAIN_LOG_SELECTOR = .*|MAIN_LOG_SELECTOR = -all|g' /etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs
|
214
|
216
|
sed -i 's|MAIN_LOG_SELECTOR = .*|MAIN_LOG_SELECTOR = -all|g' /etc/exim4/exim4.conf.template
|