source: oracle-java8-installer/trunk/fuentes/debian/oracle-java8-unlimited-jce-policy.postinst @ 2122

Last change on this file since 2122 was 566, checked in by jrpelegrina, 4 years ago

First release to xenial

File size: 2.7 KB
Line 
1#!/bin/sh
2
3set -e
4
5. /usr/share/debconf/confmodule
6
7
8### Variables
9VER='0.7'
10
11# Folders
12J_INSTALL_DIR=/usr/lib/jvm/java-8-oracle/jre/lib/security
13OLDDIR=/usr/lib/oracle-jdk8-installer-unpackdir
14NEWDIR=/var/cache/oracle-jdk8-installer
15
16SHA256SUM_TGZ="f3020a3922efd6626c2fff45695d527f34a8020e938a49292561f18ad1320b59"
17J_DIR=UnlimitedJCEPolicyJDK8
18FILENAME=jce_policy-8.zip
19PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/8/$FILENAME
20
21
22### Functions
23fp_exit_with_error() {
24        echo $1
25        echo "Unlimited JCE Policy for Oracle Java 8."
26        db_fset oracle-java8-unlimited-jce-policy/local seen false
27        exit 1
28}
29
30fp_download_and_unpack() {
31        cd /var/cache/oracle-jdk8-installer
32
33        db_get oracle-java8-unlimited-jce-policy/local
34        if [ -d "$RET" -a -f "$RET"/$FILENAME ]; then
35                echo "Installing from local file $RET/$FILENAME"
36                cp -f -p "$RET"/$FILENAME ${FILENAME}_TEMP
37                mv -f ${FILENAME}_TEMP $FILENAME
38        else # no local file
39                # use apt proxy
40                APT_PROXIES=$(apt-config shell \
41                http_proxy Acquire::http::Proxy \
42                https_proxy Acquire::https::Proxy \
43                ftp_proxy Acquire::ftp::Proxy \
44                dl_direct Acquire::http::Proxy::download.oracle.com \
45                )
46
47                [ -n "$APT_PROXIES" ] && eval export $APT_PROXIES
48
49                if [ "$dl_direct" = "DIRECT" ]; then
50                        unset http_proxy
51                        unset https_proxy
52                        unset ftp_proxy
53                fi
54
55                # setting wget options
56                :> wgetrc
57                echo "noclobber = off" >> wgetrc
58                echo "dir_prefix = ." >> wgetrc
59                echo "dirstruct = off" >> wgetrc
60                echo "verbose = on" >> wgetrc
61                echo "progress = dot:mega" >> wgetrc
62                echo "tries = 2" >> wgetrc
63
64                # downloading nlimited JCE Policy for Oracle Java 8
65                echo "Downloading Unlimited JCE Policy for Oracle Java 8..."
66                WGETRC=wgetrc wget --continue --no-check-certificate -O $FILENAME --header "Cookie: oraclelicense=a" $PARTNER_URL \
67                        || fp_exit_with_error "download failed"
68                echo "Download done."
69        fi # end if local file
70
71        # Removing outdated cached downloads
72        echo "Removing outdated cached downloads..."
73        rm -vrf $J_DIR
74
75        # Verify SHA256 checksum of (copied or downloaded) tarball
76        echo "$SHA256SUM_TGZ  $FILENAME" | sha256sum -c > /dev/null 2>&1 \
77                || fp_exit_with_error "sha256sum mismatch $FILENAME"
78
79        # Unpacking and checking the plugin
80        unzip $FILENAME || fp_exit_with_error "Cannot unpack Unlimited JCE Policy for Oracle Java 8"
81}
82
83### Main
84
85# Create dirs
86mkdir -p /var/cache/oracle-jdk8-installer /usr/lib/jvm /usr/lib/oracle-jdk8-installer-unpackdir
87
88fp_download_and_unpack
89
90# Copy it to the right dir
91if [ -e /usr/lib/jvm/java-8-oracle/jre/lib/security ]; then
92        cp -rf $NEWDIR/$J_DIR/*.jar /usr/lib/jvm/java-8-oracle/jre/lib/security/
93fi
94
95db_fset oracle-java8-unlimited-jce-policy/local seen false
96
97echo "Unlimited JCE Policy for Oracle Java 8 istalled"
98
99#DEBHELPER#
100
101exit 0
102
103# vim: ts=2 sw=2
Note: See TracBrowser for help on using the repository browser.