source: oracle-java7-installer/trunk/fuentes/debian/oracle-java7-unlimited-jce-policy.postinst @ 624

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