forked from paulc4/microservices-demo
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload-archive.sh
More file actions
executable file
·53 lines (43 loc) · 1.48 KB
/
upload-archive.sh
File metadata and controls
executable file
·53 lines (43 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/bin/sh
#Assign script parameters to name variables
export ID_DOMAIN=${1}
export REGION=${2}
export USER_ID=${3}
export USER_PASSWORD=${4}
export APP_NAME=${5}
export ARCHIVE_FILE=${6}
# If config.properties exists then read parameters from it
if [ -e "config.properties" ]; then
echo "Reading config.properties"
. config.properties
fi
if [ -z "$ID_DOMAIN" ] || [ -z "$REGION" ] || [ -z "$USER_ID" ] || [ -z "$USER_PASSWORD" ] || [ -z "$APP_NAME" ] || [ -z "$ARCHIVE_FILE" ]; then
echo "usage: ${0} <id domain> <region us|europe> <user id> <user password> <app name> <archive file name>"
exit -1
fi
if [ "$REGION" != "us" ] && [ "$REGION" != "europe" ]; then
echo "Error: region must be one of 'us' or 'europe'"
exit -1
fi
export ARCHIVE_BASENAME=$(basename "$ARCHIVE_FILE")
# Check to see if $ARCHIVE_FILE exists
if [ ! -e "$ARCHIVE_FILE" ]; then
echo "Error: archive file not found '${ARCHIVE_FILE}'"
exit -1
fi
# CREATE STORAGE CONTAINER
create_container="\
curl -i -X PUT \
-u ${USER_ID}:${USER_PASSWORD} \
https://${ID_DOMAIN}.storage.oraclecloud.com/v1/Storage-$ID_DOMAIN/$APP_NAME"
echo ${create_container}
eval ${create_container}
# PUT ARCHIVE IN STORAGE CONTAINER
put_in_container="\
curl -i -# -X PUT \
-u ${USER_ID}:${USER_PASSWORD} \
https://${ID_DOMAIN}.storage.oraclecloud.com/v1/Storage-$ID_DOMAIN/$APP_NAME/$ARCHIVE_BASENAME \
-T $ARCHIVE_FILE | cat"
echo ${put_in_container}
eval ${put_in_container}
echo '\n[info] Upload to storage complete\n'