Kimsufi availability

18 Oct 2016

A few weeks ago, I try to change my old Kimsufi but I discover OVH servers are very often out of stock. So, I wrote a small bash script to check availability and open my browser when order is possible!

This script uses jq.

# reference for KS-2A (change if you want another model)
REFERENCE='160sk2'

while true;
do
    # request list of availability and parse response
    c=$(curl -s https://ws.ovh.com/dedicated/r2/ws.dispatcher/getAvailability2 \
            | jq ".answer.availability[] | select(.reference == \"$REFERENCE\") | .metaZones[] | select(.availability != \"unavailable\" and .availability != \"unknown\")" \
            | wc -l);

    # reference is available? open browser and end loop!
    if [[ $c -gt 5 ]];
    then
        firefox https://www.kimsufi.com/fr/commande/kimsufi.xml\?reference\=$REFERENCE && break;
    fi

    # quota is 500 calls / hour
    sleep 7;
done