Fixed some MacOS inconsistency
This commit is contained in:
parent
8ab60370a0
commit
5d2acc0710
@ -28,18 +28,21 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
_DATE=$( date -u +"%Y%m%d" )
|
||||
_DTIME=$( date -u +"%Y%m%dT%H%M%SZ" )
|
||||
_HEADERS="host;x-amz-content-sha256;x-amz-date"
|
||||
_SHA=$( echo -n "" | sha256sum | cut -d' ' -f1 )
|
||||
_SHA=$( _str "" | sha256sum | cut -d' ' -f1 )
|
||||
|
||||
# Canon Request
|
||||
_C="DELETE"
|
||||
@ -56,9 +59,9 @@ _C="$_C\n$_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
@ -29,22 +29,25 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
_TEMP=$( mktemp )
|
||||
function __clean_up { rm $_TEMP; }
|
||||
trap __clean_up EXIT
|
||||
|
||||
echo -n "<Delete>" > $_TEMP
|
||||
_str "<Delete>" > $_TEMP
|
||||
sed "s/.\+/<Object><Key>\0<\/Key><\/Object>/g" $_LIST_SRC | tr -d '\n' >> $_TEMP
|
||||
if [ $? -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
echo -n "</Delete>" >> $_TEMP
|
||||
_str "</Delete>" >> $_TEMP
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
@ -71,9 +74,9 @@ _C="$_C\n$_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
@ -27,18 +27,21 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
_DATE=$( date -u +"%Y%m%d" )
|
||||
_DTIME=$( date -u +"%Y%m%dT%H%M%SZ" )
|
||||
_HEADERS="host;x-amz-content-sha256;x-amz-date"
|
||||
_SHA=$( echo -n "" | sha256sum | cut -d' ' -f1 )
|
||||
_SHA=$( _str "" | sha256sum | cut -d' ' -f1 )
|
||||
|
||||
# Canon Request
|
||||
_C="GET"
|
||||
@ -55,9 +58,9 @@ _C="$_C\n$_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
@ -27,18 +27,21 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
_DATE=$( date -u +"%Y%m%d" )
|
||||
_DTIME=$( date -u +"%Y%m%dT%H%M%SZ" )
|
||||
_HEADERS="host;x-amz-content-sha256;x-amz-date"
|
||||
_SHA=$( echo -n "" | sha256sum | cut -d' ' -f1 )
|
||||
_SHA=$( _str "" | sha256sum | cut -d' ' -f1 )
|
||||
|
||||
# Keys should be sorted
|
||||
QPARAMS=(
|
||||
@ -46,7 +49,7 @@ QPARAMS=(
|
||||
)
|
||||
|
||||
function _urlencode {
|
||||
echo -n $1 | sed "s/\//%2F/g"
|
||||
_str $1 | sed "s/\//%2F/g"
|
||||
}
|
||||
|
||||
_L=${#QPARAMS[@]}
|
||||
@ -78,9 +81,9 @@ _C="$_C\n$_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
@ -24,18 +24,21 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
_DATE=$( date -u +"%Y%m%d" )
|
||||
_DTIME=$( date -u +"%Y%m%dT%H%M%SZ" )
|
||||
_HEADERS="host;x-amz-content-sha256;x-amz-date"
|
||||
_SHA=$( echo -n "" | sha256sum | cut -d' ' -f1 )
|
||||
_SHA=$( _str "" | sha256sum | cut -d' ' -f1 )
|
||||
_PATH=""
|
||||
|
||||
# Keys should be sorted
|
||||
@ -51,7 +54,7 @@ QPARAMS=(
|
||||
)
|
||||
|
||||
function _urlencode {
|
||||
echo -n $1 | sed "s/\//%2F/g"
|
||||
_str $1 | sed "s/\//%2F/g"
|
||||
}
|
||||
|
||||
_L=${#QPARAMS[@]}
|
||||
@ -88,9 +91,9 @@ _C="$_C\n$_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
@ -36,11 +36,14 @@ if [ -z "$ARCH_S3_BUCKET_URL" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET_NAME=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( echo -n $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( echo -n $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
function _str { printf "%s" $@; }
|
||||
function _stre { printf $@; }
|
||||
|
||||
BUCKET_NAME=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f1 )
|
||||
SERVICE=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f2 )
|
||||
REGION=$( _str $ARCH_S3_BUCKET_URL | cut -d'.' -f3 )
|
||||
ACCESS_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f1 )
|
||||
SECRET_KEY=$( _str $ARCH_S3_AUTH | cut -d':' -f2 )
|
||||
|
||||
BUCKET_URL=$ARCH_S3_BUCKET_URL
|
||||
|
||||
@ -72,9 +75,9 @@ _C="$_C\n$_FILE_SHA"
|
||||
_S="AWS4-HMAC-SHA256"
|
||||
_S="$_S\n$_DTIME"
|
||||
_S="$_S\n$_DATE/$REGION/$SERVICE/aws4_request"
|
||||
_S="$_S\n$( echo -ne "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
_S="$_S\n$( _stre "$_C" | sha256sum | cut -d' ' -f1 )"
|
||||
|
||||
function _HMAC { echo -ne "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
function _HMAC { _stre "$2" | openssl dgst -sha256 -hex -mac HMAC -macopt "$1" | cut -d' ' -f2; }
|
||||
|
||||
SIG=$( _HMAC "key:AWS4$SECRET_KEY" "$_DATE" )
|
||||
SIG=$( _HMAC "hexkey:$SIG" "$REGION" )
|
||||
|
Loading…
Reference in New Issue
Block a user