-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathCode42 Status.sh
More file actions
executable file
·49 lines (39 loc) · 1.3 KB
/
Code42 Status.sh
File metadata and controls
executable file
·49 lines (39 loc) · 1.3 KB
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
#!/bin/zsh
# This is an extension attribute script to report Code42 status
# There are 4 possible values with definitions below:
# On, Logged In: ${Code42User}:
# Application is running and user is logged in
# On, Not Logged In:
# Application is running but user is not logged in
# Off:
# Application is not running
# Not Installed:
# Code42 Is Not Installed
# Code42 Application Path
Code42Path="/Applications/Code42.app"
# Check if Code42 is installed before anything else
if [[ ! -d "$Code42Path" ]]; then
echo "<result>Not Installed</result>"
exit 0
fi
# Sets value of Code42 Application Log
Code42AppLog="/Library/Logs/CrashPlan/app.log"
#If value is 0, no user is logged in to Code42
Code42LoggedIn="$(/usr/bin/awk '/USER/{getline; gsub("\,",""); print $1; exit }' $Code42AppLog)"
# Gets Code42 username
Code42User="$(/usr/bin/awk '/USER/{getline; gsub("\,",""); print $2; exit }' $Code42AppLog)"
# Checks if Code42 Client is Running
Code42Running="$(/usr/bin/pgrep "Code42Service")"
# Reports Code42 Status and Username
if [[ -n "${Code42Running}" ]]; then
Code42Status="On, "
if [[ "${Code42LoggedIn}" -eq 0 ]]
then
Code42Status+="Not Logged In"
else
Code42Status+="Logged In: ${Code42User}"
fi
else
Code42Status="Off"
fi
echo "<result>${Code42Status}</result>"