Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion tools/bits-upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,34 @@ UPDATES_IMGADM=/root/opt/imgapi-cli/bin/updates-imgadm

PATH=$PATH:/root/opt/node_modules/manta/bin:/opt/tools/bin

function content_type
{
filename="$1"
# basename <name> <.ext> will strip .ext off. Will be == name if it's
# not .ext.
if [[ "$(basename $filename .tgz)" != "$filename" ]]; then
content_type="content-type: application/gzip"
elif [[ "$(basename $filename .gz)" != "$filename" ]]; then
content_type="content-type: application/gzip"
elif [[ "$(basename $filename .txt)" != "$filename" ]]; then
content_type="content-type: text/plain"
elif [[ "$(basename $filename .log)" != "$filename" ]]; then
content_type="content-type: text/plain"
elif [[ "$(basename $filename .html)" != "$filename" ]]; then
content_type="content-type: text/html"
elif [[ "$(basename $filename .json)" != "$filename" ]]; then
content_type="content-type: application/json"
elif [[ "$(basename $filename .iso)" != "$filename" ]]; then
content_type="content-type: application/x-iso9660-image"
else
# Default value... XXX KEBE ASKS use text/plain instead?
content_type="content-type: application/octet-stream"
fi
Comment on lines +80 to +83
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider returning an empty result and let manta sort it out.


# Caller should use quotes around this.
echo $content_type
}

function fatal {
echo "$(basename $0): error: $1"
exit 1
Expand Down Expand Up @@ -155,7 +183,8 @@ function manta_upload {

if [[ -z ${manta_md5} ]]; then
# file doesn't exist, upload it
manta_run mput ${MANTA_VERBOSE} -f ${file} ${manta_object}
manta_run mput -H "$(content_type ${file})" ${MANTA_VERBOSE} \
-f ${file} ${manta_object}
[[ $? == 0 ]] || fatal "Failed to upload ${file} to ${manta_object}"
elif [[ "$BITS_UPLOAD_OVERWRITE" == "false" ]]; then
echo "${manta_object} already exists and matches local file,"
Expand Down