mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Add DNSmasq regen conf script
This commit is contained in:
parent
8838c692c9
commit
6f99b3f4e1
2 changed files with 48 additions and 0 deletions
41
data/hooks/conf_regen/43-dnsmasq
Normal file
41
data/hooks/conf_regen/43-dnsmasq
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
force=$1
|
||||
|
||||
function safe_copy () {
|
||||
if [[ "$force" == "True" ]]; then
|
||||
sudo yunohost service safecopy \
|
||||
-s dnsmasq $1 $2 --force
|
||||
else
|
||||
sudo yunohost service safecopy \
|
||||
-s dnsmasq $1 $2
|
||||
fi
|
||||
}
|
||||
|
||||
cd /usr/share/yunohost/templates/dnsmasq
|
||||
|
||||
# Get IP address
|
||||
ip=$(curl ip.yunohost.org || echo '0.0.0.0')
|
||||
|
||||
# Get IPv6 IP address
|
||||
ipv6=$(ip route get 2000:: | grep -q "unreachable" && echo '' \
|
||||
|| ip route get 2000:: | grep -v ' fe80:' | grep -v 'cache' | awk '{print $9}')
|
||||
|
||||
sudo mkdir -p /etc/dnsmasq.d
|
||||
|
||||
# Copy a configuration file for each YunoHost domain
|
||||
for domain in $(sudo yunohost domain list --raw); do
|
||||
cat domain.sed \
|
||||
| sed "s/{{ domain }}/$domain/g" \
|
||||
| sed "s/{{ ip }}/$ip/g" \
|
||||
| sudo tee $domain
|
||||
|
||||
if [[ "$ipv6" != "" ]]; then
|
||||
echo "address=/$domain/$ipv6" | sudo tee -a $domain
|
||||
fi
|
||||
|
||||
safe_copy $domain /etc/dnsmasq.d/$domain
|
||||
done
|
||||
|
||||
sudo service dnsmasq reload
|
7
data/templates/dnsmasq/domain.sed
Normal file
7
data/templates/dnsmasq/domain.sed
Normal file
|
@ -0,0 +1,7 @@
|
|||
resolv-file=
|
||||
address=/{{ domain }}/{{ ip }}
|
||||
txt-record={{ domain }},"v=spf1 mx a -all"
|
||||
mx-host={{ domain }},{{ domain }},5
|
||||
srv-host=_xmpp-client._tcp.{{ domain }},{{ domain }},5222,0,5
|
||||
srv-host=_xmpp-server._tcp.{{ domain }},{{ domain }},5269,0,5
|
||||
srv-host=_jabber._tcp.{{ domain }},{{ domain }},5269,0,5
|
Loading…
Add table
Reference in a new issue