This repository was archived by the owner on May 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathdisableJavaAutoUpdates.sh
More file actions
66 lines (54 loc) · 1.59 KB
/
disableJavaAutoUpdates.sh
File metadata and controls
66 lines (54 loc) · 1.59 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Author: Stephen Bygrave - Moof IT
# Name: disableJavaAutoUpdates.sh
#
# Purpose: Checks to see the status of the Java AutoUpdater, and disables if
# necessary.
# Usage: Can be run as a ongoing login policy in Jamf, as this will remediate
# automatically when a user logs in, if the updater is enabled.
#
# Version 1.0.0, 2018-05-05
# SB - Initial Creation
# Use at your own risk. Moof IT will accept no responsibility for loss or damage
# caused by this script.
##### Set variables
logProcess="disableJavaAutoUpdates"
##### Declare functions
writelog ()
{
/usr/bin/logger -is -t "${logProcess}" "${1}"
if [[ -e "/var/log/jamf.log" ]];
then
/bin/echo "$(date +"%a %b %d %T") $(hostname -f | awk -F "." '{print $1}') jamf[${logProcess}]: ${1}" >> "/var/log/jamf.log"
fi
}
echoVariables ()
{
writelog "Log Process is ${logProcess}"
}
checkJavaPreferences ()
{
if [[ -e /Library/Preferences/com.oracle.java.Java-Updater.plist ]];
then
writelog "Java AutoUpdate preference file found."
else
writelog "Java AutoUpdate preference file not found. Java may not be installed. Exiting..."
exit 1
fi
}
disableAutoUpdate ()
{
/usr/bin/defaults write /Library/Preferences/com.oracle.java.Java-Updater JavaAutoUpdateEnabled -bool false
if [[ $? -eq 0 ]];
then
writelog "Java AutoUpdate disabled."
else
writelog "Unable to disable Java AutoUpdate. Bailing..."
exit 1
fi
}
##### Run script
echoVariables
checkJavaPreferences
disableAutoUpdate
writelog "Script completed."