From 64075f2dd99547277a94da6677fbd5e06bb48f6e Mon Sep 17 00:00:00 2001 From: HgO Date: Sun, 20 Aug 2023 17:14:13 +0200 Subject: [PATCH] handle new dns settings --- scripts/upgrade | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/scripts/upgrade b/scripts/upgrade index 72a98b4..a27b9b0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -72,6 +72,31 @@ if [ -z $service_name ]; then ynh_app_setting_set --app=$app --key=service_name --value=$service_name fi +dns=$(ynh_app_setting_get $app dns) +if [[ -n "${dns}" ]]; then + ip6_dns="" + ip4_dns="" + for ip in $(echo "${dns}" | tr ',' ' '); do + if [[ "$ip" == *":"* ]]; then + ip6_dns+="[$ip]," + else + ip4_dns+="$ip," + fi + done + # Remove trailing , + ip6_dns="${ip6_dns%%,}" + ip4_dns="${ip4_dns%%,}" + + if [[ -z "$(ynh_app_setting_get --app=$app --key=ip6_dns)" ]]; then + ynh_app_setting_set --app=$app --key=ip6_dns --value="${ip6_dns}" + if + if [[ -z "$(ynh_app_setting_get --app=$app --key=ip4_dns)" ]]; then + ynh_app_setting_set --app=$app --key=ip4_dns --value="${ip4_dns}" + if + + ynh_app_setting_delete $app dns +fi + # Old stuff prior to 2.x ip6_net=$(ynh_app_setting_get --app=$app --key=ip6_net)