#!/bin/sh
# Readiness of named: "rndc status" reports "server is up and running" --
# named has loaded its configuration and zones and answers the control
# channel. Debian creates /etc/bind/rndc.key on installation; if the key is
# missing, this check says so (check-report) instead of guessing.
r=$(rndc status 2>&1) || { echo "rndc: $(printf '%s' "$r" | head -1)"; exit 1; }
case "$r" in
  *'server is up and running'*) exit 0 ;;
  *) echo "rndc status without 'up and running': $(printf '%s' "$r" | head -1)"; exit 1 ;;
esac
