-
Notifications
You must be signed in to change notification settings - Fork 0
/
piperlog-mkignore
executable file
·47 lines (45 loc) · 1.26 KB
/
piperlog-mkignore
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
#!/bin/bash
set -e
declare -a logcheckdirs
level=""
while getopts 'd:f:l:' opt
do case $opt in
d) logcheckdirs+=("$OPTARG");;
f) discard="$OPTARG";;
l) level="$OPTARG";;
?) echo "Usage: piperlog-mkignore [-d <logcheck directory>] [ -f <discard file>]\n [-l <level>]"
exit 1;;
esac
done
if [ ${#logcheckdirs[*]} -eq 0 ]; then
logcheckdirs[0]=/etc/logcheck
fi
if [ -z "$level" ]; then
if [ -f "$logcheckdir/logcheck.conf" ]; then
level=$(source "$logcheckdir/logcheck.conf" && echo $REPORTLEVEL)
else
level=server
fi
fi
case "$level" in
'workstation')
paths="violations.ignore.d ignore.d.server ignore.d.paranoid ignore.d.workstation" ;;
'server')
paths="violations.ignore.d ignore.d.server ignore.d.paranoid" ;;
'paranoid')
paths="violations.ignore.d ignore.d.paranoid" ;;
'')
paths="violations.ignore.d ignore.d.server ignore.d.paranoid" ;;
*)
echo "Level should be workstation, server or paranoid, was given: $level" >&2
exit 1
;;
esac
for (( i=0 ; $i < ${#logcheckdirs[*]} ; i++ )); do \
(echo "# -- Source: ${logcheckdirs[$i]}"; cd "${logcheckdirs[$i]}"; find $paths -type f | xargs cat); \
done \
| if [ -z "$discard" ]; then
piperlog-convert
else
piperlog-convert --discard "$discard"
fi