|
| 1 | +#!/bin/bash |
| 2 | +set -e |
| 3 | + |
| 4 | +if [ "$ORACLE_OTN_USER" == "" ] || [ "$ORACLE_OTN_PASSWORD" == "" ]; then |
| 5 | + echo "Error: Oracle OTN username/password not specified." |
| 6 | + exit 1 |
| 7 | +fi |
| 8 | + |
| 9 | +PRODUCT="" |
| 10 | + |
| 11 | +# Call the casperjs script to return the download url. |
| 12 | +# Then download the file using curl. |
| 13 | +downloadFile() { |
| 14 | + downloadUrl=$(exec casperjs download.js $ORACLE_OTN_USER $ORACLE_OTN_PASSWORD $1 $2) |
| 15 | + downloadUrl=${downloadUrl%$'\r'} |
| 16 | + echo "DownloadURL: $downloadUrl" |
| 17 | + curl -o $3 -L "$downloadUrl" |
| 18 | +} |
| 19 | + |
| 20 | +############################# |
| 21 | +########### START ########### |
| 22 | +############################# |
| 23 | + |
| 24 | +while getopts "p:" OPTNAME; do |
| 25 | + case "${OPTNAME}" in |
| 26 | + "p") PRODUCT="${OPTARG}" ;; |
| 27 | + esac |
| 28 | +done |
| 29 | + |
| 30 | +if [ "$PRODUCT" == "se12c" ]; then |
| 31 | + agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" |
| 32 | + downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_se2_1of2.zip" |
| 33 | + outputFile=linuxamd64_12102_database_se2_1of2.zip |
| 34 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 35 | + agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" |
| 36 | + downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_se2_2of2.zip" |
| 37 | + outputFile=linuxamd64_12102_database_se2_2of2.zip |
| 38 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 39 | + exit 0 |
| 40 | +fi |
| 41 | + |
| 42 | +if [ "$PRODUCT" == "ee12c" ]; then |
| 43 | + agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" |
| 44 | + downloadUrl="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_1of2.zip" |
| 45 | + outputFile=linuxamd64_12102_database_1of2.zip |
| 46 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 47 | + agreementUrl="http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html" |
| 48 | + DOWNLOAD_URL="http://download.oracle.com/otn/linux/oracle12c/121020/linuxamd64_12102_database_2of2.zip" |
| 49 | + outputFile=linuxamd64_12102_database_2of2.zip |
| 50 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 51 | + exit 0 |
| 52 | +fi |
| 53 | + |
| 54 | +if [ "$PRODUCT" == "xe11g" ]; then |
| 55 | + agreementUrl="http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html" |
| 56 | + downloadUrl="https://edelivery.oracle.com/akam/otn/linux/oracle11g/xe/oracle-xe-11.2.0-1.0.x86_64.rpm.zip" |
| 57 | + outputFile=oracle-xe-11.2.0-1.0.x86_64.rpm.zip |
| 58 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 59 | + exit 0 |
| 60 | +fi |
| 61 | + |
| 62 | +if [ "$PRODUCT" == "sqlcl" ]; then |
| 63 | + agreementUrl="http://www.oracle.com/technetwork/developer-tools/sqlcl/downloads/index.html" |
| 64 | + downloadUrl="https://download.oracle.com/otn/java/sqldeveloper/sqlcl-18.3.0.259.2029.zip" |
| 65 | + #downloadUrl="https://download.oracle.com/otn/java/sqldeveloper/sqlcl-19.2.1.206.1649.zip" |
| 66 | + outputFile=sqlcl-18.3.0.259.2029.zip |
| 67 | + downloadFile $agreementUrl $downloadUrl $outputFile |
| 68 | + exit 0 |
| 69 | +fi |
| 70 | + |
| 71 | +echo "Error: invalid product: $PRODUCT" |
| 72 | +exit 1 |
0 commit comments