Advertisement
ROODAY

ads.sh

Apr 10th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.83 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # ads.sh: Enables or disables ad-blocking list generated
  4. # by gravity.sh. dnsmasq is reloaded following any changes.
  5. # Called without argument toggles the list on or off. If
  6. # time is specified ad-blocking will resume after that time.
  7. # Usage: ads.sh NUM[m/h/d]. Ex: ads.sh 20m
  8.  
  9. list=/etc/pihole/gravity.list
  10. reload() { systemctl restart dnsmasq; }
  11. gravity_on() { mv $list.disabled $list; reload; }
  12. gravity_off() { mv $list $list.disabled; reload; }
  13.  
  14. if [ ! -z "$1" ];then
  15.     if [ -f $list ];then
  16.         gravity_off & echo "Ad-blocking disabled for $1"
  17.         ( sleep $1 && gravity_on ) &
  18.     else
  19.         echo "Ad-blocking already disabled"
  20.     fi
  21. else
  22.     if [ -f $list ];then
  23.         gravity_off & echo "Ad-blocking disabled"
  24.     else
  25.         gravity_on & echo "Ad-blocking enabled"
  26.     fi
  27. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement