-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJavaVersionCompare.sh
21 lines (17 loc) · 1005 Bytes
/
JavaVersionCompare.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash
#Get Latest Version
onlineversionmain=`curl -L http://www.java.com/en/download/manual.jsp | grep "Recommended Version" | awk '{ print $4}'`
onlineversionmin1=`curl -L http://www.java.com/en/download/manual.jsp | grep "Recommended Version" | awk '{ print $6}' | awk -F "<" '{ print $1}'`
onlineversionmin="${onlineversionmin1:0:3}"
LatestJavaVer="${onlineversionmain}.${onlineversionmin}"
echo "Latest Java Version is ${LatestJavaVer}"
RESULT=$( /usr/bin/defaults read "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Enabled.plist" CFBundleVersion )
REPORTED_MAJOR_VERSION=`echo "${RESULT}" | awk -F'.' '{print $2}'`
REPORTED_MINOR_VERSION=`echo "${RESULT}" | awk -F'.' '{print $3}'`
echo "Current Java Version is ${REPORTED_MAJOR_VERSION}"."${REPORTED_MINOR_VERSION}"
CurrJavaVer="${REPORTED_MAJOR_VERSION}"."${REPORTED_MINOR_VERSION}"
if [ "${LatestJavaVer}" != "${CurrJavaVer}" ]; then
echo "<result>UpdateRequired</result>"
else
echo "<result>UpToDate</result>"
fi