-
Notifications
You must be signed in to change notification settings - Fork 4
/
sysechk
executable file
·56 lines (44 loc) · 1.77 KB
/
sysechk
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
#!/bin/bash
# This file is part of System Security Checker
# Copyright (C) 2011-2016 Infertux <infertux@infertux.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
export TESTS=tests
export REPORTS=reports
. $(dirname $0)/lib/sysechk.sh
cd $(dirname $0)
$VERBOSE && echo "Purging old reports…"
rm -f $REPORTS/*
$VERBOSE && echo "Running tests…"
[ "$(ls -A $TESTS)" ] || FATAL "No tests found!"
set +e
# execute all tests in parallel, yeah Bash!
find $TESTS -name "*.sh" -print0 | xargs -0 -n1 -P0 ./lib/run_test.sh "$ARGS"
xcode=$?
set -e
fail=$(wc -l reports/*.txt | tail -1 | awk '{print $1}')
reports=$(ls $REPORTS | wc -w)
echo -ne "\x1b\x5b\x32\x4b" # send VT100 escape code ^[[2K to erase the line
echo "$reports tests ran in $SECONDS seconds."
if [ $fail -eq 0 ]; then
SUCCESS "All tests passed, your system seems quite secure!"
else
WARNING "$fail problems detected:"
grep '' $REPORTS/*.txt | sed -r 's@.*/(.*)\.txt:(.*)$@\1 \t\2@' >&2
fi
# create the output file if requested
[ "$OUTPUT_FILE" ] && \
find $REPORTS -name "*.txt" -not -empty | sed -r 's@.*/(.*)\.txt$@\1@' > $OUTPUT_FILE
$VERBOSE && echo "Done."
exit $fail