Skip to content

Instantly share code, notes, and snippets.

@jftuga
Created August 15, 2020 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jftuga/48e008acf7c5e24dbca002311d88cea7 to your computer and use it in GitHub Desktop.
Save jftuga/48e008acf7c5e24dbca002311d88cea7 to your computer and use it in GitHub Desktop.
Update block lists in a dockerized version of PiHole
#!/bin/bash
# Update block lists in a dockerized version of PiHole
# the log file should be: update_pihole_block_lists.log
#
# run this script from cron each Saturday morning with this contab entry:
# 00 3 * * 6 /root/update_pihole_block_lists.sh
IMAGE=pihole
LENGTH=12
LOG="${0%.*}.log"
CONTAINER=$(docker ps --format "{{.ID}}" --filter name=${IMAGE})
if [ "${#CONTAINER}" -ne "${LENGTH}" ] ; then
echo "No running container for image: ${IMAGE}"
exit 1
fi
echo >> ${LOG}
echo >> ${LOG}
echo >> ${LOG}
echo "==============================================================" >> ${LOG}
date >> ${LOG}
echo "==============================================================" >> ${LOG}
docker exec -t ${CONTAINER} pihole updateGravity >> ${LOG} 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment