summaryrefslogtreecommitdiff
path: root/tests/morphcache
diff options
context:
space:
mode:
Diffstat (limited to 'tests/morphcache')
-rwxr-xr-xtests/morphcache31
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/morphcache b/tests/morphcache
new file mode 100755
index 0000000..1b355b0
--- /dev/null
+++ b/tests/morphcache
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+if [ "$#" -ne 4 ]; then
+ echo usage: $0 CACHE_SERVER_IP REPO REF FILENAME
+ exit 1
+fi
+
+rawurlencode() {
+ local string="${1}"
+ local strlen=${#string}
+ local encoded=""
+
+ for (( pos=0 ; pos<strlen ; pos++ )); do
+ c=${string:$pos:1}
+ case "$c" in
+ [-_.~a-zA-Z0-9] ) o="${c}" ;;
+ * )
+ printf -v o '%%%02x' "'$c"
+ esac
+ encoded+="${o}"
+ done
+
+ echo "${encoded}"
+}
+
+CACHE_SERVER_IP=$1
+REPO=$(rawurlencode "$2")
+REF=$(rawurlencode "$3")
+FILENAME=$(rawurlencode "$4")
+
+exec wget -O /dev/null "http://${CACHE_SERVER_IP}:8080/1.0/files?repo=${REPO}&ref=${REF}&filename=${FILENAME}"