Compare commits

...

178 Commits
2.8 ... V2.9.2

Author SHA1 Message Date
Adam Warner
5966d76e9a Merge pull request #729 from pi-hole/development
Pi-hole version 2.9.2
2016-10-07 10:49:06 +01:00
Jacob Salmela
ca0cbd68d6 Merge pull request #743 from pi-hole/whatDuplicates
What duplicates
2016-10-04 08:53:51 -05:00
Promofaux
c281b47905 Mover {SUDO} mkdir -p /etc/pihole/ back to the beginning. 2016-10-02 12:44:33 +01:00
Promofaux
aca5064743 --force seems to light. lets try --i_do_not_follow_recommendations 2016-10-02 11:16:48 +01:00
Promofaux
6f780316c4 remove whiptail dependency from verifyFreeDiskSpace.
Add argument detection to skip disk space. This is because curling to bash does not support waiting for user input.
2016-10-02 11:09:14 +01:00
Promofaux
4e262d81f0 wrap these vars in {} to matcht he rest of the script 2016-10-02 10:39:09 +01:00
Promofaux
6c2ff950ee remote duplicate ${SUDO} mkdir /etc/pihole 2016-10-02 10:33:59 +01:00
Promofaux
7684069d0b verifyFreeDiskSpace BEFORE installing any dependencies 2016-10-02 10:33:04 +01:00
Promofaux
73c85ae68a remove duplicate calls to installConfigs 2016-10-02 10:30:55 +01:00
Dan Schaper
911e39ba09 Merge pull request #726 from pi-hole/DebugUpdate
DebugUpdate
2016-10-01 13:47:15 -07:00
Dan Schaper
9a421d510a Ignore comments in adlists.list section. 2016-10-01 13:16:58 -07:00
Adam Warner
3bc7172e5e Merge pull request #738 from pi-hole/updateFix
Add check at the beginning of update script to check for existence of…
2016-10-01 17:03:31 +01:00
Promofaux
1a83988e26 Add check at the beginning of update script to check for existence of local repos. If not, redirect user to run install command again. 2016-10-01 16:56:03 +01:00
Adam Warner
0d0fc2504a Merge pull request #735 from diginc/patch-1
Update README.md
2016-10-01 04:54:19 +01:00
Adam Hill
0d4402ee0c Update README.md
Updating the old x86 only reference on the link to my docker project.
2016-09-30 17:01:44 -05:00
Adam Warner
722def9362 Merge pull request #734 from pi-hole/phpVerCheckFix
Fix the php version check command (Thanks @diginc!)
2016-09-30 22:48:39 +01:00
Promofaux
6a8bef83b3 Fix the php version check command (Thanks @diginc!) 2016-09-30 22:40:43 +01:00
Dan Schaper
a9c3e2c7ba Add log_write function. Update version_check to use logical conditionals. 2016-09-28 13:09:38 -07:00
Dan Schaper
7fcb40739d Close IF statement 2016-09-28 10:25:37 -07:00
Dan Schaper
5a3d319677 Add fail check to dig local and remote. 2016-09-28 10:24:44 -07:00
Dan Schaper
8466d0b681 Change NSLOOKUP to dig for resolver tests, add dnsmasq specific records check 2016-09-28 10:14:47 -07:00
Dan Schaper
5de179f1eb Remove blacklist comparison. 2016-09-28 09:52:11 -07:00
Dan Schaper
36e10595cc Change netstat to lsof. 2016-09-28 09:51:14 -07:00
Jacob Salmela
78c8723629 Merge pull request #708 from pi-hole/github-templates
Update Github templates
2016-09-27 22:12:36 -05:00
Dan Schaper
edd7f28104 Add internet checks to IP section 2016-09-27 19:39:28 -07:00
Dan Schaper
dba1ab3fc0 Remove compareWhitelist 2016-09-27 19:31:21 -07:00
Dan Schaper
3df9c48012 Include ping statistics in default gateway checks. 2016-09-27 19:30:37 -07:00
Jacob Salmela
6f6450bcff simplify a bit more
Removed a few checkboxes.  I really don't want to deter people from
submitting issue because of a wall of text, but some of this
information we really can use to be more helpful.
2016-09-27 08:23:52 -05:00
Jacob Salmela
1f34203167 Merge pull request #722 from pi-hole/BugFix718
Fix #718
2016-09-27 08:08:42 -05:00
Jacob Salmela
fed20648c6 Merge pull request #727 from pi-hole/BugFix725
Fix 725 and 653
2016-09-27 08:07:34 -05:00
Adam Warner
3fc3c5cae4 Add iproute2 to fix #653 2016-09-27 11:15:46 +01:00
Adam Warner
daa5366b57 Check if php5 is available in apt-cache, if so install it, else just install php 2016-09-27 11:11:47 +01:00
Dan Schaper
ac1c299369 Revert overzealous renaming of Pi-hole in pihole.log detection. 2016-09-26 20:54:05 -07:00
Dan Schaper
5bbb3ac49a Standardize Pi-hole naming. 2016-09-26 20:50:03 -07:00
Dan Schaper
014bdf911a Add open port detection 2016-09-26 20:39:39 -07:00
Dan Schaper
874853fe18 Add lighttpd to version check 2016-09-26 19:23:30 -07:00
Dan Schaper
274b71f8bc Relocate hostname checks 2016-09-26 18:52:12 -07:00
Dan Schaper
c41d543d81 Handle lack of IPv6 gracefully. 2016-09-26 18:27:02 -07:00
Dan Schaper
7729ddab30 Mode code realignment. Handle lack of IPv6 gateway gracefully. 2016-09-26 18:21:58 -07:00
Dan Schaper
60c0e59a83 Add IPv6 intelligence to debug 2016-09-26 18:06:31 -07:00
Adam Warner
ac49e639bd Fix #718 2016-09-26 11:58:07 +01:00
Adam Warner
f01b20c2af Merge pull request #711 from pi-hole/EggPatch-1
Egg patch 1
2016-09-22 10:50:56 +01:00
Dan Schaper
a0d47be088 Merge conflict resolution 2016-09-21 17:20:25 -07:00
Dan Schaper
521374e238 Update .pullapprove.yml 2016-09-21 16:53:50 -07:00
Jacob Salmela
34806ee2c2 1-10 codebase familiarity
Also tried to simplify the language a bit so as not to deter people
from submitting issues.  We may need to simplify it more
2016-09-21 08:39:32 -05:00
Jacob Salmela
4a0d5138a1 move CONTRIBUTING.MD to .github 2016-09-20 15:30:27 -05:00
Jacob Salmela
e6a3758899 new template based on udemy-dl 2016-09-20 15:29:20 -05:00
Jacob Salmela
fcb7d9111e new template based on udemy-dl 2016-09-20 15:14:15 -05:00
Jacob Salmela
d907731027 new template based on udemy-dl 2016-09-20 15:10:34 -05:00
Dan Schaper
ac8d295bb9 Merge pull request #668 from bcambl/dns-hostname-fixes
Dns hostname fixes
2016-09-20 10:16:15 -07:00
Jacob Salmela
a963beb96e Merge pull request #703 from pi-hole/PromoFaux-patch-1
Add additional instruction.
2016-09-20 08:34:04 -05:00
bcambl
21d4199a38 Merge branch 'development' into dns-hostname-fixes 2016-09-19 17:33:32 -06:00
Adam Warner
655c422c3c Add additional instruction.
Include "(Press space to select)" on ChooseInterface
2016-09-19 22:17:58 +01:00
Adam Warner
b6f8bd408f Merge pull request #702 from pi-hole/PromoFaux-patch-1
Change reset_on_push to false
2016-09-19 21:12:33 +01:00
Adam Warner
a3edd0b976 Change reset_on_push to false
So we don't have to reapprove every time the branch is updated.
2016-09-19 21:06:28 +01:00
Adam Warner
8e8efa5caf Merge pull request #695 from pi-hole/gravTweak
Enable support for /etc/pihole/setupVars.conf in gravity
2016-09-19 20:57:51 +01:00
Adam Warner
a41b8f62a2 Merge branch 'development' into gravTweak 2016-09-19 20:55:58 +01:00
Dan Schaper
452ee8c2df Merge pull request #692 from pi-hole/PromoFaux-patch-1
Update piholeDebug.sh
2016-09-19 12:55:26 -07:00
Dan Schaper
5ca6599ca9 Merge branch 'development' into gravTweak 2016-09-19 12:54:58 -07:00
Adam Warner
dcedf6bfd0 Merge branch 'development' into PromoFaux-patch-1 2016-09-19 20:54:04 +01:00
Adam Warner
1f4b43645b Merge pull request #679 from pi-hole/updateTweaks
Make `pihole -up` a bit more intelligent
2016-09-19 20:46:22 +01:00
Promofaux
3d5140458b Change cron job 2016-09-19 20:43:04 +01:00
Promofaux
f16574085f remove code made redundant by the existence of /etc/pihole/setupVars.conf 2016-09-16 23:09:14 +01:00
Promofaux
3ed62d45f5 Source IP addresses from /etc/pihole/setupVars.conf 2016-09-16 23:05:08 +01:00
Adam Warner
b1a7b0a186 Update piholeDebug.sh
I can spell, honest.
2016-09-15 15:16:06 +01:00
Promofaux
ec0c68621c add blank line after Current version display 2016-09-12 19:40:34 +01:00
Promofaux
a0977af081 remove references to UpdateDashboard.sh 2016-09-12 19:10:12 +01:00
Promofaux
a3ef9efd2f remove updateDashboard script 2016-09-12 19:09:19 +01:00
Promofaux
d58f7c6ec9 Remove references to dashboard update Script 2016-09-12 19:08:33 +01:00
Promofaux
d124c2c12e Expand to check web admin versions 2016-09-12 18:57:19 +01:00
Promofaux
0229f70761 Make updatePiholeFunc a bit smarter. Only run update if version is not the latest. 2016-09-12 18:29:04 +01:00
Promofaux
dde9281139 Only pull master branch, the rest aren't needed! 2016-09-12 18:12:31 +01:00
Adam Warner
6eedfb572e Merge pull request #676 from pi-hole/development
2.9.1
2016-09-12 14:56:25 +01:00
Adam Warner
edf81a232d Merge pull request #671 from pi-hole/PromoFaux-patch-1
Add cron to apt-get dependencies
2016-09-09 20:23:34 +01:00
Adam Warner
c2cb92a0b0 Add cron to apt-get dependencies 2016-09-08 23:42:05 +01:00
bcambl
640af300cb additional hostname checks in gravity.sh
- Test if /etc/hostname exists before attempting to cat the file.
 - Add alternative hostname discovery via hostname command
 - Add an error message to stdout if unable to determine host fqdn
