199a5d
#!/bin/bash
199a5d
199a5d
if [ -r /etc/rc.d/init.d/functions ]; then
199a5d
	. /etc/rc.d/init.d/functions
199a5d
else
199a5d
success() {
199a5d
	echo $" OK "
199a5d
}
199a5d
199a5d
failure() {
199a5d
	echo -n " "
199a5d
	echo $"FAILED"
199a5d
}
199a5d
fi
199a5d
199a5d
# This script generates /etc/rndc.key if doesn't exist AND if there is no rndc.conf
199a5d
199a5d
if [ ! -s /etc/rndc.key -a ! -s /etc/rndc.conf ]; then
199a5d
  echo -n $"Generating /etc/rndc.key:"
199a5d
  if /usr/sbin/rndc-confgen -a -A hmac-sha256 > /dev/null 2>&1
199a5d
  then
199a5d
    chmod 640 /etc/rndc.key
199a5d
    chown root:named /etc/rndc.key
199a5d
    [ -x /sbin/restorecon ] && /sbin/restorecon /etc/rndc.key
199a5d
    success $"/etc/rndc.key generation"
199a5d
    echo
199a5d
  else
199a5d
    rc=$?
199a5d
    failure $"/etc/rndc.key generation"
199a5d
    echo
199a5d
    exit $rc
199a5d
  fi
199a5d
fi