 diff --git a/src/tm_mad/tm_common.sh b/src/tm_mad/tm_common.sh
-index 0f589fe..1e98122 100644
+index 0f589fe..dcd03cb 100644
 --- a/src/tm_mad/tm_common.sh
 +++ b/src/tm_mad/tm_common.sh
-@@ -145,3 +145,56 @@ function timeout_exec_and_log
+@@ -145,3 +145,65 @@ function timeout_exec_and_log
          exit $CMD_CODE
      fi
  }
-+ 
++
 +function download_extract
 +{
 +    URL=$1

+{
+    ARCHIVE=$1
+    OUTPUT=$2
+
+    if [ $(file_ends_with $ARCHIVE '.tar.gz') = 0 ]; then
+        $FORMAT=z
+    elif [ $(file_ends_with $ARCHIVE '.tar.bz2') = 0 ]; then
+        $FORMAT=j
+    elif [ $(file_ends_with $ARCHIVE '.tar.xz') = 0 ]; then
+        $FORMAT=J
+    fi
+
+    TAR_CMD="tar -x${FORMAT}f $ARCHIVE"
+
+    if [ "x$OUTPUT" != "x" ]; then
+        $TAR_CMD -O > $OUTPUT
+    else
+        $TAR_CMD
+    fi
+}
+

+    HOST=$4
+
+    if [ "x$HOST" != "x" ]; then
+        SSH_CMD="ssh $HOST"
+    fi
+
+    $SSH_CMD curl -k -o $ARCHIVE $URL
+
+    extract_tar $ARCHIVE $FILENAME $HOST
+
+    $SSH_CMD rm -rf $ARCHIVE
+}
+
+function file_ends_with