2016-09-07 21:16:52 -06:00
bcambl
6c0c6182e9 fix newline in configureSelinux stdout 2016-09-07 21:16:52 -06:00
bcambl
05ad4445b5 add dns to sysconfig interface configuration 2016-09-07 21:16:51 -06:00
bcambl
1dd9f0747e add gateway to interface configuration
pi-hole@9cb4e8b broke #593
original commit 8550b76
2016-09-07 21:16:36 -06:00
Dan Schaper
150e01be8b Merge pull request #667 from pi-hole/piholeBashCompletionUpdate
Add the newer pihole command tags to the bash auto complete!
2016-09-06 15:02:13 -07:00
Promofaux
95ee3216c4 Add the newer pihole command tags to the bash auto complete! 2016-09-06 21:57:17 +01:00
Adam Warner
3b5e409b38 Merge pull request #666 from pi-hole/PromoFaux-patch-1
Change log flush time to 00:00
2016-09-06 19:30:36 +01:00
Adam Warner
eb201b614a Change log flush time to 00:00 2016-09-06 19:29:30 +01:00
Adam Warner
162a6b8b5c Merge pull request #665 from pi-hole/FleshOutPiholeQ
Make the output of pihole -q a bit clearer. Bye Bye nifty one-liner!
2016-09-06 19:25:03 +01:00
Promofaux
4ec01769cb Appease Jacob. 2016-09-06 19:21:56 +01:00
Promofaux
19b656132d Make the output of pihole -q a bit clearer. Bye Bye nifty one-liner! 2016-09-06 19:16:04 +01:00
Adam Warner
6305c7e2ab Merge pull request #663 from pi-hole/Bugfix660
Switch fedora and debian install check order
2016-09-05 18:32:55 +01:00
Promofaux
04c60e8a1c Switch fedora and debian install check order 2016-09-05 15:52:09 +01:00
Adam Warner
b6ceb06a32 Merge pull request #655 from pi-hole/PromoFaux-patch-1
Replace `truncate` command with `echo " " >`
2016-09-02 19:34:50 +01:00
Adam Warner
8cb2f85a08 Replace truncate command with echo " " > 2016-09-02 16:39:34 +01:00
Adam Warner
7ccfb6ea88 Merge pull request #651 from pi-hole/PromoFaux-patch-1
Remove defunct list from adlists.default
2016-09-02 14:12:32 +01:00
Adam Warner
531398b532 Remove defunct list from adlists.default
See issue #650
2016-09-02 11:27:13 +01:00
Adam Warner
ec6ecf0d60 Merge pull request #639 from pi-hole/development
2.9
2016-08-30 21:46:04 +01:00
Dan Schaper
fdb0e31a78 Merge pull request #625 from pi-hole/UpdateMethod
Forget all existing attempts at an update method... this is the one.
2016-08-30 11:47:36 -07:00
Promofaux
01a9534729 Merge branch 'development' into UpdateMethod
# Conflicts:
#	automated install/basic-install.sh
2016-08-30 19:32:40 +01:00
Adam Warner
921278c5ea Merge pull request #636 from pi-hole/QueryCommand
Query command
2016-08-30 19:17:50 +01:00
Promofaux
d938f73207 Fix line endings 2016-08-26 23:10:22 +01:00
Promofaux
344e63c2dc Add undocumented argument to install script ("pihole") which allows the pihole command to run the update script without prompting the user. Useful for update automation 2016-08-26 23:06:35 +01:00
Promofaux
681144b2a3 Change the switched for updateDashboard and updatePihole(was updateMain) 2016-08-26 22:52:44 +01:00
Promofaux
e4295f5d3c Move exporting the setupConf files to a function to be run at the end of the script only. If script is cancelled, then they are not written. Simples.
Also I'm surprised nobody noticed the duplicate installPihole() function :S
2016-08-26 22:45:38 +01:00
Adam Warner
77135ca3c7 Actually pass through the argument to the function 2016-08-26 10:09:39 +01:00
Adam Warner
29b548f07c Add queryfunc 2016-08-26 09:39:27 +01:00
Dan Schaper
cb33ef77f7 Merge pull request #635 from Fourdee/development
Minor - Corrected var names
2016-08-25 12:14:12 -07:00
Daniel (Fourdee)
49ded54306 Minor - Update descriptions
Apply to whiptail descriptions also.
2016-08-25 12:17:36 +01:00
Daniel (Fourdee)
6c0a8a4337 Minor - Corrected var names
Kilobyte values are used, not Bytes.
2016-08-25 12:11:54 +01:00
Daniel (Fourdee)
e9a0ddf798 Merge remote-tracking branch 'refs/remotes/pi-hole/development' into development 2016-08-25 12:09:54 +01:00
Promofaux
d217626318 If an existing install is detected, offer the user a choice of Updating or Installing with a radio list whiptail. 2016-08-24 22:52:11 +01:00
Dan Schaper
4f5fcc2a37 Merge pull request #626 from victmo/development
Added window.close() to index.html
2016-08-22 16:43:49 -07:00
Promofaux
ed94f4b1df Create directory before trying to create a blank file in it.... 2016-08-22 22:06:33 +01:00
Promofaux
a57b097afc Change echos at the end of install depending on install or update 2016-08-21 18:00:41 +01:00
Promofaux
eb42b894c4 Delete setupVars.conf if user cancels out of install process. 2016-08-21 17:57:11 +01:00
Dan Schaper
af666e2209 Escape space in updateMainFunc
Legacy space in path strikes again!
2016-08-20 18:37:35 -07:00
Promofaux
2f2e746e56 Add update function to pihole script 2016-08-21 02:23:11 +01:00
Promofaux
b3e7619048 curly brackets all the variables! 2016-08-21 02:12:02 +01:00
Victor Marquez
0121136498 Added window.close() to index.html
Adding window.close() will automatically close any pop-ups that might get loaded with a blocked ad.
2016-08-19 20:45:17 -04:00
Promofaux
7eb43a0b47 Expand update dialog text 2016-08-19 23:25:04 +01:00
Promofaux
c0430a2248 It wouldn't be me if there weren't loads of commits for simple mistakes. 2016-08-19 23:10:56 +01:00
Promofaux
6796b8bdad pass argument from pihole command to gravity for -f check 2016-08-19 23:06:56 +01:00
Promofaux
475d016029 hmmm 2016-08-19 22:52:55 +01:00
Promofaux
201304e678 fix variables in gravity to stop it using -f wether it's set or not 2016-08-19 22:51:09 +01:00
Promofaux
fdb104348c Add updatePihole method 2016-08-19 22:45:24 +01:00
Promofaux
f54828352d remove spaces from update bool set 2016-08-19 22:42:04 +01:00
Promofaux
cc157def63 remove --defaultyes from update whiptail 2016-08-19 22:40:27 +01:00
Promofaux
8fc83655ab correct filename spelling mistake 2016-08-19 22:38:16 +01:00
Promofaux
9fb549293a APPEND 2016-08-19 22:34:50 +01:00
Promofaux
e4cc5b5b70 testing a new update method by detecting the existence of vars saved from install 2016-08-19 22:31:11 +01:00
Dan Schaper
6f0b659b38 Merge pull request #623 from pi-hole/AddForceClearToGravity
Add force clear to gravity
2016-08-17 11:32:35 -07:00
Dan Schaper
652bdf1518 Merge branch 'development' into AddForceClearToGravity 2016-08-17 11:32:26 -07:00
Promofaux
f6ac0d73b4 Add force delete option 2016-08-17 19:08:55 +01:00
Promofaux
ae47be0ce9 Add HelpFunc 2016-08-17 18:59:00 +01:00
Mcat12
491c37eafe Merge pull request #613 from goldbattle/development
Added - Readme Windows Tray App
2016-08-14 17:20:25 -04:00
Patrick Geneva
3ade7a8b0e Added - Readme Windows Tray App 2016-08-14 17:18:24 -04:00
Dan Schaper
3c7738b6d0 Merge pull request #619 from Fourdee/development
Free Disk Space check standardization
2016-08-13 19:44:40 -07:00
Daniel (Fourdee)
037318e2ff Provide non-zero exit code, as per existing sourcecode. 2016-08-12 13:20:30 +01:00
Daniel (Fourdee)
a9a499939e Fourdee - See notes:
https://github.com/pi-hole/pi-hole/issues/602
+ Improve available free disk space check.
+ Option to override if the free disk space check is not a valid
integer.
2016-08-12 12:44:45 +01:00
Daniel (Fourdee)
7e5bcd2ec3 Merge remote-tracking branch 'refs/remotes/pi-hole/development' into development 2016-08-12 12:11:55 +01:00
Adam Warner
f49ca48a22 Merge pull request #607 from pi-hole/Debug_Options
Debug options
2016-08-05 12:54:55 +01:00
Promofaux
9cb4e8bde8 Merge remote-tracking branch 'origin/Debug_Options' into Debug_Options
# Conflicts:
#	automated install/basic-install.sh
2016-08-05 12:53:08 +01:00
Adam Warner
95edb49bb8 Add option for uploading debug log to termbin 2016-08-05 12:47:57 +01:00
Dan Schaper
fb69bf551e Merge pull request #593 from bcambl/sysconfig_gateway
add gateway to interface configuration
2016-08-04 00:26:07 -07:00
bcambl
fe8d0f8ea8 Merge branch 'development' into sysconfig_gateway 2016-08-03 19:26:53 -06:00
Mcat12
acc5fa2a95 Merge pull request #609 from pi-hole/CLI_VersionCheck
Cli version check
2016-08-03 21:21:30 -04:00
Mcat12
f2e33f8581 Merge branch 'development' into CLI_VersionCheck 2016-08-03 21:21:23 -04:00
Adam Warner
4748cdc2c9 Merge pull request #599 from pi-hole/PullApprove
Add PullApprove configuration
2016-08-04 00:14:00 +01:00
Promofaux
2bc364023a Remove erroneous space in chmod command
Fix spacing in help function
2016-08-02 23:51:53 +01:00
Dan Schaper
3070f61e20 Merge branch 'development' into PullApprove 2016-08-02 14:55:47 -07:00
Promofaux
57df56dc62 Add version.sh to the install script 2016-08-02 20:08:21 +01:00
Promofaux
e11ef5a7f0 Add version display script. Also checks current version on web and reports version. 2016-08-02 20:07:09 +01:00
Promofaux
6a17a3eeec Add command to pihole script 2016-08-02 19:44:11 +01:00
Promofaux
66ff9a24c6 Add piholeDebug to the chmod 755 command in install script. Not sure how that went missing... 2016-08-01 21:54:42 +01:00
Adam Warner
a3b3a7a34d Add option for uploading debug log to termbin 2016-08-01 21:43:13 +01:00
Mcat12
c04b3559d0 Merge pull request #584 from diginc/development
Only re-block whitelist deletions if in adlists
2016-07-31 14:39:05 -04:00
Dan Schaper
e642b41b5b Add PullApprove configuration 2016-07-29 16:35:26 -07:00
Dan Schaper
ba6881d685 Merge pull request #595 from pi-hole/fix/README_Update
Typo/Linter fix
2016-07-29 13:13:24 -07:00
Dan Schaper
20d8c9053b Remove defunct Optimal link
Optimal has discontinued it's app program. Removing dead link
2016-07-29 13:05:15 -07:00
Dan Schaper
0749e4ed70 Move BountySource to top position 2016-07-27 18:58:05 -07:00
Dan Schaper
b0cc69ff80 Merge Conflict resolution 2016-07-27 18:54:41 -07:00
Dan Schaper
02c4669e95 Typo/Linter fix
Fix a few typo's, run through linter for format corrections.
2016-07-26 20:46:43 -07:00
bcambl
8550b76e23 add gateway to interface configuration 2016-07-24 22:42:06 -06:00
Adam Warner
fdf27e3d24 Merge pull request #573 from bcambl/centos-nc
fix centos nc dependency
2016-07-22 19:02:29 +01:00
Adam Warner
069023fca2 Merge pull request #589 from pi-hole/PromoFaux-patch-1
Update README.md
2016-07-22 14:14:07 +01:00
Adam Warner
1fd6648db1 Merge pull request #591 from pi-hole/master
Out of Sync with master
2016-07-22 12:04:15 +01:00
Adam Warner
7a08c8b694 Merge pull request #590 from pi-hole/revert-588-master
Revert "Development out of sync with master."
2016-07-22 12:03:17 +01:00
Adam Warner
60aad3f19b Revert "Development out of sync with master." 2016-07-22 11:59:19 +01:00
Adam Warner
51dcc2bc0f Update README.md
Add badge for bountysource to show avtive bounties.
2016-07-22 11:56:54 +01:00
Adam Warner
941525d1e0 Development out of sync with master. (#588)
* adding links to optimal.com

Also added image of Pi-hole's stats from Optimal.com and a bitcoin donation address per some user requests.

* simplified and new additions

I tried to simplify the readme page a bit.  I also added some new links to some helper videos and added some screenshots of the whitelist editor.

* updated dashboard pic

* Update README.md

* simplified donation section

* forgot to remove the old donation stuff

* Hosts-file.net moved to https

* removed pihole berry from images

also added adafruit livestream video

* Update README.md

update "How does it work" video
2016-07-22 11:54:17 +01:00
diginc
5fb6c5b012 Making the whitelist re-block echo consistent with other WL/BL echos 2016-07-20 12:53:31 -05:00
diginc
3affa73257 Only re-block whitelist deletions if in adlists
* Prevent blocking benign/untracked domains deleted off whitelist
* Issue #581
2016-07-20 12:43:30 -05:00
Blayne Campbell
c647e27e15 Merge branch 'development' into centos-nc 2016-07-19 08:48:54 -06:00
Dan Schaper
f696ed48b3 Merge pull request #570 from pi-hole/bugfix/dhcpcd_comments
Change comment to hash
2016-07-18 16:32:12 -07:00
Adam Warner
73645f299a Merge branch 'development' into bugfix/dhcpcd_comments 2016-07-18 14:37:38 +01:00
Mcat12
6aeb5f1172 Merge pull request #575 from pi-hole/bugfix/distrib_vers_check
Remove trailing slash on os-release check
2016-07-17 07:37:55 -04:00
Dan Schaper
ce8f07750f Remove trailing slash on os-release check
Fixes #CLOSED 

Remove trailing slash that would cause an os-check to always fail out.
2016-07-15 22:46:21 -07:00
bcambl
a32ad0dbf2 fix centos nc dependency 2016-07-15 21:43:23 -06:00
Promofaux
61ff12e8d4 Change header to match the rest of the scripts. 2016-07-15 21:17:16 +01:00
Adam Warner
02b0e96db8 Merge pull request #572 from pi-hole/development
Dan forgot this : `}`
2016-07-15 21:13:10 +01:00
Promofaux
e942440bb7 Dan forgot this : } 2016-07-15 21:11:10 +01:00
Dan Schaper
f0a2248c81 Change comment to hash
Change format of comment to hash/octothorpe to clearly delineate that it's a comment. Looks better than `:::` which causes confusion.
2016-07-15 10:27:40 -07:00
22 changed files with 1262 additions and 915 deletions

37
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,37 @@
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
# Contributors Guide
Please read and understand the contribution guide before creating an issue or pull request.
## Etiquette
- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature.
- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that.
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
## Viability
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many people, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project.
## Procedure
**Before filing an issue:**
- Attempt to replicate and **document** the problem, to ensure that it wasn't a coincidental incident.
- Check to make sure your feature suggestion isn't already present within the project.
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
- Check the pull requests tab to ensure that the feature isn't already in progress.
**Before submitting a pull request:**
- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
## Technical Requirements
- Submit Pull Requests to the **development branch only**.
- Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
- Commit Unix line endings.
- (Optional fun) keep to the theme of Star Trek/black holes/gravity.

View File

