Skip to content

Commit c9b7d00

Browse files
committed
Added missing download scripts
1 parent 2a97024 commit c9b7d00

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

.travis/download.js

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
var casper = require("casper").create({
3+
// verbose: true,
4+
// logLevel: "debug",
5+
pageSettings: {
6+
loadImages: false,
7+
loadPlugins: false
8+
}
9+
});
10+
11+
if (casper.cli.args.length < 4) {
12+
casper.echo("Missing parameters: username password agreementUrl downloadUrl").exit(1);
13+
}
14+
15+
// Script parameters.
16+
var paramUsername = casper.cli.get(0);
17+
var paramPassword = casper.cli.get(1);
18+
var agreementUrl = casper.cli.get(2);
19+
var downloadUrl = casper.cli.get(3);
20+
var downloaded = false;
21+
22+
casper.start();
23+
// TODO: Error handling.
24+
25+
// Accept the license agreement.
26+
casper.thenOpen(agreementUrl, function () {
27+
// this.echo("Accepting License");
28+
this.evaluate(function () {
29+
acceptAgreement(window.self);
30+
});
31+
});
32+
33+
// Try to access the download page, wait for redirection and submit the login form.
34+
casper.thenOpen(downloadUrl).waitForUrl(/signon\.jsp$/, function (re) {
35+
// this.echo("Injecting Login Info");
36+
this.evaluate(function (username, password) {
37+
document.getElementById("sso_username").value = username;
38+
document.getElementById("ssopassword").value = password;
39+
doLogin(document.LoginForm);
40+
}, paramUsername, paramPassword);
41+
// this.capture("Screenshot.png");
42+
});
43+
44+
casper.on("resource.received", function (resource) {
45+
if (resource.url.indexOf("AuthParam") !== -1 && !downloaded) {
46+
// this.echo("DownloadUrl:");
47+
// Print the download url.
48+
this.echo(resource.url);
49+
downloaded = true;
50+
// TODO: Try to download file from here. this.download is not working because of cross site request.
51+
}
52+
});
53+
54+
casper.run(function () {
55+
this.exit();
56+
});

.travis/download.sh

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
outputFile=sqlcl-18.3.0.259.2029.zip
66+
downloadFile $agreementUrl $downloadUrl $outputFile
67+
exit 0
68+
fi
69+
70+
echo "Error: invalid product: $PRODUCT"
71+
exit 1

0 commit comments

Comments
 (0)