blob: 47ecf16c746b2c38a124b5d8ef472999061aae33 (
plain) (
blame)
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
|
#!/bin/sh
PROG=check_eapol
USAGE="USAGE: ${PROG} -c CONFIGFILE -a ADDRESS -s SECRET [-p PORT] [-t TIMEOUT] [-d]"
OK=0
WARN=1
CRIT=2
UNKNOWN=3
usage(){
printf 'USAGE: %s -c CONFIGFILE -a ADDRESS -s SECRET [-p PORT] [-t TIMEOUT] [-d]' "$PROG"
exit "$UNKNOWN"
}
die(){
printf '%s: %s\n' "$PROG" "$1" 1>&2
exit "$UNKNOWN"
}
port=1812
timeout=5
debug=false
while getopts :a:c:dp:s:t: opt; do
case $opt in
a) address=$OPTARG ;;
c) config=$OPTARG ;;
d) debug=true ;;
p) port=$OPTARG ;;
s) secret=$OPTARG ;;
t) timeout=$OPTARG ;;
:|?) usage ;;
esac
done
shift $((OPTIND - 1 ))
[ $# -eq 0 ] || usage
[ -r "$config" ] || die "config file not readable: ${config}"
if [ -z "$address" ] || [ -z "$config" ] || [ -z "$secret" ]; then
usage
fi
if [ "$debug" = true ]; then
eapol_test -c "$config" -a "$address" -p "$port" -s "$secret" -t "$timeout"
else
eapol_test -c "$config" -a "$address" -p "$port" -s "$secret" -t "$timeout" > /dev/null
fi
if [ $? -eq 0 ]; then
echo "authentication to ${address}:${port} using ${config} succeeded"
exit "$OK"
else
echo "authentication to ${address}:${port} using ${config} failed"
exit "$CRIT"
fi
|