-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathoracle-java8-unlimited-jce-policy.postinst
121 lines (91 loc) · 3.51 KB
/
oracle-java8-unlimited-jce-policy.postinst
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
### Variables
VER='0.7'
# Folders
J_INSTALL_DIR=/usr/lib/jvm/java-8-oracle/jre/lib/security
OLDDIR=/usr/lib/oracle-jdk8-installer-unpackdir
NEWDIR=/var/cache/oracle-jdk8-installer
SHA256SUM_TGZ="f3020a3922efd6626c2fff45695d527f34a8020e938a49292561f18ad1320b59"
J_DIR=UnlimitedJCEPolicyJDK8
FILENAME=jce_policy-8.zip
PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/8/$FILENAME
### Functions
fp_exit_with_error() {
echo $1
echo "Unlimited JCE Policy for Oracle Java 8."
db_fset oracle-java8-unlimited-jce-policy/local seen false
exit 1
}
fp_download_and_unpack() {
cd /var/cache/oracle-jdk8-installer
db_get oracle-java8-unlimited-jce-policy/local
if [ -d "$RET" -a -f "$RET"/$FILENAME ]; then
echo "Installing from local file $RET/$FILENAME"
cp -f -p "$RET"/$FILENAME ${FILENAME}_TEMP
mv -f ${FILENAME}_TEMP $FILENAME
else # no local file
# use apt proxy
APT_PROXIES=$(apt-config shell \
http_proxy Acquire::http::Proxy \
https_proxy Acquire::https::Proxy \
ftp_proxy Acquire::ftp::Proxy \
dl_direct Acquire::http::Proxy::download.oracle.com \
)
[ -n "$APT_PROXIES" ] && eval export $APT_PROXIES
if [ "$dl_direct" = "DIRECT" ]; then
unset http_proxy
unset https_proxy
unset ftp_proxy
fi
# if /var/cache/oracle-jdk8-installer/wgetrc exists, use it for downloading java
if [ -f /var/cache/oracle-jdk8-installer/wgetrc ]; then
# downloading Unlimited JCE Policy for Oracle Java 8
echo "Using wget settings from /var/cache/oracle-jdk8-installer/wgetrc"
echo "Downloading Unlimited JCE Policy for Oracle Java 8..."
WGETRC=wgetrc wget --continue --no-check-certificate -O $FILENAME --header "Cookie: oraclelicense=a" $PARTNER_URL \
|| fp_exit_with_error "download failed"
echo "Download done."
#if it's not, use the settings below (which also creates /var/cache/oracle-jdk8-installer/wgetrc)
else
# setting wget options
:> wgetrc
echo "noclobber = off" >> wgetrc
echo "dir_prefix = ." >> wgetrc
echo "dirstruct = off" >> wgetrc
echo "verbose = on" >> wgetrc
echo "progress = dot:mega" >> wgetrc
echo "tries = 5" >> wgetrc
# downloading Unlimited JCE Policy for Oracle Java 8
echo "No /var/cache/oracle-jdk8-installer/wgetrc file found."
echo "Creating /var/cache/oracle-jdk8-installer/wgetrc and"
echo "using default oracle-java8-installer wgetrc settings for it."
echo "Downloading Unlimited JCE Policy for Oracle Java 8..."
WGETRC=wgetrc wget --continue --no-check-certificate -O $FILENAME --header "Cookie: oraclelicense=a" $PARTNER_URL \
|| fp_exit_with_error "download failed"
echo "Download done."
fi
fi
# Removing outdated cached downloads
echo "Removing outdated cached downloads..."
rm -vrf $J_DIR
# Verify SHA256 checksum of (copied or downloaded) tarball
echo "$SHA256SUM_TGZ $FILENAME" | sha256sum -c > /dev/null 2>&1 \
|| fp_exit_with_error "sha256sum mismatch $FILENAME"
# Unpacking and checking the plugin
unzip $FILENAME || fp_exit_with_error "Cannot unpack Unlimited JCE Policy for Oracle Java 8"
}
### Main
# Create dirs
mkdir -p /var/cache/oracle-jdk8-installer /usr/lib/jvm /usr/lib/oracle-jdk8-installer-unpackdir
fp_download_and_unpack
# Copy it to the right dir
if [ -e /usr/lib/jvm/java-8-oracle/jre/lib/security ]; then
cp -rf $NEWDIR/$J_DIR/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/
fi
db_fset oracle-java8-unlimited-jce-policy/local seen false
echo "Unlimited JCE Policy for Oracle Java 8 istalled"
#DEBHELPER#
exit 0
# vim: ts=2 sw=2