Use proper templating for dnsmasq conf

This commit is contained in:
Alexandre Aubin 2020-08-31 16:41:31 +02:00
parent 85ad965e4d
commit bc7344b636
2 changed files with 9 additions and 7 deletions

View file

@ -27,14 +27,13 @@ do_pre_regen() {
ipv6=$(curl -s -6 https://ip6.yunohost.org 2>/dev/null || true)
ynh_validate_ip6 "$ipv6" || ipv6=''
export ipv4
export ipv6
# add domain conf files
for domain in $YNH_DOMAINS; do
cat domain.tpl \
| sed "s/{{ domain }}/${domain}/g" \
| sed "s/{{ ip }}/${ipv4}/g" \
> "${dnsmasq_dir}/${domain}"
[[ -n $ipv6 ]] \
&& echo "address=/${domain}/${ipv6}" >> "${dnsmasq_dir}/${domain}"
export domain
ynh_render_template "domain.tpl" "${dnsmasq_dir}/${domain}"
done
# remove old domain conf files

View file

@ -1,4 +1,7 @@
address=/{{ domain }}/{{ ip }}
address=/{{ domain }}/{{ ipv4 }}
{% if ipv6 %}
address=/{{ domain }}/{{ ipv6 }}
{% endif %}
txt-record={{ domain }},"v=spf1 mx a -all"
mx-host={{ domain }},{{ domain }},5
srv-host=_xmpp-client._tcp.{{ domain }},{{ domain }},5222,0,5