#!/bin/ash

# Client querying watchdog-server

URL_PREFIX='<URL>'
AlWAYS_OK=0
querrying
# Responses to watchdog-client:
MSG_OK='OK'
MSG_RESTART='NOT OK'

[[ $AlWAYS_OK -eq 1 ]] && exit 0

mac=$(cat /sys/class/net/eth0/address) || exit 1
resp=$(curl -m 5 -f -s "${URL_PREFIX}${mac}")
[[ $? -ne 0 ]] && exit 1

case "$resp" in
  "$MSG_OK")
    exit 0
    ;;
  "$MSG_RESTART")
    exit 64
    ;;
  *)
    exit 1
    ;;
esac

exit 1
