#!/bin/bash

set -oux pipefail

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

function check_reachability {
    curl --verbose --fail -g -k -m 5 -s -N https://"$@":4443/status.json
}

test_v4=0
check_reachability 127.0.0.1 || test_v4=$?
test_v6=0
check_reachability [::1] || test_v6=$?

systemctl status schleuder-api-daemon.service

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