Use fallback IPs for pyartiproxy.
[src/qa-testdefinitions.git] / common / scripts / artiproxy-upload.sh
1 #!/bin/sh
2
3 if [ -z "$PYARTIPROXY_IP" ];then
4
5         echo "DEBUG: No PYARTIPROXY_IP variable, using fallbacks"
6         BAYLIBRE_IP=10.1.1.47
7         AGLCORELAB_IP=192.168.111.1
8
9         if ping -q -W 2 -4 -c 1 $BAYLIBRE_IP ; then 
10                 PYARTIPROXY_IP=$BAYLIBRE_IP
11         fi
12         if ping -q -W 2 -4 -c 1 $AGLCORELAB_IP ; then
13                 PYARTIPROXY_IP=$AGLCORELAB_IP
14         fi
15         if [ -z $PYARTIPROXY_IP ] ; then
16             echo "ERROR: no PYARTIPROXY_IP"
17             exit 1
18         fi
19 fi
20
21 if [ -z "$1" ];then
22         echo "ERROR: missing path argument"
23         exit 1
24 fi
25
26 if [ -z "$2" ];then
27         echo "ERROR: missing filename argument"
28         exit 1
29 fi
30
31 curl --silent --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out
32 if [ $? -ne 0 ];then
33         echo "ERROR: with curl"
34         # retry without silent
35         curl --show-error -F "filename=$2" -F "data=@$1" http://$PYARTIPROXY_IP:9090/cgi-bin/pyartiproxy.py --output curl.out
36 fi
37 ARTI_URL=$(grep -E '^http://.*|https://.*' curl.out)
38 echo "==========================="
39 cat curl.out
40 echo "==========================="
41 if [ -z "$ARTI_URL" ];then
42         # No URL something is wrong
43         lava-test-reference artifactory-$2 --result fail
44         exit 1
45 else
46         lava-test-reference artifactory-$2 --result pass --reference $ARTI_URL
47 fi