c4b7dbec0865b2f3448d261322e0dd2af6d693ab
[src/qa-testdefinitions.git] / common / scripts / artiproxy-upload.sh
1 #!/bin/sh
2
3 if [ -z "$PYARTIPROXY_IP" ];then
4         #echo "ERROR: cannot upload, no PYARTIPROXY_IP"
5         #exit 1
6         # TODO: lab-baylibre-agl does not get env as it should be. I will debug this later.
7         echo "DEBUG: No PYARTIPROXY_IP variable, fallback to baylibre one"
8         PYARTIPROXY_IP=10.1.1.47
9 fi
10
11 if [ -z "$1" ];then
12         echo "ERROR: missing path argument"
13         exit 1
14 fi
15
16 if [ -z "$2" ];then
17         echo "ERROR: missing filename argument"
18         exit 1
19 fi
20
21 curl --silent --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out
22 if [ $? -ne 0 ];then
23         echo "ERROR: with curl"
24         # retry without silent
25         curl --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out
26 fi
27 ARTI_URL=$(grep -E '^http://.*|https://.*' curl.out)
28 echo "==========================="
29 cat curl.out
30 echo "==========================="
31 if [ -z "$ARTI_URL" ];then
32         # No URL something is wrong
33         lava-test-reference artifactory-$2 --result fail
34         exit 1
35 else
36         lava-test-reference artifactory-$2 --result pass --reference $ARTI_URL
37 fi