From 9421366e4f552e5d0c69b4bb0636d10d13d99249 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 3 Dec 2015 09:25:13 -0800 Subject: [PATCH 1/6] Breakout basic-install.sh to functions --- automated install/basic-install.sh | 83 ++++++++++++++++++++---------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 3c6d14fd..99daaa52 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -148,6 +148,7 @@ else # If the settings are correct, then we need to set the piholeIP # Saving it to a temporary file us to retrieve it later when we run the gravity.sh script echo ${IPv4addr%/*} > /tmp/piholeIP + echo $piholeInterface > /tmp/piholeINT # After that's done, the loop ends and we move on ipSettingsCorrect=True else @@ -182,45 +183,71 @@ static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null sudo ip addr replace dev $piholeInterface $IPv4addr } -installPihole() -{ +installScripts(){ +sudo curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh +sudo curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh +sudo curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh +sudo curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh +sudo chmod 755 /usr/local/bin/{gravity,chronometer,whitelist,piholeLogFlush}.sh +} + +installConfigs(){ +sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig +sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig +sudo curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf +sudo curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf +} + +stopServices(){ +sudo service dnsmasq stop || true +sudo service lighttpd stop || true +} + +installDependencies(){ sudo apt-get update sudo apt-get -y upgrade sudo apt-get -y install dnsutils bc toilet sudo apt-get -y install dnsmasq sudo apt-get -y install lighttpd php5-common php5-cgi php5 -sudo mkdir /var/www/html -sudo chown www-data:www-data /var/www/html -sudo chmod 775 /var/www/html -sudo usermod -a -G www-data pi -sudo service dnsmasq stop -sudo service lighttpd stop -sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig -sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig -sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig -sudo mv /etc/crontab /etc/crontab.orig -sudo curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf -sudo curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf -sudo mv /etc/crontab /etc/crontab.orig -sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron -sudo lighty-enable-mod fastcgi fastcgi-php -sudo mkdir /var/www/html/pihole -sudo curl -o /var/www/html/pihole/index.html https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html +} + +installWebAdmin(){ sudo wget https://github.com/jacobsalmela/AdminLTE/archive/master.zip -O /var/www/master.zip -sudo unzip -o /var/www/master.zip -d /var/www/html/ +sudo unzip -oq /var/www/master.zip -d /var/www/html/ sudo mv /var/www/html/AdminLTE-master /var/www/html/admin sudo rm /var/www/master.zip 2>/dev/null +} + +installPiholeWeb(){ +sudo mkdir /var/www/html/pihole +sudo mv /var/www/html/index.lighttpd.html /var/www/html/index.lighttpd.orig +sudo curl -o /var/www/html/pihole/index.html https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/index.html +} + +installCron(){ +sudo mv /etc/crontab /etc/crontab.orig +sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron +} + +installPiLog(){ sudo touch /var/log/pihole.log sudo chmod 644 /var/log/pihole.log sudo chown dnsmasq:root /var/log/pihole.log -sudo curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh -sudo curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh -sudo curl -o /usr/local/bin/whitelist.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/whitelist.sh -sudo curl -o /usr/local/bin/piholeLogFlush.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/piholeLogFlush.sh -sudo chmod 755 /usr/local/bin/gravity.sh -sudo chmod 755 /usr/local/bin/chronometer.sh -sudo chmod 755 /usr/local/bin/whitelist.sh -sudo chmod 755 /usr/local/bin/piholeLogFlush.sh +} +installPihole() +{ +installDependencies +stopServices +sudo chown www-data:www-data /var/www/html +sudo chmod 775 /var/www/html +sudo usermod -a -G www-data pi +sudo lighty-enable-mod fastcgi fastcgi-php +installScripts +installConfigs +installWebAdmin +installPiholeWeb +installCron +installPiLog sudo /usr/local/bin/gravity.sh } From cb91b8f5fa6925c74ed2bc1d3e4db461324b28c3 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 6 Dec 2015 05:55:50 -0800 Subject: [PATCH 2/6] Add copyright headers --- advanced/Scripts/chronometer.sh | 9 ++++++++- advanced/Scripts/piholeLogFlush.sh | 10 +++++++++- advanced/Scripts/whitelist.sh | 10 +++++++++- gravity.sh | 7 ++++++- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/chronometer.sh b/advanced/Scripts/chronometer.sh index 73219760..d3ce783d 100755 --- a/advanced/Scripts/chronometer.sh +++ b/advanced/Scripts/chronometer.sh @@ -1,6 +1,13 @@ -#!/bin/bash +#!/usr/bin/env bash # Displays Pi-hole stats on the Adafruit PiTFT 2.8" touch screen # Set the pi user to log in automatically and run this script from /etc/profile +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. for (( ; ; )) do clear diff --git a/advanced/Scripts/piholeLogFlush.sh b/advanced/Scripts/piholeLogFlush.sh index 9647fe2c..832c98c9 100755 --- a/advanced/Scripts/piholeLogFlush.sh +++ b/advanced/Scripts/piholeLogFlush.sh @@ -1,3 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash # Flushes /var/log/pihole.log +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +#Pi-hole is free software: you can redistribute it and/or modify +#it under the terms of the GNU General Public License as published by +#the Free Software Foundation, either version 2 of the License, or +#(at your option) any later version. + truncate -s 0 /var/log/pihole.log diff --git a/advanced/Scripts/whitelist.sh b/advanced/Scripts/whitelist.sh index cda557c0..f66f56d0 100755 --- a/advanced/Scripts/whitelist.sh +++ b/advanced/Scripts/whitelist.sh @@ -1,4 +1,12 @@ -#!/bin/bash +#!/usr/bin/env bash +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. + whitelist=/etc/pihole/whitelist.txt adList=/etc/pihole/gravity.list if [[ ! -f $whitelist ]];then diff --git a/gravity.sh b/gravity.sh index 7d9440a3..9e636705 100755 --- a/gravity.sh +++ b/gravity.sh @@ -1,9 +1,14 @@ #!/usr/bin/env bash # Pi-hole: A black hole for Internet advertisements -# (c) 2015 by Jacob Salmela GPL 2.0 +# (c) 2015 by Jacob Salmela # Network-wide ad blocking via your Raspberry Pi # http://pi-hole.net # Compiles a list of ad-serving domains by downloading them from multiple sources +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. piholeIPfile=/tmp/piholeIP if [[ -f $piholeIPfile ]];then From 22d0e82d92e4270a3c7620eccdab3b31e12004e8 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 6 Dec 2015 06:31:49 -0800 Subject: [PATCH 3/6] Add GPL V2+ header --- automated install/basic-install.sh | 7 +++++++ automated install/uninstall.sh | 10 +++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 99daaa52..bf5cd35d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -3,6 +3,13 @@ # by Jacob Salmela # Network-wide ad blocking via your Raspberry Pi # +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. # pi-hole.net/donate # # Install with this command (from your Pi): diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index b0dd3368..563d8d07 100644 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -1,5 +1,13 @@ -#!/bin/bash +#!/usr/bin/env bash # Completely uninstalls the Pi-hole +# (c) 2015 by Jacob Salmela +# This file is part of Pi-hole. +# +# Pi-hole is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 2 of the License, or +# (at your option) any later version. + ######### SCRIPT ########### sudo apt-get -y remove --purge dnsutils bc toilet From 723c2d47bb70c58d4bf66b4ed7abb75db7b83004 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 6 Dec 2015 09:27:13 -0800 Subject: [PATCH 4/6] Add gravity.pod --- gravity.pod | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 gravity.pod diff --git a/gravity.pod b/gravity.pod new file mode 100644 index 00000000..595579ed --- /dev/null +++ b/gravity.pod @@ -0,0 +1,21 @@ +=head1 NAME + +Gravity - A Raspberry Pi based Ad Blocker. + +=head1 DESCRIPTION + +Gravity is a script that downloads ad hosting domain name lists and formats +them for use with a domain name server to block ads. + +=head1 BUGS + +Please report any bugs to the bug tracker at https://github.com/jacobsalmela/pi-hole + +=head1 AUTHORS + +B was written by Jacob Salmela . This manual page was +written by Dan Schaper . + +Both are released under the GNU General Public License, version 2 or later. + +=cut From 4027139d9c9d868a0086ab1836aa9eaafb705809 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Sun, 6 Dec 2015 20:24:58 -0800 Subject: [PATCH 5/6] More merge conflict resolution --- automated install/basic-install.sh | 6 ------ 1 file changed, 6 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 7b29bcac..75572a70 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -186,8 +186,6 @@ static routers=$IPv4gw static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null } -<<<<<<< HEAD -======= setStaticIPv4(){ if grep -q $IPv4addr $dhcpcdFile; then # address already set, noop @@ -199,7 +197,6 @@ else fi } ->>>>>>> b261e046bb6a8a2c7f2301ff6a9d37aa70e898fd installScripts(){ sudo curl -o /usr/local/bin/gravity.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/gravity.sh sudo curl -o /usr/local/bin/chronometer.sh https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/Scripts/chronometer.sh @@ -213,10 +210,7 @@ sudo mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig sudo mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.orig sudo curl -o /etc/dnsmasq.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/dnsmasq.conf sudo curl -o /etc/lighttpd/lighttpd.conf https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/lighttpd.conf -<<<<<<< HEAD -======= sudo sed -i "s/@INT@/$piholeInterface/" /etc/dnsmasq.conf ->>>>>>> b261e046bb6a8a2c7f2301ff6a9d37aa70e898fd } stopServices(){ From 73bbfc27d0b610a188609d5480c3b22667ec8d81 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Tue, 8 Dec 2015 15:43:40 -0800 Subject: [PATCH 6/6] Remove extra debian doc file --- gravity.pod | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 gravity.pod diff --git a/gravity.pod b/gravity.pod deleted file mode 100644 index 595579ed..00000000 --- a/gravity.pod +++ /dev/null @@ -1,21 +0,0 @@ -=head1 NAME - -Gravity - A Raspberry Pi based Ad Blocker. - -=head1 DESCRIPTION - -Gravity is a script that downloads ad hosting domain name lists and formats -them for use with a domain name server to block ads. - -=head1 BUGS - -Please report any bugs to the bug tracker at https://github.com/jacobsalmela/pi-hole - -=head1 AUTHORS - -B was written by Jacob Salmela . This manual page was -written by Dan Schaper . - -Both are released under the GNU General Public License, version 2 or later. - -=cut