-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate_java
More file actions
executable file
·43 lines (28 loc) · 1.33 KB
/
update_java
File metadata and controls
executable file
·43 lines (28 loc) · 1.33 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
#!/bin/bash
# Update the Java browser plugin
mkdir -p /tmp/java_plugin_install
cd /tmp/java_plugin_install
downloadPage=`curl -s -L http://www.oracle.com/technetwork/java/javase/downloads/index.html | grep -E --only-matching "/technetwork/java/javase/downloads/jdk8-downloads-([0-9]*).html" | head -1`
echo "Download page is http://www.oracle.com$downloadPage"
fileUrl=`curl -s -L "http://www.oracle.com$downloadPage" | grep -E --only-matching "http://download.oracle.com/otn-pub/java/jdk/8u(\w+)-(\w+)/([0-9a-f]+)/jdk-8u(\w+)-linux-x64.tar.gz" | head -1`
regexVersion="8u([0-9]+)"
[[ $fileUrl =~ $regexVersion ]]
availableVersion="${BASH_REMATCH[1]}"
javaVersion=`java -version 2>&1 | grep version`
regexCurrentVersion="_([0-9]+)"
[[ $javaVersion =~ $regexCurrentVersion ]]
currentVersion="${BASH_REMATCH[1]}"
echo "Current version: $currentVersion"
echo "Available version: $availableVersion"
if [[ $currentVersion -eq $availableVersion ]]; then
echo "No update needed"
exit
fi
echo "Ready to download $fileUrl..."
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" $fileUrl
echo "Making deb..."
make-jpkg jdk-8u*-linux-x64.tar.gz
echo "Installing deb..."
sudo dpkg -i oracle-java8-jdk_8u*_amd64.deb
echo "Done, cleaning up"
rm jdk-8u*-linux-x64.tar.gz oracle-java8-jdk_8u*_amd64.deb