diff --git a/install.sh b/install.sh index d7098f1c..9f3431b1 100644 --- a/install.sh +++ b/install.sh @@ -929,63 +929,37 @@ create_rdnc() { chmod 777 /etc/bind/ cp -r /etc/openpanel/bind9/* /etc/bind/ - # only on ubuntu systemd-resolved is installed - if [ -f /etc/os-release ] && grep -q "Ubuntu" /etc/os-release; then - echo " DNSStubListener=no" >> /etc/systemd/resolved.conf && systemctl restart systemd-resolved - # debian12 also! - elif [ -f /etc/os-release ] && grep -q "Debian" /etc/os-release; then - echo " DNSStubListener=no" >> /etc/systemd/resolved.conf && systemctl restart systemd-resolved - fi - - RNDC_KEY_PATH="/etc/bind/rndc.key" - RETRY_LIMIT_FOR_RDNC=5 - RETRY_COUNT_RDNC=0 - - if [ ! -f "$RNDC_KEY_PATH" ]; then - echo "Generating rndc.key for DNS zone management." - - while [ $RETRY_COUNT_RDNC -lt $RETRY_LIMIT_FOR_RDNC ]; do - debug_log "Attempt $((RETRY_COUNT_RDNC + 1)) to generate rndc.key..." - - # Run the Docker command to generate rndc.key - debug_log timeout 30 docker run -it --rm \ - -v /etc/bind/:/etc/bind/ \ - --entrypoint=/bin/sh \ - ubuntu/bind9:latest \ - -c 'rndc-confgen -a -A hmac-sha256 -b 256 -c /etc/bind/rndc.key' - - if [ $? -ne 0 ]; then - echo "Error: Generating rndc.key failed." | tee -a "$LOG_FILE" - if grep -q "Unable to find image 'ubuntu/bind9:latest' locally" "$LOG_FILE" && - grep -q "dial tcp: lookup registry-1.docker.io" "$LOG_FILE"; then - radovan 1 "Failed to connect to Docker Registry on port 53 - try setting Google DNS nameservers as suggested in: https://github.com/stefanpejcic/OpenPanel/issues/294 and then retry the installation." - else - echo "Unknown error occurred. Please check the log for details." | tee -a "$LOG_FILE" - fi - - # Check if the file exists - if [ -f "$RNDC_KEY_PATH" ]; then - : - else - debug_log "Error: rndc.key not found after attempt $((RETRY_COUNT_RDNC + 1))." - fi - - RETRY_COUNT_RDNC=$((RETRY_COUNT_RDNC + 1)) - sleep 2 - fi - - done - if [ -f "$RNDC_KEY_PATH" ]; then - echo "rndc.key successfully generated." - else - radovan 1 "Failed to generate rndc.key after $RETRY_LIMIT attempts. Exiting." - fi - else - echo "rndc.key already exists." + # Only on Ubuntu and Debian 12, systemd-resolved is installed + if [ -f /etc/os-release ] && grep -qE "Ubuntu|Debian" /etc/os-release; then + echo "DNSStubListener=no" >> /etc/systemd/resolved.conf + systemctl restart systemd-resolved fi -chmod 0777 -R /etc/bind + RNDC_KEY_PATH="/etc/bind/rndc.key" + if [ -f "$RNDC_KEY_PATH" ]; then + echo "rndc.key already exists." + chmod 0777 -R /etc/bind + return 0 + fi + + echo "Generating rndc.key for DNS zone management." + + timeout 30 docker run --rm \ + -v /etc/bind/:/etc/bind/ \ + --entrypoint=/bin/sh \ + ubuntu/bind9:latest \ + -c 'rndc-confgen -a -A hmac-sha256 -b 256 -c /etc/bind/rndc.key' + + # Check if rndc.key was successfully generated + if [ -f "$RNDC_KEY_PATH" ]; then + echo "rndc.key successfully generated." + else + echo "Error: Failed to generate rndc.key. Check logs for details." + exit 1 + fi + + chmod 0777 -R /etc/bind }