1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/adguardhome_ynh.git synced 2024-09-03 18:06:23 +02:00

Better user information about ports opening / closing

This commit is contained in:
OniriCorpe 2023-12-27 19:56:29 +01:00
parent ac6df8b708
commit 95f8a53d87
2 changed files with 12 additions and 8 deletions

View file

@ -18,15 +18,15 @@ ynh_abort_if_errors
set__open_port_53() {
if [ "$open_port_53" == "true" ]; then
ynh_script_progression --message="Opening port 53..."
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
yunohost firewall reload
ynh_exec_warn_less yunohost firewall reload
elif [ "$open_port_53" == "false" ]; then
# else if false, close it
ynh_script_progression --message="Closing port 53..."
ynh_print_info --message="Closing port 53..."
ynh_exec_warn_less yunohost firewall disallow Both 53
yunohost firewall reload
ynh_exec_warn_less yunohost firewall reload
else
# else, throw error
ynh_print_warn --message="The variable 'open_port_53' should be 'true' or 'false' but isn't, please report this."
@ -49,17 +49,17 @@ set__open_port_53() {
set__dns_over_https() {
if [ "$dns_over_https" == "true" ]; then
ynh_script_progression --message="Opening DoH and DoQ ports..."
ynh_print_info --message="Opening DoH and DoQ ports..."
# if DNS over HTTPS/QUIC is activated, open the associated ports
ynh_exec_warn_less yunohost firewall allow Both "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall allow UDP "$port_dns_over_quic"
yunohost firewall reload
ynh_exec_warn_less yunohost firewall reload
elif [ "$dns_over_https" == "false" ]; then
# else if false, close them
ynh_script_progression --message="Closing DoH and DoQ ports..."
ynh_print_info --message="Closing DoH and DoQ ports..."
ynh_exec_warn_less yunohost firewall disallow Both "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
yunohost firewall reload
ynh_exec_warn_less yunohost firewall reload
else
# else, throw error
ynh_print_warn --message="The variable 'dns_over_https' should be 'true' or 'false' but isn't, please report this."

View file

@ -17,10 +17,12 @@ ynh_script_progression --message="Storing installation settings..." --weight=2
if "$dns_over_https"; then
dns_over_https="true"
# no need to open the ports, as they were opened at the 'Provisioning ports' step
ynh_print_info --message="DoH and DoQ ports are already closed."
else
dns_over_https="false"
# if dns_over_https is false, we need to close ports,
# as they were opened at the 'Provisioning ports' step
ynh_print_info --message="Closing DoH and DoQ ports..."
ynh_exec_warn_less yunohost firewall disallow Both "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
ynh_exec_warn_less yunohost firewall reload
@ -31,10 +33,12 @@ ynh_app_setting_set --app="$app" --key=dns_over_https --value="$dns_over_https"
if "$open_port_53"; then
open_port_53="true"
# if open_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
ynh_exec_warn_less yunohost firewall reload
else
open_port_53="false"
ynh_print_info --message="Port 53 is already closed."
fi
ynh_app_setting_set --app="$app" --key=open_port_53 --value="$open_port_53"