-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoc_last-seen
56 lines (49 loc) · 1.27 KB
/
oc_last-seen
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/bash
# TODO: Error Checks
# Credentials file checker ---> Start
oc_credentials check
VALID=$"(echo "$?")"
if [ "$VALIDi" = "1" ]; then
tput setaf 1
echo "One error with your credentias has occurred, Please run oc_credentials to fix it!"
tput sgr0
exit 1
fi
CRED=~/.oC_credentials
# shellcheck source=~/.oC_credentials
. "$CRED"
# Credentials file checker <--- End
# Help ---> Start
display_help() {
echo "Usage: $0 [user]" >&2
echo
echo " -h, --help This help output "
echo
echo " [user] displays only the output from the selected user"
echo
exit 1
}
case "$1" in
-h | -help | --help)
display_help
exit 0
;;
esac
# Help <--- End
ALL_USERS=$(printf "select uid from %susers" "$DB_PREFIX")
DBUSERS=$(mysql -u "$DB_USER" --password="$DB_PASSWORD" "$DB_NAME" -e "$ALL_USERS")
[[ $# == 1 ]] && DBUSERS=$1
OLDIFS=$IFS
IFS=$'\n'
for CHECK_USER in $DBUSERS ; do
if [ "$CHECK_USER" != "uid" ] ; then
printf "Testing %s --> " "$CHECK_USER"
LAST_SEEN=$(oc_occ user:lastseen "$CHECK_USER")
if [[ "$LAST_SEEN" == *"never"* ]] ; then
tput setaf 1
fi
printf " %s \n" "$LAST_SEEN"
tput sgr0
fi
done
IFS=$OLDIFS