diff --git a/scripts/config b/scripts/config index 1603614..28795cd 100644 --- a/scripts/config +++ b/scripts/config @@ -17,19 +17,6 @@ ynh_abort_if_errors set__expose_port_53() { - if [ "$expose_port_53" == "true" ]; then - ynh_print_info --message="Opening port 53..." - # if the user would expose port 53 to the Internet, open it - ynh_exec_warn_less yunohost firewall allow Both 53 - elif [ "$expose_port_53" == "false" ]; then - # else if false, close it - ynh_print_info --message="Closing port 53..." - ynh_exec_warn_less yunohost firewall disallow Both 53 - else - # else, throw error - ynh_print_warn --message="The variable 'expose_port_53' should be 'true' or 'false' but isn't, please report this." - fi - # regenerate config, needed to add or delete public IPs following the user's choice ynh_print_info --message="Obtaining IP addresses for the AGH config file..." diff --git a/scripts/install b/scripts/install index 6f28b8b..a6fc925 100644 --- a/scripts/install +++ b/scripts/install @@ -29,8 +29,13 @@ fi ynh_app_setting_set --app="$app" --key=dns_over_https --value="$dns_over_https" -ynh_print_info --message="Opening port 53..." -ynh_exec_warn_less yunohost firewall allow Both 53 + +# if the port 53 is not open, open it, it's mandatory to use AGH +if ! yunohost firewall list | grep -q " 53$"; then + ynh_print_info --message="Opening port 53..." + ynh_exec_warn_less yunohost firewall allow Both 53 +fi + if [[ $expose_port_53 == 0 ]]; then expose_port_53="true" else diff --git a/scripts/restore b/scripts/restore index c3a5e64..af315a0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -22,8 +22,10 @@ if [ "$dns_over_https" == "false" ]; then ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic" fi -if [ "$expose_port_53" == "true" ]; then - # if expose_port_53 is true, we need to open port 53 + +# if the port 53 is not open, open it, it's mandatory to use AGH +if ! yunohost firewall list | grep -q " 53$"; then + ynh_print_info --message="Opening port 53..." ynh_exec_warn_less yunohost firewall allow Both 53 fi diff --git a/scripts/upgrade b/scripts/upgrade index c49cf15..0a3d6ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -29,18 +29,21 @@ ynh_systemd_action --service_name="$app" --action="stop" #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +# if the port 53 is not open, open it, it's mandatory to use AGH +if ! yunohost firewall list | grep -q " 53$"; then + ynh_print_info --message="Opening port 53..." + ynh_exec_warn_less yunohost firewall allow Both 53 +fi + if [ -z "${expose_port_53:-}" ] && [ "${expose_port_53:-}" = true ]; then expose_port_53="true" ynh_app_setting_set --app="$app" --key=expose_port_53 --value="$expose_port_53" - # if expose_port_53 is true, we need to open port 53 - ynh_print_info --message="Opening port 53..." - ynh_exec_warn_less yunohost firewall allow Both 53 elif [ -n "${expose_port_53:-}" ] || [ "${expose_port_53:-}" = false ]; then expose_port_53="false" ynh_app_setting_set --app="$app" --key=expose_port_53 --value="$expose_port_53" - ynh_print_info --message="Port 53 is closed." fi + if [ -z "${dns_over_https:-}" ] && [ "${dns_over_https:-}" = true ]; then dns_over_https="true" ynh_app_setting_set --app="$app" --key=dns_over_https --value=$dns_over_https