mirror of
https://github.com/YunoHost-Apps/adguardhome_ynh.git
synced 2024-09-03 18:06:23 +02:00
rework opening/closing ports
This commit is contained in:
parent
7415cc436e
commit
6124db9992
3 changed files with 74 additions and 29 deletions
|
@ -16,26 +16,12 @@ ynh_script_progression --message="Storing installation settings..." --weight=2
|
|||
|
||||
if [[ $dns_over_https == 0 ]]; 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 open."
|
||||
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" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
|
||||
fi
|
||||
|
||||
ynh_app_setting_set --app="$app" --key=dns_over_https --value="$dns_over_https"
|
||||
|
||||
|
||||
# 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
|
||||
|
@ -46,6 +32,34 @@ ynh_app_setting_set --app="$app" --key=expose_port_53 --value="$expose_port_53"
|
|||
|
||||
ynh_app_setting_set --app="$app" --key=new_password --value=""
|
||||
|
||||
#=================================================
|
||||
# PROCESS OPENING/CLOSING PORTS
|
||||
#=================================================
|
||||
|
||||
# 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 [ "${dns_over_https:-}" = true ]; then
|
||||
# if DoH and DoQ are closed
|
||||
if ! yunohost firewall list | grep -q " $port_dns_over_http$" && ! yunohost firewall list | grep -q " $port_dns_over_quic$"; then
|
||||
ynh_print_info --message="Opening DoH and DoQ ports..."
|
||||
ynh_exec_warn_less yunohost firewall allow Both "$port_dns_over_http" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall allow UDP "$port_dns_over_quic"
|
||||
else
|
||||
# no need to open the ports, as they were opened at the 'Provisioning ports' step
|
||||
ynh_print_info --message="DoH and DoQ ports are open."
|
||||
fi
|
||||
else
|
||||
# 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" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
|
|
@ -12,23 +12,32 @@ source /usr/share/yunohost/helpers
|
|||
|
||||
#=================================================
|
||||
# PROCESS OPENING/CLOSING PORTS
|
||||
# no need to open the DoH/DoQ 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 Both "$port_dns_over_http" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
|
||||
fi
|
||||
|
||||
|
||||
# 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 [ "${dns_over_https:-}" = true ]; then
|
||||
# if DoH and DoQ are closed
|
||||
if ! yunohost firewall list | grep -q " $port_dns_over_http$" && ! yunohost firewall list | grep -q " $port_dns_over_quic$"; then
|
||||
ynh_print_info --message="Opening DoH and DoQ ports..."
|
||||
ynh_exec_warn_less yunohost firewall allow Both "$port_dns_over_http" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall allow UDP "$port_dns_over_quic"
|
||||
else
|
||||
# no need to open the ports, as they were opened at the 'Provisioning ports' step
|
||||
ynh_print_info --message="DoH and DoQ ports are open."
|
||||
fi
|
||||
else
|
||||
# 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" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# RESTORE THE APP MAIN DIR
|
||||
#=================================================
|
||||
|
|
|
@ -29,12 +29,6 @@ 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"
|
||||
|
@ -90,6 +84,34 @@ if [ -z "${new_password:-}" ]; then
|
|||
ynh_app_setting_set --app="$app" --key=new_password --value=""
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# PROCESS OPENING/CLOSING PORTS
|
||||
#=================================================
|
||||
|
||||
# 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 [ "${dns_over_https:-}" = true ]; then
|
||||
# if DoH and DoQ are closed
|
||||
if ! yunohost firewall list | grep -q " $port_dns_over_http$" && ! yunohost firewall list | grep -q " $port_dns_over_quic$"; then
|
||||
ynh_print_info --message="Opening DoH and DoQ ports..."
|
||||
ynh_exec_warn_less yunohost firewall allow Both "$port_dns_over_http" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall allow UDP "$port_dns_over_quic"
|
||||
else
|
||||
# no need to open the ports, as they were opened at the 'Provisioning ports' step
|
||||
ynh_print_info --message="DoH and DoQ ports are open."
|
||||
fi
|
||||
else
|
||||
# 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" --no-reload
|
||||
ynh_exec_warn_less yunohost firewall disallow UDP "$port_dns_over_quic"
|
||||
fi
|
||||
|
||||
#=================================================
|
||||
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||
#=================================================
|
||||
|
|
Loading…
Add table
Reference in a new issue