Last active
August 2, 2022 08:39
-
-
Save mbierman/5884a0326f81093471c97eddcffdcacb to your computer and use it in GitHub Desktop.
pihole stuff
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
retain=30 | |
# This script will create a Teleport backup to a directory that it is run in. | |
# Change to mapped directory | |
cd /home/ubuntu/backups | |
# Run Backup | |
pihole -a -t & | |
# Record the process id and wait | |
process_id=$! | |
wait $process_id | |
echo -e "\n\nBackup complete with status $?" | |
echo -e "\n\nRemoving files older than $retain days..." | |
find /home/ubuntu/backups/* -type f -mtime +1 -exec ls {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 3 * * mon,wed,fri root echo $(date) > /var/log/pihole_updateGravity.log ; /usr/local/bin/pihole updateGravity | tee -a /var/log/pihole_updateGravity.log | |
@reboot /home/ubuntu/bin/reboot.sh | |
45 2 * * * /home/ubuntu/bin/backup.sh |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dir="/home/ubuntu/bin" | |
IFTTTKEY="$(cat $dir/rebootdata.txt | grep IFTTTKEY | cut -f2 -d "=" )" | |
IFTTTrigger="$(cat $dir/rebootdata.txt | grep IFTTTTrigger | cut -f2 -d "=" )" | |
name=$(hostname) | |
IMAGE="https://developer.asustor.com/uploadIcons/0020_110807_1589822880_icon%20256.png" | |
URL="http://pie.hole/admin" # opens the firewalla app on iOS | |
log="/var/log/reboot.log" | |
echo "US/Pacific" | sudo tee /etc/timezone | |
sudo dpkg-reconfigure --frontend noninteractive tzdata | |
maxpacket=$(grep -w "edns-packet-max=1232" /etc/dnsmasq.d/99-edns.conf) | |
if [ "$maxpacket" = "edns-packet-max=1232" ] ; then | |
echo "Packet is good" | |
else | |
echo "Fixng packet size..." | |
sudo touch /etc/dnsmasq.d/99-edns.conf | |
sudo chmod a+wr /etc/dnsmasq.d/99-edns.conf | |
sudo echo "edns-packet-max=1232" > /etc/dnsmasq.d/99-edns.conf | |
sudo service unbound restart | |
fi | |
sudo touch $log | |
sudo chmod a+wr $log | |
echo -e Rebooted at $(date -d "100 seconds ago") | tee -a /var/log/reboot.log | |
pushAlert () { | |
# This requires an IFTTT pro key | |
if [ -n "IFTTTKEY" ]; then curl -X POST -H "Content-Type: application/json" --data "$json" https://maker.ifttt.com/trigger/$IFTTTrigger/with/key/$IFTTTKEY fi | |
} | |
pushAlert $URL $IMAGE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment