From 3e7974fd907163fa27457e36e5d5c858e641c472 Mon Sep 17 00:00:00 2001 From: Stefan Pejcic Date: Mon, 26 Aug 2024 18:37:36 +0200 Subject: [PATCH] Update UPDATE.sh --- version/0.2.6/UPDATE.sh | 53 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/version/0.2.6/UPDATE.sh b/version/0.2.6/UPDATE.sh index 8711c39c..d22130d5 100644 --- a/version/0.2.6/UPDATE.sh +++ b/version/0.2.6/UPDATE.sh @@ -99,12 +99,15 @@ FUNCTIONS=( # update admin from github download_new_admin + # for 026 dns only + dns_key_and_reload + # update opencli opencli_update # ping us verify_license - + # openpanel/openpanel should be downloaded now! docker_compose_up_with_newer_images @@ -157,7 +160,55 @@ print_space_and_line() { +dns_key_and_reload(){ + + # generate key + 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' + + # add to file + # Define file paths + named_conf_local="/etc/bind/named.conf.local" + rndc_key="/etc/bind/rndc.key" +# Check if /etc/bind/rndc.key is already in named.conf.local +if ! grep -q "$rndc_key" "$named_conf_local"; then + # Create a temporary file + temp_file=$(mktemp) + + cat << EOF > "$temp_file" +// It is recommended to create a key and configure Bind to listen to commands +// sent via rndc. However, it will function just fine without the following +// four lines. +include "$rndc_key"; +controls { + inet 127.0.0.1 allow { localhost; } keys { "rndc-key"; }; +}; +EOF + + # Append the contents of the original named.conf.local to the temporary file + cat "$named_conf_local" >> "$temp_file" + + # Move the temporary file to replace the original named.conf.local + mv "$temp_file" "$named_conf_local" + + echo "The necessary configuration has been added to $named_conf_local." + + docker restart openpanel_dns + + echo "openpanel_dns dontainer restarted to apply the new conf from: $named_conf_local." + + +else + echo "$rndc_key is already configured in $named_conf_local." +fi + + + +}