bind/generate-rndc-key.sh

34 lines
677 B
Bash
Raw Normal View History

2019-12-28 09:41:34 +08:00
#!/bin/bash
2020-07-27 17:33:59 +08:00
if [ -r /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
else
success() {
echo $" OK "
}
failure() {
echo -n " "
echo $"FAILED"
}
fi
2019-12-28 09:41:34 +08:00
# This script generates /etc/rndc.key if doesn't exist AND if there is no rndc.conf
if [ ! -s /etc/rndc.key -a ! -s /etc/rndc.conf ]; then
echo -n $"Generating /etc/rndc.key:"
2021-12-04 15:31:20 +08:00
if /usr/sbin/rndc-confgen -a -A hmac-sha256 > /dev/null 2>&1
2019-12-28 09:41:34 +08:00
then
chmod 640 /etc/rndc.key
chown root:named /etc/rndc.key
[ -x /sbin/restorecon ] && /sbin/restorecon /etc/rndc.key
success $"/etc/rndc.key generation"
echo
else
2020-07-27 17:33:59 +08:00
rc=$?
2019-12-28 09:41:34 +08:00
failure $"/etc/rndc.key generation"
echo
2020-07-27 17:33:59 +08:00
exit $rc
2019-12-28 09:41:34 +08:00
fi
fi