@@ -1,7 +1,42 @@
##### Expected Behaviour: _This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
**In raising this issue, I confirm the following (please check boxes, eg [X]):**
- [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
- [ ] The issue I am reporting can be *replicated*
- [ ] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)).
**How familiar are you with the codebase?:**
- [ ] 1 (very unfamiliar)
- [ ] 2
- [ ] 3
- [ ] 4
- [ ] 5
- [ ] 6
- [ ] 7
- [ ] 8
- [ ] 9
- [ ] 10 (very familiar)
---
**[FEATURE REQUEST | QUESTION | OTHER]:**
_{replace this section with your content or delete if not a FEATURE REQUEST/QUESTION/OTHER}_
**[BUG | ISSUE] Expected Behaviour:**
##### Actual Behaviour: **[BUG | ISSUE] Actual Behaviour:**
##### Steps to reproduce this issue: **[BUG | ISSUE] Steps to reproduce:**
-
-
-
-
**(Optional) Debug Log generated by `pihole -d`:**
`http://termbin.com/<something>`

View File

@@ -1,11 +1,25 @@
Fixes #[issue number] . _This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
Changes proposed in this pull request: **By submitting this pull request, I confirm the following (please check boxes, eg [X]):**
- - [ ] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
- [ ] I have checked that [another pull request](https://github.com/pi-hole/pi-hole/pulls) for this purpose does not exist.
- [ ] I have considered, and confirmed that this submission will be valuable to others.
- [ ] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
- [ ] I give this submission freely, and claim no ownership to its content.
- **How familiar are you with the codebase?:**
- - [ ] 1 (very unfamiliar)
- [ ] 2
- [ ] 3
- [ ] 4
- [ ] 5
- [ ] 6
- [ ] 7
- [ ] 8
- [ ] 9
- [ ] 10 (very familiar)
@pi-hole/gravity ---
_{replace this line with your pull request content}_

19
.pullapprove.yml Normal file
View File

@@ -0,0 +1,19 @@
approve_by_comment: true
approve_regex: '^(Approved|:shipit:|:\+1:|Engage)'
reject_regex: '^(Rejected|:-1:|Borg)'
reset_on_push: true
author_approval: required
reviewers:
members:
- brantje
- dschaper
- jacobsalmela
- Mcat12
- PromoFaux
name: pullapprove
required: 3
always_pending:
title_regex: '(WIP|wip)'
labels:
- wip
explanation: 'This PR is a work in progress...'

View File

@@ -1,8 +0,0 @@
This is a basic checklist for now, We will update it in the future.
* Fork the repo and create your new branch based on the `development` branch.
* Commit Unix line endings
* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
* Submit Pull Requests to the development branch only.
* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..

131
README.md
View File

@@ -1,58 +1,65 @@
# Automated Install [![Bountysource](https://www.bountysource.com/badge/tracker?tracker_id=3011939)](https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE)
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
1. Install Raspbian # Automated Install
2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!) Designed For Raspberry Pi A+, B, B+, 2, 3B, and Zero (with an Ethernet/Wi-Fi adapter)
Works on most Debian and CentOS/RHEL based distributions!
### ```curl -L https://install.pi-hole.net | bash``` 1. Install Raspbian
2. Run the command below (downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!)
#### Alternative Semi-Automated install #### ## `curl -L https://install.pi-hole.net | bash`
```
### Alternative Semi-Automated install
```bash
wget -O basic-install.sh https://install.pi-hole.net wget -O basic-install.sh https://install.pi-hole.net
chmod +x basic-install.sh chmod +x basic-install.sh
./basic-install.sh ./basic-install.sh
``` ```
If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer If you wish to read over the script before running it, then after the `wget` command, do `nano basic-install.sh` to open a text viewer
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
## How To Install Pi-hole ## How To Install Pi-hole
[![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA) [![60-second install tutorial](http://i.imgur.com/5TEc3a6.png)](https://www.youtube.com/watch?v=TzFLJqUeirA)
## How Does It Work? ## How It Works
**Watch the 60-second video below to get a quick overview** **Watch the 60-second video below to get a quick overview**
[![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho) [![Pi-hole exlplained](http://i.imgur.com/pG1m937.png)](https://youtu.be/9Eti3xibiho)
## Pi-hole Is Free, But Powered By Your Donations ## Pi-hole Is Free, But Powered By Your Donations
Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the montly fee.
* ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY)
* ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole)
* ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL
* ![Optimal.com](http://i.imgur.com/d4EAYrw.png) : [Optimal.com](http://api.optimal.com/partner/v1.0/bmV0d29ya3xkbnN8OlJhc3BiZXJyeSBQaS1Ib2xl/subscribe?redirect=https%3A%2F%2Fpi-hole.net%2Fthank-you%2F) (we get a small comission)
Send a one-time donation or sign up for Optimal.com's service using our link below to provide us with a small portion of the monthly fee.
- ![Paypal](http://i.imgur.com/3muNfxu.png) : [Donate](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY)
- ![Flattr](http://i.imgur.com/ZFceFRu.png) : [Donate](https://flattr.com/submit/auto?user_id=jacobsalmela&url=https://github.com/pi-hole/pi-hole)
- ![Bitcoin](http://i.imgur.com/FIlmOMG.png) : 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL
## Get Help Or Connect With Us On The Web ## Get Help Or Connect With Us On The Web
- [@The_Pi_Hole](https://twitter.com/The_Pi_Hole) - [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
- [/r/pihole](https://www.reddit.com/r/pihole/) - [/r/pihole](https://www.reddit.com/r/pihole/)
- [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w) - [Pi-hole YouTube channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
- [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) - [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization)
- [FAQs](https://pi-hole.net/help/) - [FAQs](https://pi-hole.net/help/)
- [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) - [![Join the chat at https://gitter.im/pi-hole/pi-hole](https://badges.gitter.im/pi-hole/pi-hole.svg)](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## Technical Details ## Technical Details
The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads. The Pi-hole is an **advertising-aware DNS/Web server**. If an ad domain is queried, a small Web page or GIF is delivered in place of the advertisement. You can also [replace ads with any image you want](http://pi-hole.net/faq/is-it-possible-to-change-the-blank-page-that-takes-place-of-the-ads-to-something-else/) since it is just a simple Webpage taking place of the ads.
### Gravity ### Gravity
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
## Web Interface ## Web Interface
The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin` `http://192.168.1.x/admin/index.php` or `http://pi.hole/admin`
@@ -60,55 +67,59 @@ The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashb
### Whitelist and blacklist ### Whitelist and blacklist
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details ![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png)
![Whitelist editor in the Web interface](http://i.imgur.com/ogu2ewg.png)
## API ## API
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON: A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
```JSON
```json
{ {
"domains_being_blocked": "136708", "domains_being_blocked": "136708",
"dns_queries_today": "18108", "dns_queries_today": "18108",
"ads_blocked_today": "14648", "ads_blocked_today": "14648",
"ads_percentage_today": "80.89" "ads_percentage_today": "80.89"
} }
``` ```
The same output can be acheived on the CLI by running `chronometer.sh -j`
The same output can be achieved on the CLI by running `chronometer.sh -j`
## Real-time Statistics ## Real-time Statistics
You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-monitor-chronometer/) via `ssh` or on an [2.8" LCD screen](http://amzn.to/1P0q1Fj). This is accomplished via [`chronometer.sh`](https://github.com/pi-hole/pi-hole/blob/master/advanced/Scripts/chronometer.sh). ![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg)
![Pi-hole LCD](http://i.imgur.com/nBEqycp.jpg)
## Pi-hole Projects ## Pi-hole Projects
- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/) - [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html) - [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/) - [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/) - [Docker Pi-hole container (x86 and ARM)](https://hub.docker.com/r/diginc/pi-hole/)
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension)) - [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037) - [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
- [Sky-Hole](http://dlaa.me/blog/post/skyhole) - [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
- [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/) - [Sky-Hole](http://dlaa.me/blog/post/skyhole)
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0) - [Pi-hole in the Cloud!](http://blog.codybunch.com/2015/07/28/Pi-Hole-in-the-cloud/)
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/) - [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) - [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
- [Windows Tray Stat Application](https://github.com/goldbattle/copernicus)
## Coverage ## Coverage
- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI)
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s) - [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI)
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/) - [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s) - [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
- [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585) - [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
- [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d) - [MacObserver Podcast 585](http://www.macobserver.com/tmo/podcast/macgeekgab-585)
- [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/) - [Medium: Block All Ads For $53](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d)
- [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)! - [MakeUseOf: Adblock Everywhere, The Pi-hole Way](http://www.makeuseof.com/tag/adblock-everywhere-raspberry-pi-hole-way/)
- [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m) - [Lifehacker: Turn Your Pi Into An Ad Blocker With A Single Command](http://lifehacker.com/turn-a-raspberry-pi-into-an-ad-blocker-with-a-single-co-1686093533)!
- [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s) - [Pi-hole on TekThing](https://youtu.be/8Co59HU2gY0?t=2m)
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s) - [Pi-hole on Security Now! Podcast](http://www.youtube.com/watch?v=p7-osq_y8i8&t=100m26s)
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/) - [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/) - [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
## Other Operating Systems ## Other Operating Systems
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi.
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi.

View File

@@ -14,7 +14,6 @@
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
# Other lists we consider safe: # Other lists we consider safe:
http://adblock.gjtech.net/?format=unix-hosts
http://mirror1.malwaredomains.com/files/justdomains http://mirror1.malwaredomains.com/files/justdomains
http://sysctl.org/cameleon/hosts http://sysctl.org/cameleon/hosts
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist

View File

@@ -47,9 +47,9 @@ fi
#globals #globals
basename=pihole basename=pihole
piholeDir=/etc/$basename piholeDir=/etc/${basename}
adList=$piholeDir/gravity.list adList=${piholeDir}/gravity.list
blacklist=$piholeDir/blacklist.txt blacklist=${piholeDir}/blacklist.txt
reload=true reload=true
addmode=true addmode=true
force=false force=false
@@ -61,9 +61,9 @@ domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6 piholeIPv6file=/etc/pihole/.useIPv6
if [[ -f $piholeIPfile ]];then if [[ -f ${piholeIPfile} ]];then
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script # If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
piholeIP=$(cat $piholeIPfile) piholeIP=$(cat ${piholeIPfile})
#rm $piholeIPfile #rm $piholeIPfile
else else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
@@ -75,13 +75,13 @@ fi
modifyHost=false modifyHost=false
# After setting defaults, check if there's local overrides # After setting defaults, check if there's local overrides
if [[ -r $piholeDir/pihole.conf ]];then if [[ -r ${piholeDir}/pihole.conf ]];then
echo "::: Local calibration requested..." echo "::: Local calibration requested..."
. $piholeDir/pihole.conf . ${piholeDir}/pihole.conf
fi fi
if [[ -f $piholeIPv6file ]];then if [[ -f ${piholeIPv6file} ]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer # If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi fi
@@ -92,14 +92,14 @@ function HandleOther(){
if [ -z "$validDomain" ]; then if [ -z "$validDomain" ]; then
echo "::: $1 is not a valid argument or domain name" echo "::: $1 is not a valid argument or domain name"
else else
domList=("${domList[@]}" $validDomain) domList=("${domList[@]}" ${validDomain})
fi fi
} }
function PopBlacklistFile(){ function PopBlacklistFile(){
#check blacklist file exists, and if not, create it #check blacklist file exists, and if not, create it
if [[ ! -f $blacklist ]];then if [[ ! -f ${blacklist} ]];then
touch $blacklist touch ${blacklist}
fi fi
for dom in "${domList[@]}"; do for dom in "${domList[@]}"; do
if "$addmode"; then if "$addmode"; then
@@ -113,17 +113,17 @@ function PopBlacklistFile(){
function AddDomain(){ function AddDomain(){
#| sed 's/\./\\./g' #| sed 's/\./\\./g'
bool=false bool=false
grep -Ex -q "$1" $blacklist || bool=true grep -Ex -q "$1" ${blacklist} || bool=true
if $bool; then if ${bool}; then
#domain not found in the blacklist file, add it! #domain not found in the blacklist file, add it!
if $verbose; then if ${verbose}; then
echo -n "::: Adding $1 to blacklist file..." echo -n "::: Adding $1 to blacklist file..."
fi fi
echo "$1" >> $blacklist echo "$1" >> ${blacklist}
modifyHost=true modifyHost=true
echo " done!" echo " done!"
else else
if $verbose; then if ${verbose}; then
echo "::: $1 already exists in $blacklist! No need to add" echo "::: $1 already exists in $blacklist! No need to add"
fi fi
fi fi
@@ -132,15 +132,15 @@ function AddDomain(){
function RemoveDomain(){ function RemoveDomain(){
bool=false bool=false
grep -Ex -q "$1" $blacklist || bool=true grep -Ex -q "$1" ${blacklist} || bool=true
if $bool; then if ${bool}; then
#Domain is not in the blacklist file, no need to Remove #Domain is not in the blacklist file, no need to Remove
if $verbose; then if ${verbose}; then
echo "::: $1 is NOT blacklisted! No need to remove" echo "::: $1 is NOT blacklisted! No need to remove"
fi fi
else else
#Domain is in the blacklist file, add to a temporary array #Domain is in the blacklist file, add to a temporary array
if $verbose; then if ${verbose}; then
echo "::: Un-blacklisting $dom..." echo "::: Un-blacklisting $dom..."
fi fi
domToRemoveList=("${domToRemoveList[@]}" $1) domToRemoveList=("${domToRemoveList[@]}" $1)
@@ -149,17 +149,17 @@ function RemoveDomain(){
} }
function ModifyHostFile(){ function ModifyHostFile(){
if $addmode; then if ${addmode}; then
#add domains to the hosts file #add domains to the hosts file
if [[ -r $blacklist ]];then if [[ -r ${blacklist} ]];then
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) numberOf=$(cat ${blacklist} | sed '/^\s*$/d' | wc -l)
plural=; [[ "$numberOf" != "1" ]] && plural=s plural=; [[ "$numberOf" != "1" ]] && plural=s
echo ":::" echo ":::"
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
if [[ -n $piholeIPv6 ]];then if [[ -n ${piholeIPv6} ]];then
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList cat ${blacklist} | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${adList}
else else
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList cat ${blacklist} | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>${adList}
fi fi
fi fi
else else
@@ -169,10 +169,10 @@ function ModifyHostFile(){
#we need to remove the domains from the blacklist file and the host file #we need to remove the domains from the blacklist file and the host file
echo "::: $dom" echo "::: $dom"
echo -n "::: removing from HOSTS file..." echo -n "::: removing from HOSTS file..."
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' ${adList}
echo " done!" echo " done!"
echo -n "::: removing from blackist.txt..." echo -n "::: removing from blackist.txt..."
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${blacklist}
echo " done!" echo " done!"
done done
fi fi
@@ -185,12 +185,12 @@ function Reload() {
dnsmasqPid=$(pidof dnsmasq) dnsmasqPid=$(pidof dnsmasq)
if [[ $dnsmasqPid ]]; then if [[ ${dnsmasqPid} ]]; then
# service already running - reload config # service already running - reload config
$SUDO killall -s HUP dnsmasq ${SUDO} killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
$SUDO service dnsmasq start ${SUDO} service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
@@ -223,15 +223,15 @@ done
PopBlacklistFile PopBlacklistFile
if $modifyHost || $force; then if ${modifyHost} || ${force}; then
ModifyHostFile ModifyHostFile
else else
if $verbose; then if ${verbose}; then
echo "::: No changes need to be made" echo "::: No changes need to be made"
fi fi
exit 1 exit 1
fi fi
if $reload; then if ${reload}; then
Reload Reload
fi fi

View File

@@ -21,7 +21,7 @@ function CalcBlockedDomains(){
CheckIPv6 CheckIPv6
if [ -e "$gravity" ]; then if [ -e "$gravity" ]; then
#Are we IPV6 or IPV4? #Are we IPV6 or IPV4?
if [[ -n $piholeIPv6 ]];then if [[ -n ${piholeIPv6} ]];then
#We are IPV6 #We are IPV6
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}') blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
else else
@@ -43,7 +43,7 @@ function CalcQueriesToday(){
function CalcblockedToday(){ function CalcblockedToday(){
if [ -e "$piLog" ] && [ -e "$gravity" ];then if [ -e "$piLog" ] && [ -e "$gravity" ];then
blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l) blockedToday=$(cat ${piLog} | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
else else
blockedToday="Err." blockedToday="Err."
fi fi
@@ -63,7 +63,7 @@ function CalcPercentBlockedToday(){
function CheckIPv6(){ function CheckIPv6(){
piholeIPv6file="/etc/pihole/.useIPv6" piholeIPv6file="/etc/pihole/.useIPv6"
if [[ -f $piholeIPv6file ]];then if [[ -f ${piholeIPv6file} ]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer # If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi fi

View File

@@ -3,16 +3,14 @@
# (c) 2015, 2016 by Jacob Salmela # (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi # Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net # http://pi-hole.net
# Generates pihole_debug.log in /var/log/ to be used for troubleshooting. # Generates pihole_debug.log to be used for troubleshooting.
# #
# Pi-hole is free software: you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or # the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version. # (at your option) any later version.
# Nate Brandeburg set -o pipefail
# nate@ubiquisoft.com
# 3/24/2016
######## GLOBAL VARS ######## ######## GLOBAL VARS ########
DEBUG_LOG="/var/log/pihole_debug.log" DEBUG_LOG="/var/log/pihole_debug.log"
@@ -28,93 +26,188 @@ ADLISTSFILE="/etc/pihole/adlists.list"
PIHOLELOG="/var/log/pihole.log" PIHOLELOG="/var/log/pihole.log"
WHITELISTMATCHES="/tmp/whitelistmatches.list" WHITELISTMATCHES="/tmp/whitelistmatches.list"
# Header info and introduction
echo "::: Beginning Pi-hole debug at $(date)!"
echo "::: This debugging process will collect information from your running configuration,"
echo "::: and optionally upload the generated log to a unique and random directory on"
echo "::: Termbin.com. NOTE: All log files auto-delete after 1 month and you are the only"
echo "::: person who is given the unique URL. Please consider where you post this link."
echo "::: "
######## FIRST CHECK ######## ######## FIRST CHECK ########
# Must be root to debug # Must be root to debug
if [[ $EUID -eq 0 ]]; then if [[ "$EUID" -eq 0 ]]; then
echo "::: You are root... Beginning debug!" echo "::: Script is executing as root user..."
else else
echo "::: Sudo will be used for debugging." echo "::: Non-root user detected..."
# Check if sudo is actually installed # Check if sudo is actually installed
if [ -x "$(command -v sudo)" ]; then if [ -x "$(command -v sudo)" ]; then
export SUDO="sudo" export SUDO="sudo"
echo "::: sudo command located, debug will run under sudo."
else else
echo "::: Please install sudo or run this as root." echo "::: Unable to locate sudo command. Please install sudo or run this as root."
exit 1 exit 1
fi fi
fi fi
# Ensure the file exists, create if not, clear if exists. # Ensure the file exists, create if not, clear if exists.
if [ ! -f "$DEBUG_LOG" ]; then if [ ! -f "$DEBUG_LOG" ]; then
$SUDO touch $DEBUG_LOG ${SUDO} touch ${DEBUG_LOG}
$SUDO chmod 644 $DEBUG_LOG ${SUDO} chmod 644 ${DEBUG_LOG}
$SUDO chown "$USER":root $DEBUG_LOG ${SUDO} chown "$USER":root ${DEBUG_LOG}
else else
truncate -s 0 $DEBUG_LOG truncate -s 0 ${DEBUG_LOG}
fi fi
### Private functions exist here ### ### Private functions exist here ###
function versionCheck { function log_write {
echo "#######################################" >> $DEBUG_LOG echo "$1" >> "${DEBUG_LOG}"
echo "########## Versions Section ###########" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
TMP=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
echo "Pi-hole Version: $TMP" >> $DEBUG_LOG
TMP=$(cd /var/www/html/admin && git describe --tags --abbrev=0)
echo "WebUI Version: $TMP" >> $DEBUG_LOG
echo >> $DEBUG_LOG
} }
function distroCheck { function version_check {
echo "#######################################" >> $DEBUG_LOG log_write "############################################################"
echo "######## Distribution Section #########" >> $DEBUG_LOG log_write "########## Installed Versions ##########"
echo "#######################################" >> $DEBUG_LOG log_write "############################################################"
TMP=$(cat /etc/*release/ || echo "Failed to find release")
echo "Distribution Version: $TMP" >> $DEBUG_LOG
function compareWhitelist {
if [ ! -f "$WHITELISTMATCHES" ]; then
$SUDO touch $WHITELISTMATCHES
$SUDO chmod 644 $WHITELISTMATCHES
$SUDO chown "$USER":root $WHITELISTMATCHES
else
truncate -s 0 $WHITELISTMATCHES
fi
echo "#######################################" >> $DEBUG_LOG echo "::: Detecting Pi-hole installed versions."
echo "######## Whitelist Comparison #########" >> $DEBUG_LOG pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \
echo "#######################################" >> $DEBUG_LOG && log_write "Pi-hole Version: $pi_hole_ver" || log_write "Pi-hole git repository not detected."
while read -r line; do admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \
TMP=$(grep -w ".* $line$" "$GRAVITYFILE") && log_write "WebUI Version: $admin_ver" || log_write "Pi-hole Admin Pages git repository not detected."
if [ ! -z "$TMP" ]; then
echo "$TMP" >> $DEBUG_LOG echo "::: Writing lighttpd version to logfile."
echo "$TMP" >> $WHITELISTMATCHES light_ver="$(lighttpd -v |& head -n1)" && log_write "${light_ver}" || log_write "lighttpd not installed."
fi
done < "$WHITELISTFILE" echo "::: Writing PHP version to logfile."
echo >> $DEBUG_LOG php_ver="$(php -v |& head -n1)" && log_write "${php_ver}" || log_write "PHP not installed."
} }
function compareBlacklist { function distro_check {
echo "#######################################" >> $DEBUG_LOG echo "############################################################" >> ${DEBUG_LOG}
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG echo "######## Installed OS Distribution #########" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "############################################################" >> ${DEBUG_LOG}
while read -r line; do
if [ ! -z "$line" ]; then echo "::: Checking installed OS Distribution release."
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG TMP=$(cat /etc/*release || echo "Failed to find release")
fi
done < "$BLACKLISTFILE" echo "::: Writing OS Distribution release to logfile."
echo >> $DEBUG_LOG echo "$TMP" >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
} }
function testNslookup { function ip_check {
TESTURL="doubleclick.com" echo "############################################################" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "######## IP Address Information #########" >> ${DEBUG_LOG}
echo "############ NSLookup Test ############" >> $DEBUG_LOG echo "############################################################" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG
echo "::: Writing local IPs to logfile"
IPADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')"
echo "$IPADDR" >> ${DEBUG_LOG}
IP6ADDR="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')" \
&& echo "$IP6ADDR" >> ${DEBUG_LOG} || echo "No IPv6 addresses found." >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
echo "::: Locating default gateway and checking connectivity"
GATEWAY=$(ip r | grep default | cut -d ' ' -f 3)
if [[ $? = 0 ]]
then
echo "::: Pinging default IPv4 gateway..."
GATEWAY_CHECK=$(ping -q -w 3 -c 3 -n "${GATEWAY}" | tail -n3)
if [[ $? = 0 ]]
then
echo "IPv4 Gateway check:" >> ${DEBUG_LOG}
else
echo "IPv4 Gateway check failed:" >> ${DEBUG_LOG}
fi
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
echo "::: Pinging Internet via IPv4..."
INET_CHECK=$(ping -q -w 5 -c 3 -n 8.8.8.8 | tail -n3)
if [[ $? = 0 ]]
then
echo "IPv4 Internet check:" >> ${DEBUG_LOG}
else
echo "IPv4 Internet check failed:" >> ${DEBUG_LOG}
fi
echo "$INET_CHECK" >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
fi
GATEWAY6=$(ip -6 r | grep default | cut -d ' ' -f 3)
if [[ $? = 0 ]]
then
echo "::: Pinging default IPv6 gateway..."
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n "${GATEWAY6}" | tail -n3)
if [[ $? = 0 ]]
then
echo "IPv6 Gateway check:" >> ${DEBUG_LOG}
else
echo "IPv6 Gateway check failed:" >> ${DEBUG_LOG}
fi
echo "::: Pinging Internet via IPv6..."
GATEWAY6_CHECK=$(ping6 -q -w 3 -c 3 -n 2001:4860:4860::8888 | tail -n3)
if [[ $? = 0 ]]
then
echo "IPv6 Internet check:" >> ${DEBUG_LOG}
else
echo "IPv6 Internet check failed:" >> ${DEBUG_LOG}
fi
else
GATEWAY_CHECK="No IPv6 Gateway Detected"
fi
echo "$GATEWAY_CHECK" >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
}
function hostnameCheck {
echo "############################################################" >> ${DEBUG_LOG}
echo "######## Hostname Information #########" >> ${DEBUG_LOG}
echo "############################################################" >> ${DEBUG_LOG}
echo "::: Writing locally configured hostnames to logfile"
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
echo "This Pi-hole is: $(hostname)" >> ${DEBUG_LOG}
echo "::: Writing hosts file to debug log..."
echo "### Hosts ###" >> ${DEBUG_LOG}
if [ -e "$HOSTSFILE" ]
then
cat "$HOSTSFILE" >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
else
echo "No hosts file found!" >> ${DEBUG_LOG}
printf ":::\tNo hosts file found!\n"
fi
}
function portCheck {
echo "############################################################" >> ${DEBUG_LOG}
echo "######## Open Port Information #########" >> ${DEBUG_LOG}
echo "############################################################" >> ${DEBUG_LOG}
echo "::: Detecting local server port 80 and 53 processes."
${SUDO} lsof -i :80 >> ${DEBUG_LOG}
${SUDO} lsof -i :53 >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
}
function testResolver {
echo "############################################################" >> ${DEBUG_LOG}
echo "############ Resolver Functions Check ############" >> ${DEBUG_LOG}
echo "############################################################" >> ${DEBUG_LOG}
# Find a blocked url that has not been whitelisted. # Find a blocked url that has not been whitelisted.
TESTURL="doubleclick.com"
if [ -s "$WHITELISTMATCHES" ]; then if [ -s "$WHITELISTMATCHES" ]; then
while read -r line; do while read -r line; do
CUTURL=${line#*" "} CUTURL=${line#*" "}
@@ -130,190 +223,198 @@ function testNslookup {
done < "$GRAVITYFILE" done < "$GRAVITYFILE"
fi fi
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG echo "Resolution of $TESTURL from Pi-hole:" >> ${DEBUG_LOG}
nslookup "$TESTURL" >> $DEBUG_LOG LOCALDIG=$(dig "$TESTURL" @127.0.0.1)
echo >> $DEBUG_LOG if [[ $? = 0 ]]
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG then
nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG echo "$LOCALDIG" >> ${DEBUG_LOG}
echo >> $DEBUG_LOG else
echo "Failed to resolve $TESTURL on Pi-hole" >> ${DEBUG_LOG}
fi
echo >> ${DEBUG_LOG}
echo "Resolution of $TESTURL from 8.8.8.8:" >> ${DEBUG_LOG}
REMOTEDIG=$(dig "$TESTURL" @8.8.8.8)
if [[ $? = 0 ]]
then
echo "$REMOTEDIG" >> ${DEBUG_LOG}
else
echo "Failed to resolve $TESTURL on 8.8.8.8" >> ${DEBUG_LOG}
fi
echo >> ${DEBUG_LOG}
echo "Pi-hole dnsmasq specific records lookups" >> ${DEBUG_LOG}
echo "Cache Size:" >> ${DEBUG_LOG}
dig +short chaos txt cachesize.bind >> ${DEBUG_LOG}
echo "Insertions count:" >> ${DEBUG_LOG}
dig +short chaos txt insertions.bind >> ${DEBUG_LOG}
echo "Evictions count:" >> ${DEBUG_LOG}
dig +short chaos txt evictions.bind >> ${DEBUG_LOG}
echo "Misses count:" >> ${DEBUG_LOG}
dig +short chaos txt misses.bind >> ${DEBUG_LOG}
echo "Hits count:" >> ${DEBUG_LOG}
dig +short chaos txt hits.bind >> ${DEBUG_LOG}
echo "Auth count:" >> ${DEBUG_LOG}
dig +short chaos txt auth.bind >> ${DEBUG_LOG}
echo "Upstream Servers:" >> ${DEBUG_LOG}
dig +short chaos txt servers.bind >> ${DEBUG_LOG}
echo >> ${DEBUG_LOG}
} }
function checkProcesses { function checkProcesses {
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "########### Processes Check ###########" >> $DEBUG_LOG echo "########### Processes Check ###########" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo ":::" echo ":::"
echo "::: Logging status of lighttpd and dnsmasq..." echo "::: Logging status of lighttpd and dnsmasq..."
PROCESSES=( lighttpd dnsmasq ) PROCESSES=( lighttpd dnsmasq )
for i in "${PROCESSES[@]}" for i in "${PROCESSES[@]}"
do do
echo "" >> $DEBUG_LOG echo "" >> ${DEBUG_LOG}
echo -n "$i" >> "$DEBUG_LOG" echo -n "$i" >> "$DEBUG_LOG"
echo " processes status:" >> $DEBUG_LOG echo " processes status:" >> ${DEBUG_LOG}
$SUDO systemctl -l status "$i" >> "$DEBUG_LOG" ${SUDO} systemctl -l status "$i" >> "$DEBUG_LOG"
done done
echo >> ${DEBUG_LOG}
} }
function debugLighttpd { function debugLighttpd {
echo "::: Writing lighttpd to debug log..." echo "::: Writing lighttpd to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############ lighttpd.conf ############" >> $DEBUG_LOG echo "############ lighttpd.conf ############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$LIGHTTPDFILE" ] if [ -e "$LIGHTTPDFILE" ]
then then
while read -r line; do while read -r line; do
if [ ! -z "$line" ]; then if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue [[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG echo "$line" >> ${DEBUG_LOG}
fi fi
done < "$LIGHTTPDFILE" done < "$LIGHTTPDFILE"
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No lighttpd.conf file found!" >> $DEBUG_LOG echo "No lighttpd.conf file found!" >> ${DEBUG_LOG}
printf ":::\tNo lighttpd.conf file found\n" printf ":::\tNo lighttpd.conf file found\n"
fi fi
if [ -e "$LIGHTTPDERRFILE" ] if [ -e "$LIGHTTPDERRFILE" ]
then then
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "######### lighttpd error.log ##########" >> $DEBUG_LOG echo "######### lighttpd error.log ##########" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
cat "$LIGHTTPDERRFILE" >> $DEBUG_LOG cat "$LIGHTTPDERRFILE" >> ${DEBUG_LOG}
else else
echo "No lighttpd error.log file found!" >> $DEBUG_LOG echo "No lighttpd error.log file found!" >> ${DEBUG_LOG}
printf ":::\tNo lighttpd error.log file found\n" printf ":::\tNo lighttpd error.log file found\n"
fi fi
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
} }
### END FUNCTIONS ### ### END FUNCTIONS ###
### Check Pi internet connections ### version_check
# Log the IP addresses of this Pi distro_check
IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e') ip_check
echo "::: Writing local IPs to debug log" hostnameCheck
echo "IP Addresses of this Pi:" >> $DEBUG_LOG portCheck
echo "$IPADDR" >> $DEBUG_LOG
echo >> $DEBUG_LOG
# Check if we can connect to the local gateway
GATEWAY_CHECK=$(ping -q -w 1 -c 1 "$(ip r | grep default | cut -d ' ' -f 3)" > /dev/null && echo ok || echo error)
echo "Gateway check:" >> $DEBUG_LOG
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
echo >> $DEBUG_LOG
versionCheck
distroCheck
compareWhitelist
compareBlacklist
testNslookup
checkProcesses checkProcesses
testResolver
debugLighttpd debugLighttpd
echo "::: Writing dnsmasq.conf to debug log..." echo "::: Writing dnsmasq.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############### Dnsmasq ###############" >> $DEBUG_LOG echo "############### Dnsmasq ###############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$DNSMASQFILE" ] if [ -e "$DNSMASQFILE" ]
then then
#cat $DNSMASQFILE >> $DEBUG_LOG #cat $DNSMASQFILE >> $DEBUG_LOG
while read -r line; do while read -r line; do
if [ ! -z "$line" ]; then if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue [[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG echo "$line" >> ${DEBUG_LOG}
fi fi
done < "$DNSMASQFILE" done < "$DNSMASQFILE"
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No dnsmasq.conf file found!" >> $DEBUG_LOG echo "No dnsmasq.conf file found!" >> ${DEBUG_LOG}
printf ":::\tNo dnsmasq.conf file found!\n" printf ":::\tNo dnsmasq.conf file found!\n"
fi fi
echo "::: Writing 01-pihole.conf to debug log..." echo "::: Writing 01-pihole.conf to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "########### 01-pihole.conf ############" >> $DEBUG_LOG echo "########### 01-pihole.conf ############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$PIHOLECONFFILE" ] if [ -e "$PIHOLECONFFILE" ]
then then
while read -r line; do while read -r line; do
if [ ! -z "$line" ]; then if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue [[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> $DEBUG_LOG echo "$line" >> ${DEBUG_LOG}
fi fi
done < "$PIHOLECONFFILE" done < "$PIHOLECONFFILE"
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No 01-pihole.conf file found!" >> $DEBUG_LOG echo "No 01-pihole.conf file found!" >> ${DEBUG_LOG}
printf ":::\tNo 01-pihole.conf file found\n" printf ":::\tNo 01-pihole.conf file found\n"
fi fi
echo "::: Writing size of gravity.list to debug log..." echo "::: Writing size of gravity.list to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############ gravity.list #############" >> $DEBUG_LOG echo "############ gravity.list #############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$GRAVITYFILE" ] if [ -e "$GRAVITYFILE" ]
then then
wc -l "$GRAVITYFILE" >> $DEBUG_LOG wc -l "$GRAVITYFILE" >> ${DEBUG_LOG}
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No gravity.list file found!" >> $DEBUG_LOG echo "No gravity.list file found!" >> ${DEBUG_LOG}
printf ":::\tNo gravity.list file found\n" printf ":::\tNo gravity.list file found\n"
fi fi
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
echo "Hostname of this pihole is: " >> $DEBUG_LOG
hostname >> $DEBUG_LOG
echo "::: Writing hosts file to debug log..." ### Pi-hole application specific logging ###
echo "#######################################" >> $DEBUG_LOG
echo "################ Hosts ################" >> $DEBUG_LOG
echo "#######################################" >> $DEBUG_LOG
if [ -e "$HOSTSFILE" ]
then
cat "$HOSTSFILE" >> $DEBUG_LOG
echo >> $DEBUG_LOG
else
echo "No hosts file found!" >> $DEBUG_LOG
printf ":::\tNo hosts file found!\n"
fi
### PiHole application specific logging ###
echo "::: Writing whitelist to debug log..." echo "::: Writing whitelist to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############## Whitelist ##############" >> $DEBUG_LOG echo "############## Whitelist ##############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$WHITELISTFILE" ] if [ -e "$WHITELISTFILE" ]
then then
cat "$WHITELISTFILE" >> $DEBUG_LOG cat "$WHITELISTFILE" >> ${DEBUG_LOG}
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No whitelist.txt file found!" >> $DEBUG_LOG echo "No whitelist.txt file found!" >> ${DEBUG_LOG}
printf ":::\tNo whitelist.txt file found!\n" printf ":::\tNo whitelist.txt file found!\n"
fi fi
echo "::: Writing blacklist to debug log..." echo "::: Writing blacklist to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############## Blacklist ##############" >> $DEBUG_LOG echo "############## Blacklist ##############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$BLACKLISTFILE" ] if [ -e "$BLACKLISTFILE" ]
then then
cat "$BLACKLISTFILE" >> $DEBUG_LOG cat "$BLACKLISTFILE" >> ${DEBUG_LOG}
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
else else
echo "No blacklist.txt file found!" >> $DEBUG_LOG echo "No blacklist.txt file found!" >> ${DEBUG_LOG}
printf ":::\tNo blacklist.txt file found!\n" printf ":::\tNo blacklist.txt file found!\n"
fi fi
echo "::: Writing adlists.list to debug log..." echo "::: Writing adlists.list to debug log..."
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############ adlists.list #############" >> $DEBUG_LOG echo "############ adlists.list #############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$ADLISTSFILE" ] if [ -e "$ADLISTSFILE" ]
then then
cat "$ADLISTSFILE" >> $DEBUG_LOG while read -r line; do
echo >> $DEBUG_LOG if [ ! -z "$line" ]; then
[[ "$line" =~ ^#.*$ ]] && continue
echo "$line" >> ${DEBUG_LOG}
fi
done < "$ADLISTSFILE"
echo >> ${DEBUG_LOG}
else else
echo "No adlists.list file found... using adlists.default!" >> $DEBUG_LOG echo "No adlists.list file found... using adlists.default!" >> ${DEBUG_LOG}
printf ":::\tNo adlists.list file found... using adlists.default!\n" printf ":::\tNo adlists.list file found... using adlists.default!\n"
fi fi
@@ -321,35 +422,45 @@ fi
# Continuously append the pihole.log file to the pihole_debug.log file # Continuously append the pihole.log file to the pihole_debug.log file
function dumpPiHoleLog { function dumpPiHoleLog {
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)" echo -e "::: Writing current Pi-hole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
echo "############# pihole.log ##############" >> $DEBUG_LOG echo "############# pihole.log ##############" >> ${DEBUG_LOG}
echo "#######################################" >> $DEBUG_LOG echo "#######################################" >> ${DEBUG_LOG}
if [ -e "$PIHOLELOG" ] if [ -e "$PIHOLELOG" ]
then then
while true; do while true; do
tail -f "$PIHOLELOG" >> $DEBUG_LOG tail -f "$PIHOLELOG" >> ${DEBUG_LOG}
echo >> $DEBUG_LOG echo >> ${DEBUG_LOG}
done done
else else
echo "No pihole.log file found!" >> $DEBUG_LOG echo "No pihole.log file found!" >> ${DEBUG_LOG}
printf ":::\tNo pihole.log file found!\n" printf ":::\tNo pihole.log file found!\n"
fi fi
} }
# Anything to be done after capturing of pihole.log terminates # Anything to be done after capturing of pihole.log terminates
function finalWork { function finalWork {
echo "::: Finshed debugging!" echo "::: Finshed debugging!"
TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999) echo "::: The debug log can be uploaded to Termbin.com for easier sharing."
read -r -p "::: Would you like to upload the log? [y/N] " response
case ${response} in
[yY][eE][sS]|[yY])
TERMBIN=$(cat /var/log/pihole_debug.log | nc termbin.com 9999)
;;
*)
echo "::: Log will NOT be uploaded to Termbin."
;;
esac
# Check if termbin.com is reachable. When it's not, point to local log instead # Check if termbin.com is reachable. When it's not, point to local log instead
if [ -n "$TERMBIN" ] if [ -n "$TERMBIN" ]
then then
echo "::: Debug log can be found at : $TERMBIN" echo "::: Debug log can be found at : $TERMBIN"
else else
echo "::: Debug log can be found at : /var/log/pihole_debug.log" echo "::: Debug log can be found at : /var/log/pihole_debug.log"
fi fi
} }
trap finalWork EXIT trap finalWork EXIT
### Method calls for additional logging ### ### Method calls for additional logging ###

View File

@@ -11,5 +11,5 @@
# (at your option) any later version. # (at your option) any later version.
echo -n "::: Flushing /var/log/pihole.log ..." echo -n "::: Flushing /var/log/pihole.log ..."
truncate -s 0 /var/log/pihole.log echo " " > /var/log/pihole.log
echo "... done!" echo "... done!"

View File

@@ -44,12 +44,12 @@ getInitSys() {
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285 # https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
autoLoginPiToConsole() { autoLoginPiToConsole() {
if [ -e /etc/init.d/lightdm ]; then if [ -e /etc/init.d/lightdm ]; then
if [ $SYSTEMD -eq 1 ]; then if [ ${SYSTEMD} -eq 1 ]; then
$SUDO systemctl set-default multi-user.target ${SUDO} systemctl set-default multi-user.target
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service ${SUDO} ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
else else
$SUDO update-rc.d lightdm disable 2 ${SUDO} update-rc.d lightdm disable 2
$SUDO sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/" ${SUDO} sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/"
fi fi
fi fi
} }
@@ -66,23 +66,23 @@ echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
# Set up the LCD screen based on Adafruits instuctions: # Set up the LCD screen based on Adafruits instuctions:
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install # https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash curl -SLs https://apt.adafruit.com/add-pin | ${SUDO} bash
$SUDO apt-get -y install raspberrypi-bootloader ${SUDO} apt-get -y install raspberrypi-bootloader
$SUDO apt-get -y install adafruit-pitft-helper ${SUDO} apt-get -y install adafruit-pitft-helper
$SUDO adafruit-pitft-helper -t 28r ${SUDO} adafruit-pitft-helper -t 28r
# Download the cmdline.txt file that prevents the screen from going blank after a period of time # Download the cmdline.txt file that prevents the screen from going blank after a period of time
$SUDO mv /boot/cmdline.txt /boot/cmdline.orig ${SUDO} mv /boot/cmdline.txt /boot/cmdline.orig
$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt ${SUDO} curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
# Back up the original file and download the new one # Back up the original file and download the new one
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig ${SUDO} mv /etc/default/console-setup /etc/default/console-setup.orig
$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup ${SUDO} curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
# Instantly apply the font change to the LCD screen # Instantly apply the font change to the LCD screen
$SUDO setupcon ${SUDO} setupcon
$SUDO reboot ${SUDO} reboot
# Start showing the stats on the screen by running the command on another tty: # Start showing the stats on the screen by running the command on another tty:
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty # http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty

View File

@@ -1,69 +0,0 @@
#!/usr/bin/env bash
# Pi-hole: A black hole for Internet advertisements
# (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net
# Updates the Pi-hole web interface
#
# 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.
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
WEB_INTERFACE_DIR="/var/www/html/admin"
main() {
prerequisites
if ! is_repo; then
make_repo
fi
update_repo
}
prerequisites() {
# must be root to update
if [[ $EUID -ne 0 ]]; then
sudo bash "$0" "$@"
exit $?
fi
# web interface must already exist. this is a (lazy)
# check to make sure pihole is actually installed.
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
echo "$WEB_INTERFACE_DIR not found. Exiting."
exit 1
fi
if ! type "git" > /dev/null; then
apt-get -y install git
fi
}
is_repo() {
# if the web interface directory does not have a .git folder
# it means its using the master.zip archive from the install
# script.
if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then
return 1
fi
return 0
}
# removes the web interface installed from the master.zip archive and
# replaces it with the current master branch from github
make_repo() {
# remove the non-repod interface and clone the interface
rm -rf $WEB_INTERFACE_DIR
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
}
# pulls the latest master branch from github
update_repo() {
# pull the latest commits
cd "$WEB_INTERFACE_DIR"
git pull
}
main

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env bash
# Pi-hole: A black hole for Internet advertisements
# (c) 2015, 2016 by Jacob Salmela
# Network-wide ad blocking via your Raspberry Pi
# http://pi-hole.net
# Whitelists domains
#
# 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.
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
echo "::: Web-Admin version is $webVersion (Latest version is $webVersionLatest)"

View File

@@ -47,9 +47,9 @@ fi
#globals #globals
basename=pihole basename=pihole
piholeDir=/etc/$basename piholeDir=/etc/${basename}
adList=$piholeDir/gravity.list adList=${piholeDir}/gravity.list
whitelist=$piholeDir/whitelist.txt whitelist=${piholeDir}/whitelist.txt
reload=true reload=true
addmode=true addmode=true
force=false force=false
@@ -61,9 +61,9 @@ domToRemoveList=()
piholeIPfile=/etc/pihole/piholeIP piholeIPfile=/etc/pihole/piholeIP
piholeIPv6file=/etc/pihole/.useIPv6 piholeIPv6file=/etc/pihole/.useIPv6
if [[ -f $piholeIPfile ]];then if [[ -f ${piholeIPfile} ]];then
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script # If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
piholeIP=$(cat $piholeIPfile) piholeIP=$(cat ${piholeIPfile})
#rm $piholeIPfile #rm $piholeIPfile
else else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script # Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
@@ -75,12 +75,12 @@ fi
modifyHost=false modifyHost=false
# After setting defaults, check if there's local overrides # After setting defaults, check if there's local overrides
if [[ -r $piholeDir/pihole.conf ]];then if [[ -r ${piholeDir}/pihole.conf ]];then
echo "::: Local calibration requested..." echo "::: Local calibration requested..."
. $piholeDir/pihole.conf . ${piholeDir}/pihole.conf
fi fi
if [[ -f $piholeIPv6file ]];then if [[ -f ${piholeIPv6file} ]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer # If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }') piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi fi
@@ -91,18 +91,18 @@ function HandleOther(){
if [ -z "$validDomain" ]; then if [ -z "$validDomain" ]; then
echo "::: $1 is not a valid argument or domain name" echo "::: $1 is not a valid argument or domain name"
else else
domList=("${domList[@]}" $validDomain) domList=("${domList[@]}" ${validDomain})
fi fi
} }
function PopWhitelistFile(){ function PopWhitelistFile(){
#check whitelist file exists, and if not, create it #check whitelist file exists, and if not, create it
if [[ ! -f $whitelist ]];then if [[ ! -f ${whitelist} ]];then
touch $whitelist touch ${whitelist}
fi fi
for dom in "${domList[@]}" for dom in "${domList[@]}"
do do
if $addmode; then if ${addmode}; then
AddDomain "$dom" AddDomain "$dom"
else else
RemoveDomain "$dom" RemoveDomain "$dom"
@@ -114,19 +114,19 @@ function AddDomain(){
#| sed 's/\./\\./g' #| sed 's/\./\\./g'
bool=false bool=false
grep -Ex -q "$1" $whitelist || bool=true grep -Ex -q "$1" ${whitelist} || bool=true
if $bool; then if ${bool}; then
#domain not found in the whitelist file, add it! #domain not found in the whitelist file, add it!
if $verbose; then if ${verbose}; then
echo -n "::: Adding $1 to $whitelist..." echo -n "::: Adding $1 to $whitelist..."
fi fi
echo "$1" >> $whitelist echo "$1" >> ${whitelist}
modifyHost=true modifyHost=true
if $verbose; then if ${verbose}; then
echo " done!" echo " done!"
fi fi
else else
if $verbose; then if ${verbose}; then
echo "::: $1 already exists in $whitelist, no need to add!" echo "::: $1 already exists in $whitelist, no need to add!"
fi fi
fi fi
@@ -135,10 +135,10 @@ function AddDomain(){
function RemoveDomain(){ function RemoveDomain(){
bool=false bool=false
grep -Ex -q "$1" $whitelist || bool=true grep -Ex -q "$1" ${whitelist} || bool=true
if $bool; then if ${bool}; then
#Domain is not in the whitelist file, no need to Remove #Domain is not in the whitelist file, no need to Remove
if $verbose; then if ${verbose}; then
echo "::: $1 is NOT whitelisted! No need to remove" echo "::: $1 is NOT whitelisted! No need to remove"
fi fi
else else
@@ -152,21 +152,21 @@ function RemoveDomain(){
} }
function ModifyHostFile(){ function ModifyHostFile(){
if $addmode; then if ${addmode}; then
#remove domains in from hosts file #remove domains in from hosts file
if [[ -r $whitelist ]];then if [[ -r ${whitelist} ]];then
# Remove whitelist entries # Remove whitelist entries
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l) numberOf=$(cat ${whitelist} | sed '/^\s*$/d' | wc -l)
plural=; [[ "$numberOf" != "1" ]] && plural=s plural=; [[ "$numberOf" != "1" ]] && plural=s
echo ":::" echo ":::"
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..." echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp awk -F':' '{print $1}' ${whitelist} | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp awk -F':' '{print $1}' ${whitelist} | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
echo "l" >> /etc/pihole/whitelist.tmp echo "l" >> /etc/pihole/whitelist.tmp
grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp grep -F -x -v -f ${piholeDir}/whitelist.tmp ${adList} > ${piholeDir}/gravity.tmp
rm $adList rm ${adList}
mv $piholeDir/gravity.tmp $adList mv ${piholeDir}/gravity.tmp ${adList}
rm $piholeDir/whitelist.tmp rm ${piholeDir}/whitelist.tmp
echo " done!" echo " done!"
fi fi
@@ -175,20 +175,23 @@ function ModifyHostFile(){
echo ":::" echo ":::"
echo "::: Modifying HOSTS file to un-whitelist domains..." echo "::: Modifying HOSTS file to un-whitelist domains..."
for rdom in "${domToRemoveList[@]}" for rdom in "${domToRemoveList[@]}"
do do
if [[ -n $piholeIPv6 ]];then if grep -q "$rdom" /etc/pihole/*.domains; then
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..." echo "::: AdLists contain $rdom, re-adding block"
echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList if [[ -n ${piholeIPv6} ]];then
echo " done!" echo -n "::: Restoring block for $rdom on IPv4 and IPv6..."
else echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${adList}
echo -n "::: Un-whitelisting $rdom on IPv4" echo " done!"
echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList else
echo " done!" echo -n "::: Restoring block for $rdom on IPv4..."
fi echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>${adList}
echo -n "::: Removing $rdom from $whitelist..." echo " done!"
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist fi
echo " done!" fi
done echo -n "::: Removing $rdom from $whitelist..."
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' ${whitelist}
echo " done!"
done
fi fi
} }
@@ -198,12 +201,12 @@ function Reload() {
echo -n "::: Refresh lists in dnsmasq..." echo -n "::: Refresh lists in dnsmasq..."
dnsmasqPid=$(pidof dnsmasq) dnsmasqPid=$(pidof dnsmasq)
if [[ $dnsmasqPid ]]; then if [[ ${dnsmasqPid} ]]; then
# service already running - reload config # service already running - reload config
$SUDO killall -s HUP dnsmasq ${SUDO} killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
$SUDO service dnsmasq start ${SUDO} service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
@@ -236,16 +239,16 @@ done
PopWhitelistFile PopWhitelistFile
if $modifyHost || $force; then if ${modifyHost} || ${force}; then
ModifyHostFile ModifyHostFile
else else
if $verbose; then if ${verbose}; then
echo ":::" echo ":::"
echo "::: No changes need to be made" echo "::: No changes need to be made"
fi fi
exit 1 exit 1
fi fi
if $reload; then if ${reload}; then
Reload Reload
fi fi

View File

@@ -4,7 +4,7 @@ _pihole()
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer uninstall help" opts="blacklist chronometer debug flush help query setupLCD uninstall updateDashboard updateGravity updatePihole version whitelist"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0 return 0

View File

@@ -1,4 +1,7 @@
<html> <html>
<head>
<script>window.close();</script>
</head>
<body> <body>
</body> </body>
</html> </html>

View File

@@ -13,14 +13,13 @@
# Download any updates from the adlists # Download any updates from the adlists
59 1 * * 7 root /usr/local/bin/pihole updateGravity 59 1 * * 7 root /usr/local/bin/pihole updateGravity
# Pi-hole: Update the Web interface shortly after gravity runs # Pi-hole: Update Pi-hole! Uncomment to enable auto update
# This should also update the version number if it is changed in the dashboard repo #30 2 * * 7 root /usr/local/bin/pihole updatePihole
30 2 * * 7 root /usr/local/bin/pihole updateDashboard
# Pi-hole: Parse the log file before it is flushed and save the stats to a database # Pi-hole: Parse the log file before it is flushed and save the stats to a database
# This will be used for a historical view of your Pi-hole's performance # This will be used for a historical view of your Pi-hole's performance
#50 23 * * * root /usr/local/bin/dailyLog.sh # note: this is outdated #50 23 * * * root /usr/local/bin/dailyLog.sh # note: this is outdated
# Pi-hole: Flush the log daily at 11:58 so it doesn't get out of control # Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
# Stats will be viewable in the Web interface thanks to the cron job above # Stats will be viewable in the Web interface thanks to the cron job above
58 23 * * * root /usr/local/bin/pihole flush 00 00 * * * root /usr/local/bin/pihole flush

File diff suppressed because it is too large Load Diff

View File

@@ -39,7 +39,7 @@ if [ -x "$(command -v rpm)" ];then
rpm -qa | grep ^$1- > /dev/null rpm -qa | grep ^$1- > /dev/null
} }
package_cleanup() { package_cleanup() {
$SUDO $PKG_MANAGER -y autoremove ${SUDO} ${PKG_MANAGER} -y autoremove
} }
elif [ -x "$(command -v apt-get)" ];then elif [ -x "$(command -v apt-get)" ];then
# Debian Family # Debian Family
@@ -50,8 +50,8 @@ elif [ -x "$(command -v apt-get)" ];then
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed" dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
} }
package_cleanup() { package_cleanup() {
$SUDO $PKG_MANAGER -y autoremove ${SUDO} ${PKG_MANAGER} -y autoremove
$SUDO $PKG_MANAGER -y autoclean ${SUDO} ${PKG_MANAGER} -y autoclean
} }
else else
echo "OS distribution not supported" echo "OS distribution not supported"
@@ -66,8 +66,8 @@ spinner()
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
local temp=${spinstr#?} local temp=${spinstr#?}
printf " [%c] " "$spinstr" printf " [%c] " "$spinstr"
local spinstr=$temp${spinstr%"$temp"} local spinstr=${temp}${spinstr%"$temp"}
sleep $delay sleep ${delay}
printf "\b\b\b\b\b\b" printf "\b\b\b\b\b\b"
done done
printf " \b\b\b\b" printf " \b\b\b\b"
@@ -77,12 +77,12 @@ function removeAndPurge {
# Purge dependencies # Purge dependencies
echo ":::" echo ":::"
for i in "${PIHOLE_DEPS[@]}"; do for i in "${PIHOLE_DEPS[@]}"; do
package_check $i > /dev/null package_check ${i} > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
while true; do while true; do
read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn
case $yn in case ${yn} in
[Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO $PKG_REMOVE "$i" &> /dev/null & spinner $!; printf "done!\n"; break;; [Yy]* ) printf ":::\tRemoving %s..." "$i"; ${SUDO} ${PKG_REMOVE} "$i" &> /dev/null & spinner $!; printf "done!\n"; break;;
[Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;; [Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;;
* ) printf "::: You must answer yes or no!\n";; * ) printf "::: You must answer yes or no!\n";;
esac esac
@@ -94,7 +94,7 @@ echo ":::"
# Remove dependency config files # Remove dependency config files
echo "::: Removing dnsmasq config files..." echo "::: Removing dnsmasq config files..."
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
# Take care of any additional package cleaning # Take care of any additional package cleaning
printf "::: Auto removing & cleaning remaining dependencies..." printf "::: Auto removing & cleaning remaining dependencies..."
@@ -108,14 +108,14 @@ function removeNoPurge {
echo ":::" echo ":::"
# Only web directories/files that are created by pihole should be removed. # Only web directories/files that are created by pihole should be removed.
echo "::: Removing the Pi-hole Web server files..." echo "::: Removing the Pi-hole Web server files..."
$SUDO rm -rf /var/www/html/admin &> /dev/null ${SUDO} rm -rf /var/www/html/admin &> /dev/null
$SUDO rm -rf /var/www/html/pihole &> /dev/null ${SUDO} rm -rf /var/www/html/pihole &> /dev/null
$SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null ${SUDO} rm /var/www/html/index.lighttpd.orig &> /dev/null
# If the web directory is empty after removing these files, then the parent html folder can be removed. # If the web directory is empty after removing these files, then the parent html folder can be removed.
if [ -d "/var/www/html" ]; then if [ -d "/var/www/html" ]; then
if [[ ! "$(ls -A /var/www/html)" ]]; then if [[ ! "$(ls -A /var/www/html)" ]]; then
$SUDO rm -rf /var/www/html &> /dev/null ${SUDO} rm -rf /var/www/html &> /dev/null
fi fi
fi fi
@@ -125,36 +125,36 @@ function removeNoPurge {
# preserved. # preserved.
if [[ -f /etc/crontab.orig ]]; then if [[ -f /etc/crontab.orig ]]; then
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..." echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
$SUDO mv /etc/crontab /etc/crontab.pihole ${SUDO} mv /etc/crontab /etc/crontab.pihole
$SUDO mv /etc/crontab.orig /etc/crontab ${SUDO} mv /etc/crontab.orig /etc/crontab
$SUDO service cron restart ${SUDO} service cron restart
fi fi
# Attempt to preserve backwards compatibility with older versions # Attempt to preserve backwards compatibility with older versions
if [[ -f /etc/cron.d/pihole ]];then if [[ -f /etc/cron.d/pihole ]];then
echo "::: Removing cron.d/pihole..." echo "::: Removing cron.d/pihole..."
$SUDO rm /etc/cron.d/pihole &> /dev/null ${SUDO} rm /etc/cron.d/pihole &> /dev/null
fi fi
echo "::: Removing config files and scripts..." echo "::: Removing config files and scripts..."
package_check $i > /dev/null package_check ${i} > /dev/null
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
$SUDO rm -rf /etc/lighttpd/ &> /dev/null ${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
else else
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
$SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf ${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
fi fi
fi fi
$SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null
$SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null ${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
$SUDO rm -rf /var/log/*pihole* &> /dev/null ${SUDO} rm -rf /var/log/*pihole* &> /dev/null
$SUDO rm -rf /etc/pihole/ &> /dev/null ${SUDO} rm -rf /etc/pihole/ &> /dev/null
$SUDO rm -rf /etc/.pihole/ &> /dev/null ${SUDO} rm -rf /etc/.pihole/ &> /dev/null
$SUDO rm -rf /opt/pihole/ &> /dev/null ${SUDO} rm -rf /opt/pihole/ &> /dev/null
$SUDO rm /usr/local/bin/pihole &> /dev/null ${SUDO} rm /usr/local/bin/pihole &> /dev/null
$SUDO rm /etc/bash_completion.d/pihole &> /dev/null ${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null
$SUDO rm /etc/sudoers.d/pihole &> /dev/null ${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
echo ":::" echo ":::"
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
@@ -168,7 +168,7 @@ echo "::: Preparing to remove packages, be sure that each may be safely removed
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)" echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
while true; do while true; do
read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn
case $yn in case ${yn} in
[Yy]* ) removeAndPurge; break;; [Yy]* ) removeAndPurge; break;;
[Nn]* ) removeNoPurge; break;; [Nn]* ) removeNoPurge; break;;

View File

@@ -27,49 +27,43 @@ else
fi fi
fi fi
piholeIPfile=/etc/pihole/piholeIP function helpFunc()
piholeIPv6file=/etc/pihole/.useIPv6 {
echo "::: Pull in domains from adlists"
echo ":::"
echo "::: Usage: pihole -g"
echo ":::"
echo "::: Options:"
echo "::: -f, --force Force lists to be downloaded, even if they don't need updating."
echo "::: -h, --help Show this help dialog"
exit 1
}
adListFile=/etc/pihole/adlists.list adListFile=/etc/pihole/adlists.list
adListDefault=/etc/pihole/adlists.default adListDefault=/etc/pihole/adlists.default
whitelistScript=/opt/pihole/whitelist.sh whitelistScript=/opt/pihole/whitelist.sh
blacklistScript=/opt/pihole/blacklist.sh blacklistScript=/opt/pihole/blacklist.sh
if [[ -f $piholeIPfile ]];then #Source the setupVars from install script for the IP
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script . /etc/pihole/setupVars.conf
piholeIP=$(cat $piholeIPfile) #Remove the /* from the end of the IPv4addr.
#rm $piholeIPfile IPv4addr=${IPv4addr%/*}
else
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
piholeIP=${piholeIPCIDR%/*}
fi
if [[ -f $piholeIPv6file ]];then
# If the file exists, then the user previously chose to use IPv6 in the automated installer
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
fi
# Variables for various stages of downloading and formatting the list # Variables for various stages of downloading and formatting the list
## Nate 3/26/2016 - Commented unused variables
basename=pihole basename=pihole
piholeDir=/etc/$basename piholeDir=/etc/${basename}
adList=$piholeDir/gravity.list adList=${piholeDir}/gravity.list
#blacklist=$piholeDir/blacklist.txt
#whitelist=$piholeDir/whitelist.txt
#latentWhitelist=$piholeDir/latentWhitelist.txt
justDomainsExtension=domains justDomainsExtension=domains
matterandlight=$basename.0.matterandlight.txt matterAndLight=${basename}.0.matterandlight.txt
supernova=$basename.1.supernova.txt supernova=${basename}.1.supernova.txt
eventHorizon=$basename.2.eventHorizon.txt eventHorizon=${basename}.2.eventHorizon.txt
accretionDisc=$basename.3.accretionDisc.txt accretionDisc=${basename}.3.accretionDisc.txt
#eyeOfTheNeedle=$basename.4.wormhole.txt
# After setting defaults, check if there's local overrides # After setting defaults, check if there's local overrides
if [[ -r $piholeDir/pihole.conf ]];then if [[ -r ${piholeDir}/pihole.conf ]];then
echo "::: Local calibration requested..." echo "::: Local calibration requested..."
. $piholeDir/pihole.conf . ${piholeDir}/pihole.conf
fi fi
########################### ###########################
@@ -78,18 +72,18 @@ function gravity_collapse() {
echo "::: Neutrino emissions detected..." echo "::: Neutrino emissions detected..."
echo ":::" echo ":::"
#Decide if we're using a custom ad block list, or defaults. #Decide if we're using a custom ad block list, or defaults.
if [ -f $adListFile ]; then if [ -f ${adListFile} ]; then
#custom file found, use this instead of default #custom file found, use this instead of default
echo -n "::: Custom adList file detected. Reading..." echo -n "::: Custom adList file detected. Reading..."
sources=() sources=()
while read -r line; do while read -r line; do
#Do not read commented out or blank lines #Do not read commented out or blank lines
if [[ $line = \#* ]] || [[ ! $line ]]; then if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
echo "" > /dev/null echo "" > /dev/null
else else
sources+=($line) sources+=(${line})
fi fi
done < $adListFile done < ${adListFile}
echo " done!" echo " done!"
else else
#no custom file found, use defaults! #no custom file found, use defaults!
@@ -97,27 +91,27 @@ function gravity_collapse() {
sources=() sources=()
while read -r line; do while read -r line; do
#Do not read commented out or blank lines #Do not read commented out or blank lines
if [[ $line = \#* ]] || [[ ! $line ]]; then if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
echo "" > /dev/null echo "" > /dev/null
else else
sources+=($line) sources+=(${line})
fi fi
done < $adListDefault done < ${adListDefault}
echo " done!" echo " done!"
fi fi
# Create the pihole resource directory if it doesn't exist. Future files will be stored here # Create the pihole resource directory if it doesn't exist. Future files will be stored here
if [[ -d $piholeDir ]];then if [[ -d ${piholeDir} ]];then
# Temporary hack to allow non-root access to pihole directory # Temporary hack to allow non-root access to pihole directory
# Will update later, needed for existing installs, new installs should # Will update later, needed for existing installs, new installs should
# create this directory as non-root # create this directory as non-root
$SUDO chmod 777 $piholeDir ${SUDO} chmod 777 ${piholeDir}
echo ":::" echo ":::"
echo "::: Existing pihole directory found" echo "::: Existing pihole directory found"
else else
echo "::: Creating pihole directory..." echo "::: Creating pihole directory..."
mkdir $piholeDir mkdir ${piholeDir}
$SUDO chmod 777 $piholeDir ${SUDO} chmod 777 ${piholeDir}
fi fi
} }
@@ -146,13 +140,13 @@ function gravity_transport() {
# tmp file, so we don't have to store the (long!) lists in RAM # tmp file, so we don't have to store the (long!) lists in RAM
patternBuffer=$(mktemp) patternBuffer=$(mktemp)
heisenbergCompensator="" heisenbergCompensator=""
if [[ -r $saveLocation ]]; then if [[ -r ${saveLocation} ]]; then
# if domain has been saved, add file for date check to only download newer # if domain has been saved, add file for date check to only download newer
heisenbergCompensator="-z $saveLocation" heisenbergCompensator="-z $saveLocation"
fi fi
# Silently curl url # Silently curl url
curl -s -L $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer curl -s -L ${cmd_ext} ${heisenbergCompensator} -A "$agent" ${url} > ${patternBuffer}
# Check for list updates # Check for list updates
gravity_patternCheck "$patternBuffer" gravity_patternCheck "$patternBuffer"
# Cleanup # Cleanup
@@ -170,8 +164,8 @@ function gravity_spinup() {
domain=$(echo "$url" | cut -d'/' -f3) domain=$(echo "$url" | cut -d'/' -f3)
# Save the file as list.#.domain # Save the file as list.#.domain
saveLocation=$piholeDir/list.$i.$domain.$justDomainsExtension saveLocation=${piholeDir}/list.${i}.${domain}.${justDomainsExtension}
activeDomains[$i]=$saveLocation activeDomains[$i]=${saveLocation}
agent="Mozilla/10.0" agent="Mozilla/10.0"
@@ -201,10 +195,10 @@ function gravity_Schwarzchild() {
echo "::: " echo "::: "
# Find all active domains and compile them into one file and remove CRs # Find all active domains and compile them into one file and remove CRs
echo -n "::: Aggregating list of domains..." echo -n "::: Aggregating list of domains..."
truncate -s 0 $piholeDir/$matterandlight truncate -s 0 ${piholeDir}/${matterAndLight}
for i in "${activeDomains[@]}" for i in "${activeDomains[@]}"
do do
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight cat "$i" | tr -d '\r' >> ${piholeDir}/${matterAndLight}
done done
echo " done!" echo " done!"
} }
@@ -212,7 +206,7 @@ function gravity_Schwarzchild() {
function gravity_Blacklist(){ function gravity_Blacklist(){
# Append blacklist entries if they exist # Append blacklist entries if they exist
echo -n "::: Running blacklist script to update HOSTS file...." echo -n "::: Running blacklist script to update HOSTS file...."
$blacklistScript -f -nr -q > /dev/null ${blacklistScript} -f -nr -q > /dev/null
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt") numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
@@ -229,12 +223,12 @@ function gravity_Whitelist() {
for url in "${sources[@]}" for url in "${sources[@]}"
do do
tmp=$(echo "$url" | awk -F '/' '{print $3}') tmp=$(echo "$url" | awk -F '/' '{print $3}')
urls=("${urls[@]}" $tmp) urls=("${urls[@]}" ${tmp})
done done
echo " done!" echo " done!"
echo -n "::: Running whitelist script to update HOSTS file...." echo -n "::: Running whitelist script to update HOSTS file...."
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null ${whitelistScript} -f -nr -q "${urls[@]}" > /dev/null
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt") numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
echo " $numWhitelisted domain${plural} whitelisted!" echo " $numWhitelisted domain${plural} whitelisted!"
@@ -243,36 +237,42 @@ function gravity_Whitelist() {
function gravity_unique() { function gravity_unique() {
# Sort and remove duplicates # Sort and remove duplicates
echo -n "::: Removing duplicate domains...." echo -n "::: Removing duplicate domains...."
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon sort -u ${piholeDir}/${supernova} > ${piholeDir}/${eventHorizon}
echo " done!" echo " done!"
numberOf=$(wc -l < $piholeDir/$eventHorizon) numberOf=$(wc -l < ${piholeDir}/${eventHorizon})
echo "::: $numberOf unique domains trapped in the event horizon." echo "::: $numberOf unique domains trapped in the event horizon."
} }
function gravity_hostFormat() { function gravity_hostFormat() {
# Format domain list as "192.168.x.x domain.com" # Format domain list as "192.168.x.x domain.com"
echo "::: Formatting domains into a HOSTS file..." echo "::: Formatting domains into a HOSTS file..."
hostname=$(</etc/hostname) if [[ -f /etc/hostname ]]; then
hostname=$(</etc/hostname)
elif [ -x "$(command -v hostname)" ]; then
hostname=$(hostname -f)
else
echo "::: Error: Unable to determine fully qualified domain name of host"
fi
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols # If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
if [[ -n $piholeIPv6 ]];then if [[ -n ${piholeIPv6} ]];then
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin) # Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
echo -e "$piholeIP $hostname\n$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc echo -e "$IPv4addr $hostname\n$piholeIPv6 $hostname\n$IPv4addr pi.hole\n$piholeIPv6 pi.hole" > ${piholeDir}/${accretionDisc}
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
else else
# Otherwise, just create gravity.list as normal using IPv4 # Otherwise, just create gravity.list as normal using IPv4
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin) # Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc echo -e "$IPv4addr $hostname\n$IPv4addr pi.hole" > ${piholeDir}/${accretionDisc}
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPv4addr" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
fi fi
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
cp $piholeDir/$accretionDisc $adList cp ${piholeDir}/${accretionDisc} ${adList}
} }
# blackbody - remove any remnant files from script processes # blackbody - remove any remnant files from script processes
function gravity_blackbody() { function gravity_blackbody() {
# Loop through list files # Loop through list files
for file in $piholeDir/*.$justDomainsExtension for file in ${piholeDir}/*.${justDomainsExtension}
do do
# If list is in active array then leave it (noop) else rm the list # If list is in active array then leave it (noop) else rm the list
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
@@ -289,10 +289,13 @@ function gravity_advanced() {
# This helps with that and makes it easier to read # This helps with that and makes it easier to read
# It also helps with debugging so each stage of the script can be researched more in depth # It also helps with debugging so each stage of the script can be researched more in depth
echo -n "::: Formatting list of domains to remove comments...." echo -n "::: Formatting list of domains to remove comments...."
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova #awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
#Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment')
#Add additional awk command to read all lines up to a '#', and then continue as we were
cat ${piholeDir}/${matterAndLight} | awk -F'#' '{print $1}' | awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
echo " done!" echo " done!"
numberOf=$(wc -l < $piholeDir/$supernova) numberOf=$(wc -l < ${piholeDir}/${supernova})
echo "::: $numberOf domains being pulled in by gravity..." echo "::: $numberOf domains being pulled in by gravity..."
gravity_unique gravity_unique
@@ -302,7 +305,7 @@ function gravity_reload() {
#Clear no longer needed files... #Clear no longer needed files...
echo ":::" echo ":::"
echo -n "::: Cleaning up un-needed files..." echo -n "::: Cleaning up un-needed files..."
$SUDO rm $piholeDir/pihole.*.txt ${SUDO} rm ${piholeDir}/pihole.*.txt
echo " done!" echo " done!"
# Reload hosts file # Reload hosts file
@@ -313,22 +316,38 @@ function gravity_reload() {
#First escape forward slashes in the path: #First escape forward slashes in the path:
adList=${adList//\//\\\/} adList=${adList//\//\\\/}
#Now replace the line in dnsmasq file #Now replace the line in dnsmasq file
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf ${SUDO} sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
dnsmasqPid=$(pidof dnsmasq) dnsmasqPid=$(pidof dnsmasq)
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; find "$piholeDir" -type f -exec ${SUDO} chmod 666 {} \;
if [[ $dnsmasqPid ]]; then if [[ ${dnsmasqPid} ]]; then
# service already running - reload config # service already running - reload config
$SUDO killall -s HUP dnsmasq ${SUDO} killall -s HUP dnsmasq
else else
# service not running, start it up # service not running, start it up
$SUDO service dnsmasq start ${SUDO} service dnsmasq start
fi fi
echo " done!" echo " done!"
} }
$SUDO cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
for var in "$@"
do
case "$var" in
"-f" | "--force" ) forceGrav=true;;
"-h" | "--help" ) helpFunc;;
esac
done
if [[ ${forceGrav} == true ]]; then
echo -n "::: Deleting exising list cache..."
${SUDO} rm /etc/pihole/list.*
echo " done!"
fi
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
${SUDO} cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
gravity_collapse gravity_collapse
gravity_spinup gravity_spinup
gravity_Schwarzchild gravity_Schwarzchild

177
pihole
View File

@@ -12,13 +12,13 @@
# Must be root to use this tool # Must be root to use this tool
if [[ ! $EUID -eq 0 ]];then if [[ ! $EUID -eq 0 ]];then
#echo "::: You are root." #echo "::: You are root."
#else #else
#echo "::: Sudo will be used for this tool." #echo "::: Sudo will be used for this tool."
# Check if it is actually installed # Check if it is actually installed
# If it isn't, exit because the pihole cannot be invoked without privileges. # If it isn't, exit because the pihole cannot be invoked without privileges.
if [ -x "$(command -v sudo)" ];then if [ -x "$(command -v sudo)" ];then
export SUDO="sudo" export SUDO="sudo"
else else
echo "::: Please install sudo or run this as root." echo "::: Please install sudo or run this as root."
exit 1 exit 1
@@ -26,76 +26,161 @@ if [[ ! $EUID -eq 0 ]];then
fi fi
function whitelistFunc { function whitelistFunc {
shift shift
$SUDO /opt/pihole/whitelist.sh "$@" ${SUDO} /opt/pihole/whitelist.sh "$@"
exit 1 exit 1
} }
function blacklistFunc { function blacklistFunc {
shift shift
$SUDO /opt/pihole/blacklist.sh "$@" ${SUDO} /opt/pihole/blacklist.sh "$@"
exit 1 exit 1
} }
function debugFunc { function debugFunc {
$SUDO /opt/pihole/piholeDebug.sh ${SUDO} /opt/pihole/piholeDebug.sh
exit 1 exit 1
} }
function flushFunc { function flushFunc {
$SUDO /opt/pihole/piholeLogFlush.sh ${SUDO} /opt/pihole/piholeLogFlush.sh
exit 1 exit 1
} }
function updateDashboardFunc {
$SUDO /opt/pihole/updateDashboard.sh function updatePiholeFunc {
exit 1
if [ ! -d "/etc/.pihole" ]; then #This is unlikely
echo "::: Critical Error: Pi-Hole repo missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
exit 1;
fi
if [ ! -d "/var/www/html/admin" ]; then #This is unlikely
echo "::: Critical Error: Pi-Hole repo missing from system!"
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
exit 1;
fi
echo "::: Checking for updates..."
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
piholeVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
webVersionLatest=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/releases/latest | grep -Po '"tag_name":.*?[^\\]",' | perl -pe 's/"tag_name": "//; s/^"//; s/",$//')
echo "::: Pi-hole version is $piholeVersion (Latest version is $piholeVersionLatest)"
echo "::: Web Admin version is $webVersion (Latest version is $webVersionLatest)"
echo ":::"
if [[ ${piholeVersion} == ${piholeVersionLatest} ]] ; then
echo "::: Pi-hole Base files are already up to date! Version: ${piholeVersionLatest}"
echo "::: No need to update!"
echo ":::"
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
echo "::: Web Admin files are already up to date!"
echo "::: No need to update!"
echo ":::"
else
echo "::: An Update is available for the Web Admin!"
echo ":::"
echo "::: Fetching latest changes from GitHub..."
cd /var/www/html/admin
${SUDO} git pull origin master
echo ":::"
echo "::: Pi-hole Web Admin has been updated to ${webVersion}"
echo "::: See https://changes.pi-hole.net for details"
fi
else
echo -n "::: An update is available for "
if [[ ${webVersion} == ${webVersionLatest} ]] ; then
echo " Pi-Hole!"
else
echo " Pi-Hole base files and the Web Admin. Both will be updated!"
fi
echo "::: Fetching latest changes from GitHub..."
cd /etc/.pihole
${SUDO} git pull origin master
${SUDO} /etc/.pihole/automated\ install/basic-install.sh pihole
echo ":::"
echo "::: Pi-hole has been updated to version ${piholeVersionLatest}"
if [[ ${webVersion} != ${webVersionLatest} ]] ; then
echo "::: Web Admin has been updated to version ${webVersionLatest}"
fi
echo ":::"
echo "::: See https://changes.pi-hole.net for details"
fi
exit 1
} }
function updateGravityFunc { function updateGravityFunc {
$SUDO /opt/pihole/gravity.sh ${SUDO} /opt/pihole/gravity.sh "$@"
exit 1 exit 1
} }
function setupLCDFunction { function setupLCDFunction {
$SUDO /opt/pihole/setupLCD.sh ${SUDO} /opt/pihole/setupLCD.sh
exit 1 exit 1
}
function queryFunc {
domain=$2
for list in /etc/pihole/list.*
do
count=$(grep ${domain} $list | wc -l)
echo "::: ${list} (${count} results)"
if [[ ${count} > 0 ]]; then
grep ${domain} ${list}
fi
echo ""
done
exit 1
} }
function chronometerFunc { function chronometerFunc {
shift shift
$SUDO /opt/pihole/chronometer.sh "$@" ${SUDO} /opt/pihole/chronometer.sh "$@"
exit 1 exit 1
} }
function uninstallFunc { function uninstallFunc {
$SUDO /opt/pihole/uninstall.sh ${SUDO} /opt/pihole/uninstall.sh
exit 1 exit 1
}
function versionFunc {
${SUDO} /opt/pihole/version.sh
exit 1
} }
function helpFunc { function helpFunc {
echo "::: Control all PiHole specific functions!" echo "::: Control all PiHole specific functions!"
echo ":::" echo ":::"
echo "::: Usage: pihole [options]" echo "::: Usage: pihole [options]"
echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage" echo "::: Add -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -w, whitelist Whitelist domains" echo "::: -w, whitelist Whitelist domains"
echo "::: -b, blacklist Blacklist domains" echo "::: -b, blacklist Blacklist domains"
echo "::: -d, debug Start a debugging session if having trouble" echo "::: -d, debug Start a debugging session if having trouble"
echo "::: -f, flush Flush the pihole.log file" echo "::: -f, flush Flush the pihole.log file"
echo "::: -u, updateDashboard Update the web dashboard manually" echo "::: -up, updatePihole Update Pi-hole"
echo "::: -g, updateGravity Update the list of ad-serving domains" echo "::: -g, updateGravity Update the list of ad-serving domains"
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it" echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -c, chronometer Calculates stats and displays to an LCD"
echo "::: -h, help Show this help dialog" echo "::: -h, help Show this help dialog"
echo "::: uninstall Uninstall Pi-Hole from your system!" echo "::: -v, version Show current versions"
exit 1 echo "::: -q, query Query the adlists for a specific domain"
echo "::: uninstall Uninstall Pi-Hole from your system :(!"
exit 1
} }
if [[ $# = 0 ]]; then if [[ $# = 0 ]]; then
helpFunc helpFunc
fi fi
# Handle redirecting to specific functions based on arguments # Handle redirecting to specific functions based on arguments
@@ -104,11 +189,13 @@ case "$1" in
"-b" | "blacklist" ) blacklistFunc "$@";; "-b" | "blacklist" ) blacklistFunc "$@";;
"-d" | "debug" ) debugFunc;; "-d" | "debug" ) debugFunc;;
"-f" | "flush" ) flushFunc;; "-f" | "flush" ) flushFunc;;
"-u" | "updateDashboard" ) updateDashboardFunc;; "-up" | "updatePihole" ) updatePiholeFunc;;
"-g" | "updateGravity" ) updateGravityFunc;; "-g" | "updateGravity" ) updateGravityFunc "$@";;
"-s" | "setupLCD" ) setupLCDFunction;; "-s" | "setupLCD" ) setupLCDFunction;;
"-c" | "chronometer" ) chronometerFunc "$@";; "-c" | "chronometer" ) chronometerFunc "$@";;
"-h" | "help" ) helpFunc;; "-h" | "help" ) helpFunc;;
"-v" | "version" ) versionFunc;;
"-q" | "query" ) queryFunc "$@";;
"uninstall" ) uninstallFunc;; "uninstall" ) uninstallFunc;;
* ) helpFunc;; * ) helpFunc;;
esac esac