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

handle closing unnecessary ports at restore and upgrade

This commit is contained in:
OniriCorpe 2023-12-26 23:14:07 +01:00
parent 0475073364
commit 8aa3f1508b
2 changed files with 21 additions and 0 deletions

View file

@ -10,6 +10,20 @@
source ../settings/scripts/_common.sh source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers source /usr/share/yunohost/helpers
#=================================================
# CLOSE UNNECESSARY PORTS
# no need to open the ports, as they were opened at the 'Provisioning ports' step
#=================================================
if [ "$dns_over_https" == "false" ]; then
# if dns_over_https is false, we need to close ports,
# as they were opened at the 'Provisioning ports' step
ynh_exec_warn_less yunohost firewall disallow --no-upnp TCP "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow --no-upnp UDP "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow --no-upnp UDP "$port_dns_over_quic"
ynh_exec_warn_less yunohost firewall reload
fi
#================================================= #=================================================
# RESTORE THE APP MAIN DIR # RESTORE THE APP MAIN DIR
#================================================= #=================================================

View file

@ -33,10 +33,17 @@ if [ -n "$dns_over_https" ] && [ "$dns_over_https" == "1" ];
then then
dns_over_https="true" dns_over_https="true"
ynh_app_setting_set --app="$app" --key=dns_over_https --value=$dns_over_https ynh_app_setting_set --app="$app" --key=dns_over_https --value=$dns_over_https
# no need to open the ports, as they were opened at the 'Provisioning ports' step
elif [ -z "$dns_over_https" ] || [ "$dns_over_https" == "0" ]; elif [ -z "$dns_over_https" ] || [ "$dns_over_https" == "0" ];
then then
dns_over_https="false" dns_over_https="false"
ynh_app_setting_set --app="$app" --key=dns_over_https --value=$dns_over_https ynh_app_setting_set --app="$app" --key=dns_over_https --value=$dns_over_https
# if dns_over_https is false, we need to close ports,
# as they were opened at the 'Provisioning ports' step
ynh_exec_warn_less yunohost firewall disallow --no-upnp TCP "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow --no-upnp UDP "$port_dns_over_http"
ynh_exec_warn_less yunohost firewall disallow --no-upnp UDP "$port_dns_over_quic"
ynh_exec_warn_less yunohost firewall reload
fi fi
#================================================= #=================================================