From 06737daaa3463a104a60703ba0b53a59dfcde479 Mon Sep 17 00:00:00 2001 From: OniriCorpe Date: Mon, 1 Jan 2024 04:09:11 +0100 Subject: [PATCH] declare needs_exposed_ports according to real user need --- scripts/config | 7 ++++--- scripts/install | 7 ++++--- scripts/restore | 7 ++++--- scripts/upgrade | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/scripts/config b/scripts/config index 9830f79..1603614 100644 --- a/scripts/config +++ b/scripts/config @@ -83,11 +83,12 @@ set__dns_over_https() { ynh_print_warn --message="The variable 'dns_over_https' should be 'true' or 'false' but isn't, please report this." fi - if [[ $dns_over_https == 0 ]] && [[ $expose_port_53 == 0 ]]; then + # declare needs_exposed_ports according to real user need + if [ "$dns_over_https" == "true" ] && [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" "$port_dns_over_http" "$port_dns_over_quic" - elif [[ $dns_over_https == 0 ]]; then + elif [ "$dns_over_https" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "$port_dns_over_http" "$port_dns_over_quic" - elif [[ $expose_port_53 == 0 ]]; then + elif [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" else yunohost service add "$app" --description="Ads & trackers blocking DNS server" diff --git a/scripts/install b/scripts/install index ca36abc..6f28b8b 100644 --- a/scripts/install +++ b/scripts/install @@ -109,11 +109,12 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=1 # Create a dedicated systemd config ynh_add_systemd_config -if [[ $dns_over_https == 0 ]] && [[ $expose_port_53 == 0 ]]; then +# declare needs_exposed_ports according to real user need +if [ "$dns_over_https" == "true" ] && [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $dns_over_https == 0 ]]; then +elif [ "$dns_over_https" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $expose_port_53 == 0 ]]; then +elif [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" else yunohost service add "$app" --description="Ads & trackers blocking DNS server" diff --git a/scripts/restore b/scripts/restore index eb40af5..c3a5e64 100644 --- a/scripts/restore +++ b/scripts/restore @@ -80,11 +80,12 @@ ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" ynh_restore_file --origin_path="/etc/systemd/system/$app.service" systemctl enable "$app.service" --quiet -if [[ $dns_over_https == 0 ]] && [[ $expose_port_53 == 0 ]]; then +# declare needs_exposed_ports according to real user need +if [ "$dns_over_https" == "true" ] && [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $dns_over_https == 0 ]]; then +elif [ "$dns_over_https" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $expose_port_53 == 0 ]]; then +elif [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" else yunohost service add "$app" --description="Ads & trackers blocking DNS server" diff --git a/scripts/upgrade b/scripts/upgrade index 60d9665..c49cf15 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -111,11 +111,12 @@ ynh_add_nginx_config # Create a dedicated systemd config ynh_add_systemd_config -if [[ $dns_over_https == 0 ]] && [[ $expose_port_53 == 0 ]]; then +# declare needs_exposed_ports according to real user need +if [ "$dns_over_https" == "true" ] && [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $dns_over_https == 0 ]]; then +elif [ "$dns_over_https" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "$port_dns_over_http" "$port_dns_over_quic" -elif [[ $expose_port_53 == 0 ]]; then +elif [ "$expose_port_53" == "true" ]; then yunohost service add "$app" --description="Ads & trackers blocking DNS server" --needs_exposed_ports "53" else yunohost service add "$app" --description="Ads & trackers blocking DNS server"