Skip to content

Instantly share code, notes, and snippets.

@bdashrad
Created April 18, 2020 16:55
Show Gist options
  • Save bdashrad/3b926f4af7695727cbcfde831a78e85e to your computer and use it in GitHub Desktop.
Save bdashrad/3b926f4af7695727cbcfde831a78e85e to your computer and use it in GitHub Desktop.
pihole sync example
#!/usr/bin/env bash
# Perform maintenance on secondary Pi if online
pi=$(timeout 0.2 ping -c1 10.0.0.3 &> /dev/null && echo "0" || echo "1")
if [ "$jd" -eq 0 ]; then
cd /etc/pihole/
ssh -i /root/.ssh/id.pi "pi@10.0.0.3" "[ ! -f '~/pihole' ] && mkdir ~/pihole"
scp -i /root/.ssh/id.pi adlists.list *list.txt setupVars.conf *.domains pi@10.0.0.3:~/pihole
scp -i /root/.ssh/id.pi /etc/dnsmasq.d/03-pihole-wildcard.conf pi@10.0.0.3:~/pihole/03-pihole-wildcard.conf
ssh -i /root/.ssh/id.pi "pi@10.0.0.3" "sudo mv ~/pihole/03-pihole-wildcard.conf /etc/dnsmasq.d; sudo mv ~/pihole/* /etc/pihole"
ssh -i /root/.ssh/id.pi "pi@10.0.0.3" "pihole -g"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment