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

fix ynh_replace_string

This commit is contained in:
OniriCorpe 2023-12-27 04:57:11 +01:00
parent ac4a27a368
commit 8e746e8bfb

View file

@ -54,19 +54,19 @@ if grep -q "certificate_path: \"\"" "$install_dir/AdGuardHome.yaml" || grep -q "
ynh_replace_string --match_string="enabled: \"\"" --replace_string="enabled: \"$dns_over_https\"" --target_file="$install_dir/AdGuardHome.yaml"
# using sed magic because of the line break :/
sed --in-place "/tls:$/{n;s/enabled: false/enabled: $dns_over_https/}" "$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="server_name: \"\"" --replace_string="server_name: \"$domain\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="server_name: \"\"" --replace_string="server_name: $domain" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="allow_unencrypted_doh: false" --replace_string="allow_unencrypted_doh: true" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="certificate_path: \"\"" --replace_string="certificate_path: \"/etc/yunohost/certs/$domain/crt.pem\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="private_key_path: \"\"" --replace_string="private_key_path: \"/etc/yunohost/certs/$domain/key.pem\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="certificate_path: \"\"" --replace_string="certificate_path: /etc/yunohost/certs/$domain/crt.pem" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="private_key_path: \"\"" --replace_string="private_key_path: /etc/yunohost/certs/$domain/key.pem" --target_file="$install_dir/AdGuardHome.yaml"
fi
# check if one of 'port_https:', 'port_dns_over_tls:' or 'port_dns_over_quic:' uses the default setting
if grep -q "port_https: \"443\"" "$install_dir/AdGuardHome.yaml" || grep -q "port_dns_over_tls: \"853\"" "$install_dir/AdGuardHome.yaml" || grep -q "port_dns_over_quic: \"784\"" "$install_dir/AdGuardHome.yaml"; then
# if so: mandatory replacement for them
# (because the final user can't easily know the ports used by the package)
ynh_replace_string --match_string="port_https: \"443\"" --replace_string="port_https: \"$port_internal_https\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="port_dns_over_tls: \"853\"" --replace_string="port_dns_over_tls: \"$port_dns_over_http\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="port_dns_over_quic: \"784\"" --replace_string="port_dns_over_quic: \"$port_dns_over_quic\"" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="port_https: 443" --replace_string="port_https: $port_internal_https" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="port_dns_over_tls: 853" --replace_string="port_dns_over_tls: $port_dns_over_http" --target_file="$install_dir/AdGuardHome.yaml"
ynh_replace_string --match_string="port_dns_over_quic: 784" --replace_string="port_dns_over_quic: $port_dns_over_quic" --target_file="$install_dir/AdGuardHome.yaml"
fi
if [ -n "${open_port_53:-}" ] && [ "${open_port_53:-}" == "1" ]; then