From 271cd9428ac50ffbd1ac2a4776c270219bb044dc Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Wed, 27 Dec 2023 07:25:48 +0100 Subject: [PATCH] update IPs on restore --- scripts/restore | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/restore b/scripts/restore index c342dbc..e4abd84 100644 --- a/scripts/restore +++ b/scripts/restore @@ -41,6 +41,21 @@ ynh_script_progression --message="Restoring the app main directory..." --weight= ynh_restore_file --origin_path="$install_dir" +# we need to update IP adresses in case the backup is restored in a different +# environment, else AGH will try to bind port 53 on non-existent IPs and crash + +# get IPv4 for the AGH config file +ipv4_route_output=$(echo "$(ip -4 route get 1.2.3.4 2> /dev/null)" | head -n1 | head -n1) +ipv4_addr=$(process_ips "$ipv4_route_output") + +# get IPv6 for the AGH config file +ipv6_route_output=$(echo "$(ip -6 route get ::1.2.3.4 2> /dev/null)" | head -n1) +ipv6_addr=$(process_ips "$ipv6_route_output") + +# update the IP adresses in the AGH config file +update_config + + # this will be treated as a security issue. chmod 750 "$install_dir" chmod -R o-rwx "$install_dir"