diff --git a/src/datastore_mad/remotes/downloader.sh b/src/datastore_mad/remotes/downloader.sh index 8414c0bb23..237e632b9b 100755 --- a/src/datastore_mad/remotes/downloader.sh +++ b/src/datastore_mad/remotes/downloader.sh @@ -20,9 +20,13 @@ # to determine the file type function get_type { - command=$1 + if [ "$NO_DECOMPRESS" = "yes" ]; then + echo "application/octet-stream" + else + command=$1 - ( $command | head -n 1024 | file -b --mime-type - ) 2>/dev/null + ( $command | head -n 1024 | file -b --mime-type - ) 2>/dev/null + fi } # Gets the command needed to decompress an stream. @@ -113,7 +117,7 @@ function unarchive fi } -TEMP=`getopt -o m:s: -l md5:,sha1: -- "$@"` +TEMP=`getopt -o m:s:n -l md5:,sha1:,nodecomp -- "$@"` if [ $? != 0 ] ; then echo "Arguments error" @@ -134,6 +138,10 @@ while true; do HASH=$2 shift 2 ;; + -n|--nodecomp) + export NO_DECOMPRESS="yes" + shift + ;; --) shift break diff --git a/src/datastore_mad/remotes/fs/cp b/src/datastore_mad/remotes/fs/cp index ba5ffcbfb5..840ac28fd8 100755 --- a/src/datastore_mad/remotes/fs/cp +++ b/src/datastore_mad/remotes/fs/cp @@ -53,7 +53,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/UMASK \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ - /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1) + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS) BASE_PATH="${XPATH_ELEMENTS[0]}" RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}" @@ -62,23 +63,17 @@ UMASK="${XPATH_ELEMENTS[3]}" SRC="${XPATH_ELEMENTS[4]}" MD5="${XPATH_ELEMENTS[5]}" SHA1="${XPATH_ELEMENTS[6]}" +NO_DECOMPRESS="${XPATH_ELEMENTS[7]}" mkdir -p "$BASE_PATH" + set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" DST=`generate_image_path` -HASHES="" +DOWNLOADER_ARGS=`set_downloader_args "$MD5" "$SHA1" "$NO_DECOMPRESS" "$SRC" "$DST"` -if [ -n "$MD5" ]; then - HASHES="$HASHES --md5 $MD5" -fi - -if [ -n "$SHA1" ]; then - HASHES="$HASHES --sha1 $SHA1" -fi - -COPY_COMMAND="$UTILS_PATH/downloader.sh $HASHES $SRC $DST" +COPY_COMMAND="$UTILS_PATH/downloader.sh $DOWNLOADER_ARGS" # ------------ Copy the image to the repository ------------- diff --git a/src/datastore_mad/remotes/iscsi/cp b/src/datastore_mad/remotes/iscsi/cp index 4e2f15a66e..c99b970c16 100755 --- a/src/datastore_mad/remotes/iscsi/cp +++ b/src/datastore_mad/remotes/iscsi/cp @@ -58,7 +58,8 @@ done < <($XPATH /DS_DRIVER_ACTION_DATA/DATASTORE/BASE_PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/PATH \ /DS_DRIVER_ACTION_DATA/IMAGE/SIZE \ /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/MD5 \ - /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1) + /DS_DRIVER_ACTION_DATA/IMAGE/TEMPLATE/SHA1 \ + /DS_DRIVER_ACTION_DATA/DATASTORE/TEMPLATE/NO_DECOMPRESS) BASE_PATH="${XPATH_ELEMENTS[0]}" RESTRICTED_DIRS="${XPATH_ELEMENTS[1]}" @@ -71,6 +72,7 @@ SRC="${XPATH_ELEMENTS[7]}" SIZE="${XPATH_ELEMENTS[8]}" MD5="${XPATH_ELEMENTS[9]}" SHA1="${XPATH_ELEMENTS[10]}" +NO_DECOMPRESS="${XPATH_ELEMENTS[11]}" set_up_datastore "$BASE_PATH" "$RESTRICTED_DIRS" "$SAFE_DIRS" "$UMASK" @@ -93,17 +95,9 @@ REGISTER_CMD=$(cat <