#!/bin/bash #================================================= # GENERIC STARTING #================================================= # IMPORT GENERIC HELPERS #================================================= source _common.sh source /usr/share/yunohost/helpers ynh_abort_if_errors #================================================= # SPECIFIC SETTERS #================================================= set__open_port_53() { if [ "$open_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 ynh_exec_warn_less yunohost firewall reload elif [ "$open_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 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." 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..." # get the name of the network interface in IPv4 and IPv6 ipv4_interface="$(get_network_interface 4)" ipv6_interface="$(get_network_interface 6)" # the 'sed' is used to get rid of the network prefix ('/24' for example) and the router IP ipv4_addr=$(process_ips "$(ip -4 address show "$ipv4_interface" 2> /dev/null | grep inet | sed 's&/.*&&')") # get IPv6 for the AGH config file # the 'sed' is used to get rid of the network prefix ('/64' for example) ipv6_addr=$(process_ips "$(ip -6 address show "$ipv6_interface" 2> /dev/null | grep inet | sed 's&/.*&&')") ynh_print_info --message="Updating the AGH config file..." # update the IP adresses in the AGH config file update_agh_ip_config # save the new setting ynh_app_setting_set "$app" --key=open_port_53 --value="$open_port_53" } set__dns_over_https() { if [ "$dns_over_https" == "true" ]; then 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" ynh_exec_warn_less yunohost firewall reload elif [ "$dns_over_https" == "false" ]; then # else if false, close them 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 else # else, throw error ynh_print_warn --message="The variable 'dns_over_https' should be 'true' or 'false' but isn't, please report this." fi # save the new setting ynh_app_setting_set "$app" --key=dns_over_https --value="$dns_over_https" } #================================================= # GENERIC FINALIZATION #================================================= ynh_app_config_run "$1"