-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does not work with pihole DHCP #19
Comments
I threw together a little hard coded version of a keepalive check script that tries to keep dhcpd enabled/disabled appropriately. that takes care of number 3, and the others are very straightforward. #!/bin/bash
set -e
[ "$(docker inspect -f "{{.State.Health.Status}}" pihole)" = "healthy" ] && HEALTHY=0 || HEALTHY=1
PIHOLE_HOME="/home/ohthehugemanatee/pihole"
# if all of these are true, then return 0, else return 1
if [ ${HEALTHY} ]; then
# If we own the primary IP.
if /usr/sbin/ip a |grep -q 10.10.10.40 ; then
# Ensure DHCP is enabled.
if ! [ -f ${PIHOLE_HOME}/dnsmasq.d/02-pihole-dhcp.conf ]; then
/usr/bin/docker exec -d pihole /usr/local/bin/pihole -a enabledhcp "10.10.10.100" "10.10.10.251" "10.10.10.1" "24" "vert"
fi
else
# Ensure DHCP is disabled.
if [ -f ${PIHOLE_HOME}/dnsmasq.d/02-pihole-dhcp.conf ]; then
/usr/bin/docker exec -d pihole /usr/local/bin/pihole -a disabledhcp
fi
fi
exit $HEALTHY
else
exit $HEALTHY
fi
Got any good suggestions for getting those variables into the script? I guess I need to get them from ansible and do it in the template, but if you have them handy as bash vars I'll use that instead. |
I'm now also syncing the whole dnsmasq directory except the dhcp config file, as well as the dhcp leases file. This takes care of numbers 1 and 2. RSYNC_LEASES=$(rsync -a --info=name -e "ssh $key $host_key_check" $target:$pihole_dir/pihole/dhcp.leases $sync_dir)
if [ $? -eq 0 ]; then
if [ -n "$RSYNC_LEASES" ]; then
sudo cp --preserve=timestamps $sync_dir/dhcp.leases $pihole_dir/pihole
fi
fi
if ! [ -d ${pihole_dir}/dnsmasq.d ]; then
mkdir -p ${pihole_dir}/dnsmasq.d
fi
RSYNC_DNSMASQ=$(rsync -a --info=name -e "ssh $key $host_key_check" --exclude '02-pihole-dhcp.conf' $target:$pihole_dir/dnsmasq.d/* $sync_dir/dnsmasq.d/)
if [ $? -eq 0 ]; then
if [ -n "$RSYNC_DNSMASQ" ]; then
sudo cp --preserve=timestamps $sync_dir/dnsmasq.d/* $pihole_dir/dnsmasq.d
fi
fi
The whole setup is working for me... now I'll work on getting it into ansible/templates. |
Though it supports enabling DHCP by variable, some capabilities are missing:
pihole -a enabledhcp
/pihole -a disabledhcp
)dhcp-option=6,${virtual_ip}
into a dnsmasq conf fileI'd send a PR but I'm not sure how to have keepalived trigger a script in response to a change in state. At a guess I could add to the status check script to check if the current node is master or backup and respond accordingly.
The text was updated successfully, but these errors were encountered: