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