-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcoreconfig-restart-reminder
57 lines (45 loc) · 1.68 KB
/
coreconfig-restart-reminder
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
# Script to make the user aware that a restart has not occurred in over 14 days
# Use JamfHelper tool to show alert message
jHelper="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
# Set maximum days to 14 before warning about restart
maxDays="14"
# Check to see if machine has restarted in the last day
# See if "days" exists in the uptime
upTime=`uptime | grep "days"`
if [ -z "$upTime" ];
then
echo "Not yet one day"
exit 1;
else
echo "More than one day"
fi
# Get current uptime
upTimeDays=`uptime | awk '{print $3}'`
# Display uptime
echo "Uptime days: $upTimeDays"
# Advise user of uptime and give the option to reboot
msg="Your University supported Mac has not been restarted for at least $upTimeDays days.
Please restart as soon as it is convenient in order to maintain smooth operation of your system."
# Location of icon
icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertNoteIcon.icns"
# If uptime is equal to or greater than 14 days then display message
if [ "$upTimeDays" -ge "$maxDays" ]; then
echo "Mac has been up for more than $maxDays days"
# Get answer from user
result=`"$jHelper" -windowType utility -description "$msg" -title "UoE Supported Desktop Notification" -button1 "Restart now" -button2 "Not yet" -defaultButton 2 -icon "$icon" -iconSize 90`
# If answer is Restart now, then restart
if [ $result -eq 0 ];
then
echo "I am rebooting...."
#reboot
else
# Else delay restart
echo "Not yet..."
exit 0
fi
else
# Mac has been restarted within 14 days
echo "Mac has been up for less than $maxDays days. Exiting."
exit 0
fi