dnsmasq/entrypoint.sh

31 lines
848 B
Bash
Raw Normal View History

2023-04-13 12:45:03 +00:00
#!/usr/bin/env bash
if [[ ! -f /config/dnsmasq.conf ]]; then
echo "* Creating /config/dnsmasq.conf"
sed 's/^conf-dir=\/etc\//conf-dir=\/config\//g' /etc/dnsmasq.conf > /config/dnsmasq.conf
fi
if [[ ! -f /config/hosts/hosts ]]; then
echo "* Creating /config/hosts/hosts"
mkdir /config/hosts
cp /etc/hosts /config/hosts/hosts
fi
if [[ ! -f /config/resolv.conf ]]; then
echo "* Creating /config/resolv.conf"
cp /etc/resolv.conf /config/resolv.conf
fi
if [[ ! -d /config/dnsmasq.d ]]; then
echo "* Creating /config/dnsmasq.d"
mkdir /config/dnsmasq.d
fi
if [[ "$1" == "start" ]]; then
/usr/sbin/dnsmasq \
--conf-fil=/config/dnsmasq.conf \
--no-daemon --no-hosts \
--keep-in-foreground \
--resolv-file=/config/resolv.conf \
--hostsdir=/config/hosts
else
exec "$@"
fi