mirror of
https://github.com/eduardogsilva/wireguard_webadmin.git
synced 2025-08-04 18:24:31 +02:00
DNS Container and docker compose
This commit is contained in:
parent
da1513e560
commit
aefd3f698b
18 changed files with 175 additions and 20 deletions
13
containers/dnsmasq/Dockerfile-dnsmasq
Normal file
13
containers/dnsmasq/Dockerfile-dnsmasq
Normal file
|
@ -0,0 +1,13 @@
|
|||
FROM ubuntu:latest
|
||||
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && \
|
||||
apt-get install -y dnsmasq nano inotify-tools psmisc && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
40
containers/dnsmasq/entrypoint.sh
Normal file
40
containers/dnsmasq/entrypoint.sh
Normal file
|
@ -0,0 +1,40 @@
|
|||
#!/bin/bash
|
||||
CONFIG_FILE="/etc/dnsmasq/wireguard_webadmin_dns.conf"
|
||||
DEFAULT_CONFIG_CONTENT="
|
||||
no-dhcp-interface=
|
||||
server=1.1.1.1
|
||||
server=1.0.0.1
|
||||
|
||||
listen-address=0.0.0.0
|
||||
bind-interfaces
|
||||
"
|
||||
|
||||
create_default_config() {
|
||||
if [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "Config file not found, creating a new one..."
|
||||
echo "$DEFAULT_CONFIG_CONTENT" > "$CONFIG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
start_dnsmasq() {
|
||||
dnsmasq -C "$CONFIG_FILE" &
|
||||
while inotifywait -e modify "$CONFIG_FILE"; do
|
||||
echo "Configuration changed, reloading dnsmasq..."
|
||||
pkill dnsmasq
|
||||
sleep 5
|
||||
dnsmasq -C "$CONFIG_FILE" &
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
handle_sigint() {
|
||||
echo "SIGINT received. Stopping inotifywait and dnsmasq..."
|
||||
pkill inotifywait
|
||||
pkill dnsmasq
|
||||
exit 0
|
||||
}
|
||||
|
||||
trap handle_sigint SIGINT
|
||||
|
||||
create_default_config
|
||||
start_dnsmasq
|
Loading…
Add table
Add a link
Reference in a new issue