My Ad Blocker For Linux


SUBMITTED BY: Guest

DATE: June 18, 2015, 8:33 p.m.

FORMAT: Bash

SIZE: 2.7 kB

HITS: 1063

  1. # Adaway4linux by wb9688
  2. # github.com/wb9688/Adaway4linux
  3. if [ "$(id -u)" != "0" ]; then
  4. echo "This script must be run as root!" 1>&2
  5. exit 1
  6. fi
  7. echo "========================"
  8. echo " Downloading files... "
  9. echo "========================"
  10. echo
  11. curl "https://adaway.org/hosts.txt" > hosts1.txt
  12. curl "http://winhelp2002.mvps.org/hosts.txt" > hosts2.txt
  13. curl "http://hosts-file.net/ad_servers.txt" > hosts3.txt
  14. curl "http://pgl.yoyo.org/adservers/serverlist.php?hostformat=hosts&showintro=0&mimetype=plaintex"t > hosts4.txt
  15. echo
  16. echo "===================="
  17. echo " Merging files... "
  18. echo "===================="
  19. cat hosts1.txt hosts2.txt hosts3.txt hosts4.txt exceptions.txt >> hosts
  20. rm hosts1.txt hosts2.txt hosts3.txt hosts4.txt
  21. sed '/^\#/d' hosts > hosts.tmp
  22. mv hosts.tmp hosts
  23. sed '/^$/d' hosts > hosts.tmp
  24. mv hosts.tmp hosts
  25. sed '/127.0.0.1 localhost/d' hosts > hosts.tmp
  26. mv hosts.tmp hosts
  27. sed '/::1 localhost/d' hosts > hosts.tmp
  28. mv hosts.tmp hosts
  29. sed '/127.0.0.1 localhost/d' hosts > hosts.tmp
  30. mv hosts.tmp hosts
  31. sed '/::1 localhost/d' hosts > hosts.tmp
  32. mv hosts.tmp hosts
  33. sed '/adf\.ly/d' hosts > hosts.tmp
  34. mv hosts.tmp hosts
  35. echo "# This file is automatically generated by Adaway4linux by wb9688" >> hosts_license
  36. echo "# If you run Adaway4linux again this file will be overwritten" >> hosts_license
  37. echo "# # Please add extra lines in a file called extra_lines.txt in the same directory as Adaway4linux" >> hosts_license
  38. echo >> hosts_license
  39. mv hosts hosts.txt
  40. echo
  41. echo "====================================="
  42. echo " Backing up your old hosts file... "
  43. echo "====================================="
  44. if [ -f /etc/hosts.bkup ];
  45. then
  46. cat /etc/hosts.bkup > old_hosts
  47. else
  48. cp /etc/hosts /etc/hosts.bkup
  49. cat /etc/hosts.bkup > old_hosts
  50. fi
  51. echo
  52. echo "=========================================="
  53. echo " Including old hosts file in new one... "
  54. echo "=========================================="
  55. cat hosts_license >> new_hosts
  56. sed '/^\#/d' old_hosts > hosts.tmp
  57. rm old_hosts
  58. mv hosts.tmp old_hosts
  59. cat old_hosts >> new_hosts
  60. echo >> new_hosts
  61. cat hosts.txt >> new_hosts
  62. rm hosts_license
  63. rm hosts.txt
  64. mv new_hosts hosts
  65. echo
  66. echo "================================"
  67. echo " Installing new hosts file... "
  68. echo "================================"
  69. cp hosts /etc/hosts
  70. rm hosts
  71. echo
  72. echo "============="
  73. echo " Finished! "
  74. echo "============="

comments powered by Disqus