#!/bin/bash

set -oux pipefail

# schleuder-api-daemon might take some time to start -- #1078689
sleep 10

function check_reachability {
    curl -g -k -m 5 -s -N https://"$@":4443/status.json | grep -q '{"status":"ok"}' || return 1
}

test_v4=$(check_reachability 127.0.0.1; echo $?)
test_v6=$(check_reachability [::1]; echo $?)

if [ $test_v4 -eq 0 ] || [ $test_v6 -eq 0 ]
then
    exit 0
else
    exit 1
fi
