#!/bin/sh set -e . /usr/share/debconf/confmodule ### Variables VER='0.7' # Folders J_INSTALL_DIR=/usr/lib/jvm/java-7-oracle/jre/lib/security OLDDIR=/usr/lib/oracle-jdk7-installer-unpackdir NEWDIR=/var/cache/oracle-jdk7-installer SHA256SUM_TGZ="7a8d790e7bd9c2f82a83baddfae765797a4a56ea603c9150c87b7cdb7800194d" J_DIR=UnlimitedJCEPolicy FILENAME=UnlimitedJCEPolicyJDK7.zip PARTNER_URL=http://download.oracle.com/otn-pub/java/jce/7/$FILENAME ### Functions fp_exit_with_error() { echo $1 echo "Unlimited JCE Policy for Oracle Java 7 is NOT installed." db_fset oracle-java7-unlimited-jce-policy/local seen false exit 1 } fp_download_and_unpack() { cd /var/cache/oracle-jdk7-installer db_get oracle-java7-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 # 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 = 2" >> wgetrc # downloading jdk7 echo "Downloading Unlimited JCE Policy for Oracle Java 7..." 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 # end if local file # 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 7" } ### Main # Create dirs mkdir -p /var/cache/oracle-jdk7-installer /usr/lib/jvm /usr/lib/oracle-jdk7-installer-unpackdir fp_download_and_unpack # Copy it to the right dir if [ -e /usr/lib/jvm/java-7-oracle/jre/lib/security ]; then cp -rf $NEWDIR/$J_DIR/*.jar /usr/lib/jvm/java-7-oracle/jre/lib/security/ fi db_fset oracle-java7-unlimited-jce-policy/local seen false echo "Unlimited JCE Policy for Oracle Java 7 istalled" #DEBHELPER# exit 0 # vim: ts=2 sw=2