-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheck
executable file
·95 lines (89 loc) · 2.82 KB
/
check
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#
# check - Searching a JBT log file for critical issues or selected information.
#
# Distributed under the GNU General Public License version 2 or later, Copyright (c) 2024 Heiko Lübbe
# https://github.com/muhme/joomla-branches-tester
if [[ $(dirname "$0") != "scripts" || ! -f "scripts/helper.sh" ]]; then
echo "Please run me as 'scripts/info'. Thank you for your cooperation! :)"
exit 1
fi
function help {
echo "
check – Displays critical issues or selected information from a JBT log file without an optional argument.
With the optional 'jbt' argument, displays all JBT log messages.
With the optional 'scripts' argument, displays only start and stop messages for JBT scripts.
With the optional 'help' argument, displays this page. For full details, see https://bit.ly/JBT-README.
If no filename is specified, the latest log file is used.
$(random_quote)"
}
file=""
jbt=false
scripts=false
while [ $# -ge 1 ]; do
if [[ "$1" =~ ^(help|-h|--h|-help|--help|-\?)$ ]]; then
source scripts/helper.sh
help
exit 0
elif [ "$1" = "jbt" ]; then
jbt=true
shift # Argument is eaten as to show JBT information.
elif [ "$1" = "scripts" ]; then
scripts=true
shift # Argument is eaten as to show only the start and stop messages.
elif [ -f "logs/$1" ] || [ -f "$1" ]; then
# Ensure file name only, relative and absolute file names are working.
file=$(basename "$1")
file="logs/${file}"
shift # Argument is eaten as log file name.
else
source scripts/helper.sh
help
error "Argument '$1' is not valid."
exit 1
fi
done
if [[ ! -f "${file}" ]]; then
# shellcheck disable=SC2012 # find newest file, as ordered by file name
file="logs/$(ls logs | tail -1)"
if [[ ! -f "${file}" ]]; then
source scripts/helper.sh
error "No log file."
exit 1
fi
fi
# We assume now '$file' exists
echo "${file}:"
if [ "${jbt}" = "true" ]; then
grep '\*\*\*' "${file}"
elif [ "${scripts}" = "true" ]; then
grep -e '<<<' -e '>>>' "${file}"
else
grep -iv \
-e 'Configure to catch all PHP errors' \
-e 'liberror-perl' \
-e 'symfony/error-handler' \
-e 'fatal-error.html' \
-e 'system-admin-error.css' \
-e 'system-site-error.css' \
-e 'system-site-error_rtl.css' \
-e 'languageErrors/widget.css' \
-e 'Stopping and removing JBT Docker container' \
-e 'Container .* Stopping' \
-e 'Container .* Stopped' \
-e 'symfony/stopwatch' \
-e 'pear-build-defaultuser' \
-e 'libcanberra0' \
-e 'Enabling conf localized-error-page' \
-e 'info: Executing deferred' \
-e 'returns not found return code' \
-e 'referrer-policy' \
-e 'status-errored' \
-e 'overrid' "${file}" | \
grep -i --color=always \
-e ERR \
-e error \
-e fatal \
-e stop \
-e 'not found'
fi