Compare commits
539 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
26fcb1b2a0 | ||
|
e9c4e8123c | ||
|
a290e01bdf | ||
|
9cc392fa02 | ||
|
7c2046cce7 | ||
|
b13171cc45 | ||
|
9c645e2010 | ||
|
bb6f409e89 | ||
|
61ec7723f6 | ||
|
9c136a5579 | ||
|
a5733508ae | ||
|
c8e1e6dc8a | ||
|
30dcf6ff47 | ||
|
3473ebc0fe | ||
|
8c657910ae | ||
|
1886c44579 | ||
|
1dcc1871fb | ||
|
19e688effb | ||
|
6a2b885988 | ||
|
bfc4775b34 | ||
|
981004606b | ||
|
9d40fd1eda | ||
|
fbb6b56d99 | ||
|
f1f70133dc | ||
|
d0f55e5125 | ||
|
5e308dbd51 | ||
|
c3c554f4d6 | ||
|
320c06e0a4 | ||
|
b1484104bd | ||
|
c738a9a044 | ||
|
519cb71022 | ||
|
fcd92d27f7 | ||
|
3eacfa9831 | ||
|
1d64b614c7 | ||
|
a832dd7f67 | ||
|
a96b4d28e1 | ||
|
57e8b7f924 | ||
|
263eb856d5 | ||
|
5a4f088b24 | ||
|
c1913bfa7d | ||
|
474881e4c7 | ||
|
7e0aa822b6 | ||
|
940d780a4c | ||
|
ad9575ce18 | ||
|
ce86205df0 | ||
|
3cf9942465 | ||
|
153031482f | ||
|
1f74b1e2fd | ||
|
42393123a0 | ||
|
af2cff5177 | ||
|
5435b93df2 | ||
|
3a3dde6298 | ||
|
b4bc90fb85 | ||
|
02040cd25d | ||
|
bdc6bd4135 | ||
|
e720de401d | ||
|
ce97896ffd | ||
|
86fa4e9ee8 | ||
|
f09c166350 | ||
|
24868fdb2b | ||
|
a463250ecf | ||
|
d38e034e92 | ||
|
6eb9192cd1 | ||
|
94f15f1b3c | ||
|
ee296f36c1 | ||
|
598a7b3cc0 | ||
|
52baf26d7d | ||
|
fb3e6ee35c | ||
|
af1d1bd9c2 | ||
|
f32ad7699d | ||
|
79294bb6ca | ||
|
1cd4710718 | ||
|
48c19ade8e | ||
|
0acf70f836 | ||
|
fd584dd03b | ||
|
2740c68a63 | ||
|
62a242a894 | ||
|
8b060e9699 | ||
|
b1f769b671 | ||
|
77378da70a | ||
|
160030b75f | ||
|
0a0c3a2fb7 | ||
|
e9f1ca338f | ||
|
073c7e54df | ||
|
2834f2ccc2 | ||
|
6c56665403 | ||
|
0d794226ab | ||
|
ab2af11775 | ||
|
83662c9e50 | ||
|
6c1d52199f | ||
|
cfaf1ac67c | ||
|
a6caa0e680 | ||
|
c4b43f92ce | ||
|
3d1ccd9625 | ||
|
76bd53ef1f | ||
|
8fa209f0df | ||
|
88835512dd | ||
|
6b862dd9e9 | ||
|
be0b76c954 | ||
|
e45559da20 | ||
|
d7b5870ba6 | ||
|
df18c7cd59 | ||
|
2e74219ff9 | ||
|
b0ae954f1e | ||
|
a2404f104a | ||
|
38547ced7a | ||
|
9a9d9007cd | ||
|
bd2d81f691 | ||
|
1b9e7fbf2e | ||
|
d4a49d192f | ||
|
8cb66544d2 | ||
|
140ac192aa | ||
|
b961b13d60 | ||
|
febdb4a190 | ||
|
1d60b62e7a | ||
|
41e1e4cb68 | ||
|
d5b88e0df8 | ||
|
20fd61468d | ||
|
0a0d25dff4 | ||
|
38ba079baa | ||
|
33f7979359 | ||
|
8460b2544b | ||
|
bc514ea955 | ||
|
6f8893d950 | ||
|
de6aaf18ab | ||
|
0fe64cf5cc | ||
|
9a95531fb9 | ||
|
9df6a8dd06 | ||
|
1590a179fa | ||
|
5e16487ef6 | ||
|
2b3afbfef8 | ||
|
c3c7dcc9f5 | ||
|
273728b481 | ||
|
81a1057cac | ||
|
fd310c6445 | ||
|
a9b52518bf | ||
|
87da40068c | ||
|
b8f1eadb7f | ||
|
b522d8eaf6 | ||
|
89ff99322d | ||
|
56e17d1010 | ||
|
708067e875 | ||
|
d2ab0694b7 | ||
|
8a14a63d5d | ||
|
8235b18854 | ||
|
e0e9ebbe74 | ||
|
6e6259975e | ||
|
10bc8414b9 | ||
|
4e25e0dc5c | ||
|
b1a9793d94 | ||
|
6dea00668e | ||
|
ae9182c92e | ||
|
af17355fe7 | ||
|
dce3e50a00 | ||
|
cf31561267 | ||
|
a97f0b1298 | ||
|
d1e0f3ae18 | ||
|
47a6786e8f | ||
|
a69fcbb91e | ||
|
8e2b51b391 | ||
|
560af43204 | ||
|
9c119f919e | ||
|
baefec86f2 | ||
|
eb763d2dc2 | ||
|
512c650441 | ||
|
dc44fc9e27 | ||
|
05640f9a6b | ||
|
6f2fb57c08 | ||
|
2547cc4c8d | ||
|
112ddb3c77 | ||
|
9f4ef66f41 | ||
|
086f0790fc | ||
|
709b44f736 | ||
|
6cd4ff6d68 | ||
|
abd3e828de | ||
|
b85af50d14 | ||
|
0e8fd49669 | ||
|
945e22874e | ||
|
77ab47a984 | ||
|
ed8088f203 | ||
|
8831b22fc8 | ||
|
0341bd1758 | ||
|
9bb4a5fb25 | ||
|
ebfffea5dc | ||
|
81939ab265 | ||
|
f2fe84c9d3 | ||
|
051f463350 | ||
|
f626406685 | ||
|
dd971b6ee5 | ||
|
8776b822db | ||
|
fc76b1a6a3 | ||
|
9183200b6f | ||
|
f1b8abf503 | ||
|
9502356980 | ||
|
a535ca9db4 | ||
|
2c762899de | ||
|
24fd23493d | ||
|
6f1ed28d0a | ||
|
66b7d04b82 | ||
|
044afa838c | ||
|
7ba47f504c | ||
|
0be1717ff4 | ||
|
189a4e0078 | ||
|
3adf8785d8 | ||
|
b74862bfc5 | ||
|
01273124ea | ||
|
721ada7e16 | ||
|
bd9dc91396 | ||
|
de6c43a8d3 | ||
|
93dea7b942 | ||
|
f6fc6a5e56 | ||
|
ca24f7c143 | ||
|
17b0db6515 | ||
|
83b0600863 | ||
|
38961fb31b | ||
|
6c130b7960 | ||
|
7244d44a1d | ||
|
9b060aab34 | ||
|
ba5bbf3523 | ||
|
697b0295f3 | ||
|
66d7ebd6c3 | ||
|
ae24f1255f | ||
|
ec7e75a6e3 | ||
|
aee106ae69 | ||
|
2a881a90ac | ||
|
ce6c465942 | ||
|
3748a0ed33 | ||
|
7a1a2dec67 | ||
|
7ed1bbad49 | ||
|
078cc7660e | ||
|
af2893d2ce | ||
|
0fe5efba76 | ||
|
fb6631d317 | ||
|
cd0b8927c5 | ||
|
3fab34687c | ||
|
b2d78edae9 | ||
|
412cacac49 | ||
|
dcb9797f35 | ||
|
4dcee5cd84 | ||
|
a64211123f | ||
|
1645677c3a | ||
|
4f85ace525 | ||
|
e8fde702a0 | ||
|
e339f3852c | ||
|
032f94afc0 | ||
|
e9b50442fa | ||
|
77b3764481 | ||
|
90ccbef431 | ||
|
02ea9b9abc | ||
|
4cd598ae10 | ||
|
8eeb8ad779 | ||
|
2ffb103acb | ||
|
a0c17368ed | ||
|
d76e761d0b | ||
|
6023984703 | ||
|
cde7b53de3 | ||
|
b36a44a954 | ||
|
fcc3d5450d | ||
|
057cecb3e0 | ||
|
86c6e0e826 | ||
|
5c223b5f4e | ||
|
883aa30aca | ||
|
763b51fe22 | ||
|
dd1aa9163c | ||
|
e087797edc | ||
|
5e6f8489a9 | ||
|
48351fed79 | ||
|
875a5d309d | ||
|
70e876ee13 | ||
|
7a269e757e | ||
|
87edbeaf58 | ||
|
339f95b00c | ||
|
e480c761cd | ||
|
26c628f8a5 | ||
|
59d6907d71 | ||
|
b4450a3918 | ||
|
7032be6049 | ||
|
70a6a79b8c | ||
|
f24f77c5bd | ||
|
66ae79f9b8 | ||
|
378338c684 | ||
|
7da076df18 | ||
|
45fbadbb26 | ||
|
a7def771c8 | ||
|
543f1243e2 | ||
|
a001443ad7 | ||
|
36166c129a | ||
|
4e7a485e23 | ||
|
9e5795bf55 | ||
|
053b38e0bd | ||
|
2aa3a109a0 | ||
|
472708376d | ||
|
cfed3d59e9 | ||
|
95fd9d4863 | ||
|
c89bca6ec8 | ||
|
ee262c30c2 | ||
|
6b8240d4de | ||
|
4035c933df | ||
|
abd44dd284 | ||
|
95d7fe76b5 | ||
|
a052f397fe | ||
|
09d6e73b0a | ||
|
7fb6b71d52 | ||
|
07e37d7fc3 | ||
|
fbe3dc0dcd | ||
|
6018c0c2fc | ||
|
52a2f166fd | ||
|
26cb6a1929 | ||
|
7c63bbfe44 | ||
|
109026222e | ||
|
af8e629df4 | ||
|
f7f1daa69f | ||
|
01f980d49c | ||
|
99fab7e52a | ||
|
692292b1d4 | ||
|
cd608d9d5b | ||
|
ba67144e34 | ||
|
162d9d7d57 | ||
|
357f5a2cfd | ||
|
d1ca32b0a5 | ||
|
34f326c559 | ||
|
7785dac50e | ||
|
01f643e5eb | ||
|
8037f3e332 | ||
|
19e30b829a | ||
|
afe5176e01 | ||
|
a48317883d | ||
|
5ac92ae4eb | ||
|
8fb6ba19a1 | ||
|
314f7e7889 | ||
|
4fcf8fd23f | ||
|
10a30344e5 | ||
|
1206dda347 | ||
|
b764d17c64 | ||
|
ba0abdb88d | ||
|
1428b58dde | ||
|
e57425df5f | ||
|
5e7dfaf220 | ||
|
ad5c011b6c | ||
|
fcdd33b585 | ||
|
f767f066ad | ||
|
b8d0e5e5a1 | ||
|
26ad23f01e | ||
|
21d771e171 | ||
|
66616eb0f0 | ||
|
18eb8a2159 | ||
|
72a1fc3f64 | ||
|
96eea32a9d | ||
|
3239c7023a | ||
|
5333895a9f | ||
|
da05491992 | ||
|
b9f5d79f3d | ||
|
fddc515ee1 | ||
|
3d4516dc95 | ||
|
509c864cc3 | ||
|
8b22f435ad | ||
|
55d39595e1 | ||
|
f8944177a0 | ||
|
3060c4d887 | ||
|
13ee5dc728 | ||
|
06873fe69e | ||
|
a8ac212ee6 | ||
|
3d9d13222b | ||
|
745adabb05 | ||
|
3861b57dc6 | ||
|
99a4a80017 | ||
|
033ba26041 | ||
|
439999cb62 | ||
|
7291aa07ca | ||
|
9181e2652e | ||
|
409f76aa34 | ||
|
54e2c6181a | ||
|
a281d87315 | ||
|
2a5587f236 | ||
|
2d18b2d784 | ||
|
585f842206 | ||
|
8cb4304c13 | ||
|
737819b56e | ||
|
a7130e6530 | ||
|
f9cfed5aff | ||
|
f65a9dbfd2 | ||
|
96c59fada4 | ||
|
153a9d8ac7 | ||
|
297d4eec57 | ||
|
c31b4383e6 | ||
|
0375a3caa3 | ||
|
08cddba200 | ||
|
1bf43b0425 | ||
|
35828f9cea | ||
|
90af12fdb8 | ||
|
dc63182647 | ||
|
5fede23cf7 | ||
|
bc4762f270 | ||
|
01429d59bd | ||
|
731d15f9b5 | ||
|
f0bd7fae5c | ||
|
f8322cc2d4 | ||
|
dfdb9e393b | ||
|
bd07d7f32e | ||
|
f588c6f93c | ||
|
d9ec3d2c22 | ||
|
e2b87759d8 | ||
|
52e0aa11af | ||
|
1421c31179 | ||
|
d5587e32d0 | ||
|
28eb348707 | ||
|
91bcc18e6a | ||
|
5b43f13935 | ||
|
85b3fef08d | ||
|
cc7c48237c | ||
|
15037fa888 | ||
|
d595fef18f | ||
|
be5fa22b6f | ||
|
a5c6bbeee7 | ||
|
094a645e60 | ||
|
51acdfa633 | ||
|
2c16a75ef1 | ||
|
6fd7e0311c | ||
|
1bcf2dd0fc | ||
|
9a3cf949cf | ||
|
cec214f900 | ||
|
dad669d68b | ||
|
561f40d97e | ||
|
dad18dc5de | ||
|
5c95c4074b | ||
|
4301b9a12a | ||
|
0bbe0aed83 | ||
|
b16f797317 | ||
|
4bb71ae046 | ||
|
679b098aa7 | ||
|
e0e88fdb52 | ||
|
8bba3a257c | ||
|
8529c1287f | ||
|
9c7f7756b4 | ||
|
f1cfb16bf9 | ||
|
95796e1978 | ||
|
968b981ecb | ||
|
3aeb378b56 | ||
|
28bafe7427 | ||
|
1317b67657 | ||
|
3f462c771f | ||
|
31aa42c35e | ||
|
f7a17248b7 | ||
|
b60e6310bf | ||
|
6a89c6bf3b | ||
|
b3b7aae7d7 | ||
|
fe8c365d17 | ||
|
9acc3aac01 | ||
|
1ad23a065e | ||
|
de102fde5c | ||
|
77554fbd13 | ||
|
6863bff7c5 | ||
|
eaf6938c35 | ||
|
34ad2157dd | ||
|
0635309f23 | ||
|
2661ef53a2 | ||
|
eddca8f127 | ||
|
cef0211c00 | ||
|
86052540d9 | ||
|
930cb15e2c | ||
|
8bb9dd460b | ||
|
8a3c78ca0a | ||
|
62a5e36afd | ||
|
00b28f0aed | ||
|
7c94aa9f07 | ||
|
ec8c40b69b | ||
|
2981f3cbd1 | ||
|
c2e1819098 | ||
|
58f3ff69d8 | ||
|
72d8d10e64 | ||
|
63d02df0bc | ||
|
f579fd3895 | ||
|
34df34ba27 | ||
|
2689b37c35 | ||
|
9b6427144f | ||
|
9212eea8bd | ||
|
6de5d6dd0a | ||
|
08f08fea61 | ||
|
1ed2a8637f | ||
|
d8bcbdadd6 | ||
|
d196c13f2c | ||
|
7ba251d3a6 | ||
|
0b72c639fb | ||
|
bd1c5a42e8 | ||
|
845d8c0e63 | ||
|
bcb8a52418 | ||
|
322cb2387b | ||
|
bfe56942f9 | ||
|
b4c32e47c6 | ||
|
248d8680f7 | ||
|
1bda965a7c | ||
|
2ee305769d | ||
|
3a8a936575 | ||
|
6b6fbc4709 | ||
|
3fd2ffd466 | ||
|
b56ca2b834 | ||
|
10f77df8bb | ||
|
df7671d393 | ||
|
a263936243 | ||
|
11924d425b | ||
|
0bd5a5f382 | ||
|
757eb64be3 | ||
|
6b3aea933d | ||
|
2935275227 | ||
|
cbe045b946 | ||
|
c58a95ca2e | ||
|
80a3bce6d5 | ||
|
6f0289de49 | ||
|
0966d7660e | ||
|
27e90cc4e6 | ||
|
b785213c3a | ||
|
642a73508d | ||
|
8f7b023769 | ||
|
a122fb2900 | ||
|
a299a2cc5f | ||
|
47196d86ad | ||
|
a713cf7952 | ||
|
6cd7b8ff5e | ||
|
f8264f8277 | ||
|
0e4d5e9103 | ||
|
f599bcfef9 | ||
|
74a4e62cc9 | ||
|
63a414a544 | ||
|
7d1f5091a7 | ||
|
3b54cab3bc | ||
|
52d06d906e | ||
|
d9e949b27c | ||
|
b65fe9d64f | ||
|
168397e90d | ||
|
e3c1fcd2c6 | ||
|
26c6446252 | ||
|
e5e44db5ac | ||
|
cc68155dfa | ||
|
2b778695b1 | ||
|
ebf0db4bbf | ||
|
9ac265980f | ||
|
40798da6b1 | ||
|
3f189ae7fe | ||
|
6b896a1c54 |
38
.editorconfig
Normal file
38
.editorconfig
Normal file
@@ -0,0 +1,38 @@
|
||||
# EditorConfig is awesome: http://EditorConfig.org
|
||||
|
||||
# top-most EditorConfig file
|
||||
root = true
|
||||
|
||||
# Unix-style newlines with a newline ending every file
|
||||
[*]
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = tab
|
||||
tab_width = 2
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# Matches multiple files with brace expansion notation
|
||||
# Set default charset
|
||||
[*.{js,py}]
|
||||
charset = utf-8
|
||||
|
||||
# 4 space indentation
|
||||
[*.py]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
# Tab indentation (no size specified)
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
|
||||
# Indentation override for all JS under lib directory
|
||||
[scripts/**.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
# Matches the exact files either package.json or .travis.yml
|
||||
[{package.json,.travis.yml}]
|
||||
indent_style = space
|
||||
indent_size = 2
|
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -35,4 +35,4 @@ GitHub.Tests.Integration/Resources/* binary
|
||||
|
||||
|
||||
# Catch all for anything we forgot. Add rules if you get CRLF -> LF warnings.
|
||||
* text=auto
|
||||
* text eol=lf
|
||||
|
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@@ -2,7 +2,7 @@
|
||||
|
||||
- [] 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)).
|
||||
- [] The issue I am 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
.gitignore
vendored
1
.gitignore
vendored
@@ -4,4 +4,3 @@
|
||||
__pycache__
|
||||
.cache
|
||||
.pullapprove.yml
|
||||
|
||||
|
42
.idea/codeStyleSettings.xml
generated
42
.idea/codeStyleSettings.xml
generated
@@ -1,25 +1,25 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<option name="OTHER_INDENT_OPTIONS">
|
||||
<value>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</value>
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<option name="OTHER_INDENT_OPTIONS">
|
||||
<value>
|
||||
<option name="INDENT_SIZE" value="2" />
|
||||
<option name="CONTINUATION_INDENT_SIZE" value="8" />
|
||||
<option name="TAB_SIZE" value="2" />
|
||||
<option name="USE_TAB_CHARACTER" value="false" />
|
||||
<option name="SMART_TABS" value="false" />
|
||||
<option name="LABEL_INDENT_SIZE" value="0" />
|
||||
<option name="LABEL_INDENT_ABSOLUTE" value="false" />
|
||||
<option name="USE_RELATIVE_INDENTS" value="false" />
|
||||
</value>
|
||||
</option>
|
||||
<MarkdownNavigatorCodeStyleSettings>
|
||||
<option name="RIGHT_MARGIN" value="72" />
|
||||
</MarkdownNavigatorCodeStyleSettings>
|
||||
</value>
|
||||
</option>
|
||||
<MarkdownNavigatorCodeStyleSettings>
|
||||
<option name="RIGHT_MARGIN" value="72" />
|
||||
</MarkdownNavigatorCodeStyleSettings>
|
||||
</value>
|
||||
</option>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</component>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</component>
|
||||
</project>
|
@@ -1,7 +1,7 @@
|
||||
version: 2
|
||||
|
||||
always_pending:
|
||||
title_regex: '(WIP|wip)'
|
||||
title_regex: '(WIP|wip)'
|
||||
labels:
|
||||
- wip
|
||||
explanation: 'This PR is a work in progress...'
|
||||
@@ -22,17 +22,17 @@ groups:
|
||||
enabled: true
|
||||
conditions:
|
||||
branches:
|
||||
- development
|
||||
- development
|
||||
required: 2
|
||||
teams:
|
||||
- approvers
|
||||
|
||||
|
||||
master:
|
||||
approve_by_comment:
|
||||
enabled: true
|
||||
conditions:
|
||||
branches:
|
||||
- master
|
||||
required: -1
|
||||
required: 4
|
||||
teams:
|
||||
- admin
|
||||
|
@@ -35,4 +35,5 @@ When requesting or submitting new features, first consider whether it might be u
|
||||
- Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
||||
- Please use the [Google Style Guide for Shell](https://google.github.io/styleguide/shell.xml) for your code submission styles.
|
||||
- Commit Unix line endings.
|
||||
- Please use the Pi-hole brand: **Pi-hole** (Take a special look at the capitalized 'P' and a low 'h' with a hyphen)
|
||||
- (Optional fun) keep to the theme of Star Trek/black holes/gravity.
|
||||
|
390
LICENSE
390
LICENSE
@@ -1,339 +1,167 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
Copyright (C) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
Pi-hole Core
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
This software is licensed under the European Union Public License (EUPL)
|
||||
The license is available in the 22 official languages of the EU. The English version is included here.
|
||||
Please see https://joinup.ec.europa.eu/community/eupl/og_page/eupl for official translations of the other languages.
|
||||
|
||||
Preamble
|
||||
This license applies to the whole project EXCEPT:
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
License is intended to guarantee your freedom to share and change free
|
||||
software--to make sure the software is free for all its users. This
|
||||
General Public License applies to most of the Free Software
|
||||
Foundation's software and to any other program whose authors commit to
|
||||
using it. (Some other Free Software Foundation software is covered by
|
||||
the GNU Lesser General Public License instead.) You can apply it to
|
||||
your programs, too.
|
||||
- any commits made to the master branch prior to the release of version 3.0
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
this service if you wish), that you receive source code or can get it
|
||||
if you want it, that you can change the software or use pieces of it
|
||||
in new free programs; and that you know you can do these things.
|
||||
The licenses that existed prior to this change have remained intact.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
anyone to deny you these rights or to ask you to surrender the rights.
|
||||
These restrictions translate to certain responsibilities for you if you
|
||||
distribute copies of the software, or if you modify it.
|
||||
-------------------------------------------------------------
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must give the recipients all the rights that
|
||||
you have. You must make sure that they, too, receive or can get the
|
||||
source code. And you must show them these terms so they know their
|
||||
rights.
|
||||
European Union Public Licence
|
||||
V. 1.1
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and
|
||||
(2) offer you this license which gives you legal permission to copy,
|
||||
distribute and/or modify the software.
|
||||
EUPL (C) the European Community 2007
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain
|
||||
that everyone understands that there is no warranty for this free
|
||||
software. If the software is modified by someone else and passed on, we
|
||||
want its recipients to know that what they have is not the original, so
|
||||
that any problems introduced by others will not reflect on the original
|
||||
authors' reputations.
|
||||
This European Union Public Licence (the "EUPL") applies to the Work or Software (as defined below) which is provided under the terms of this Licence. Any use of the Work, other than as authorised under this Licence is prohibited (to the extent such use is covered by a right of the copyright holder of the Work).
|
||||
|
||||
Finally, any free program is threatened constantly by software
|
||||
patents. We wish to avoid the danger that redistributors of a free
|
||||
program will individually obtain patent licenses, in effect making the
|
||||
program proprietary. To prevent this, we have made it clear that any
|
||||
patent must be licensed for everyone's free use or not licensed at all.
|
||||
The Original Work is provided under the terms of this Licence when the Licensor (as defined below) has placed the following notice immediately following the copyright notice for the Original Work:
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
Licensed under the EUPL V.1.1
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
or has expressed by any other mean his willingness to license under the EUPL.
|
||||
|
||||
0. This License applies to any program or other work which contains
|
||||
a notice placed by the copyright holder saying it may be distributed
|
||||
under the terms of this General Public License. The "Program", below,
|
||||
refers to any such program or work, and a "work based on the Program"
|
||||
means either the Program or any derivative work under copyright law:
|
||||
that is to say, a work containing the Program or a portion of it,
|
||||
either verbatim or with modifications and/or translated into another
|
||||
language. (Hereinafter, translation is included without limitation in
|
||||
the term "modification".) Each licensee is addressed as "you".
|
||||
1. Definitions
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running the Program is not restricted, and the output from the Program
|
||||
is covered only if its contents constitute a work based on the
|
||||
Program (independent of having been made by running the Program).
|
||||
Whether that is true depends on what the Program does.
|
||||
In this Licence, the following terms have the following meaning:
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's
|
||||
source code as you receive it, in any medium, provided that you
|
||||
conspicuously and appropriately publish on each copy an appropriate
|
||||
copyright notice and disclaimer of warranty; keep intact all the
|
||||
notices that refer to this License and to the absence of any warranty;
|
||||
and give any other recipients of the Program a copy of this License
|
||||
along with the Program.
|
||||
- The Licence: this Licence.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and
|
||||
you may at your option offer warranty protection in exchange for a fee.
|
||||
- The Original Work or the Software: the software distributed and/or communicated by the Licensor under this Licence, available as Source Code and also as Executable Code as the case may be.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion
|
||||
of it, thus forming a work based on the Program, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
- Derivative Works: the works or software that could be created by the Licensee, based upon the Original Work or modifications thereof. This Licence does not define the extent of modification or dependence on the Original Work required in order to classify a work as a Derivative Work; this extent is determined by copyright law applicable in the country mentioned in Article 15.
|
||||
|
||||
a) You must cause the modified files to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
- The Work: the Original Work and/or its Derivative Works.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in
|
||||
whole or in part contains or is derived from the Program or any
|
||||
part thereof, to be licensed as a whole at no charge to all third
|
||||
parties under the terms of this License.
|
||||
- The Source Code: the human-readable form of the Work which is the most convenient for people to study and modify.
|
||||
|
||||
c) If the modified program normally reads commands interactively
|
||||
when run, you must cause it, when started running for such
|
||||
interactive use in the most ordinary way, to print or display an
|
||||
announcement including an appropriate copyright notice and a
|
||||
notice that there is no warranty (or else, saying that you provide
|
||||
a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this
|
||||
License. (Exception: if the Program itself is interactive but
|
||||
does not normally print such an announcement, your work based on
|
||||
the Program is not required to print an announcement.)
|
||||
- The Executable Code: any code which has generally been compiled and which is meant to be interpreted by a computer as a program.
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Program,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Program, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote it.
|
||||
- The Licensor: the natural or legal person that distributes and/or communicates the Work under the Licence.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Program.
|
||||
- Contributor(s): any natural or legal person who modifies the Work under the Licence, or otherwise contributes to the creation of a Derivative Work.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
- The Licensee or "You": any natural or legal person who makes any usage of the Software under the terms of the Licence.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it,
|
||||
under Section 2) in object code or executable form under the terms of
|
||||
Sections 1 and 2 above provided that you also do one of the following:
|
||||
- Distribution and/or Communication: any act of selling, giving, lending, renting, distributing, communicating, transmitting, or otherwise making available, on-line or off-line, copies of the Work or providing access to its essential functionalities at the disposal of any other natural or legal person.
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable
|
||||
source code, which must be distributed under the terms of Sections
|
||||
1 and 2 above on a medium customarily used for software interchange; or,
|
||||
2. Scope of the rights granted by the Licence
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three
|
||||
years, to give any third party, for a charge no more than your
|
||||
cost of physically performing source distribution, a complete
|
||||
machine-readable copy of the corresponding source code, to be
|
||||
distributed under the terms of Sections 1 and 2 above on a medium
|
||||
customarily used for software interchange; or,
|
||||
The Licensor hereby grants You a world-wide, royalty-free, non-exclusive, sub-licensable licence to do the following, for the duration of copyright vested in the Original Work:
|
||||
|
||||
c) Accompany it with the information you received as to the offer
|
||||
to distribute corresponding source code. (This alternative is
|
||||
allowed only for noncommercial distribution and only if you
|
||||
received the program in object code or executable form with such
|
||||
an offer, in accord with Subsection b above.)
|
||||
- use the Work in any circumstance and for all usage,
|
||||
- reproduce the Work,
|
||||
- modify the Original Work, and make Derivative Works based upon the Work,
|
||||
- communicate to the public, including the right to make available or display the Work or copies thereof to the public and perform publicly, as the case may be, the Work,
|
||||
- distribute the Work or copies thereof,
|
||||
- lend and rent the Work or copies thereof,
|
||||
- sub-license rights in the Work or copies thereof.
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source
|
||||
code means all the source code for all modules it contains, plus any
|
||||
associated interface definition files, plus the scripts used to
|
||||
control compilation and installation of the executable. However, as a
|
||||
special exception, the source code distributed need not include
|
||||
anything that is normally distributed (in either source or binary
|
||||
form) with the major components (compiler, kernel, and so on) of the
|
||||
operating system on which the executable runs, unless that component
|
||||
itself accompanies the executable.
|
||||
Those rights can be exercised on any media, supports and formats, whether now known or later invented, as far as the applicable law permits so.
|
||||
|
||||
If distribution of executable or object code is made by offering
|
||||
access to copy from a designated place, then offering equivalent
|
||||
access to copy the source code from the same place counts as
|
||||
distribution of the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
In the countries where moral rights apply, the Licensor waives his right to exercise his moral right to the extent allowed by law in order to make effective the licence of the economic rights here above listed.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense or distribute the Program is
|
||||
void, and will automatically terminate your rights under this License.
|
||||
However, parties who have received copies, or rights, from you under
|
||||
this License will not have their licenses terminated so long as such
|
||||
parties remain in full compliance.
|
||||
The Licensor grants to the Licensee royalty-free, non exclusive usage rights to any patents held by the Licensor, to the extent necessary to make use of the rights granted on the Work under this Licence.
|
||||
|
||||
5. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Program or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Program (or any work based on the
|
||||
Program), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Program or works based on it.
|
||||
3. Communication of the Source Code
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute or modify the Program subject to
|
||||
these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties to
|
||||
this License.
|
||||
The Licensor may provide the Work either in its Source Code form, or as Executable Code. If the Work is provided as Executable Code, the Licensor provides in addition a machine-readable copy of the Source Code of the Work along with each copy of the Work that the Licensor distributes or indicates, in a notice following the copyright notice attached to the Work, a repository where the Source Code is easily and freely accessible for as long as the Licensor continues to distribute and/or communicate the Work.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Program at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Program by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
4. Limitations on copyright
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under
|
||||
any particular circumstance, the balance of the section is intended to
|
||||
apply and the section as a whole is intended to apply in other
|
||||
circumstances.
|
||||
Nothing in this Licence is intended to deprive the Licensee of the benefits from any exception or limitation to the exclusive rights of the rights owners in the Original Work or Software, of the exhaustion of those rights or of other applicable limitations thereto.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system, which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
5. Obligations of the Licensee
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
The grant of the rights mentioned above is subject to some restrictions and obligations imposed on the Licensee. Those obligations are the following:
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Program under this License
|
||||
may add an explicit geographical distribution limitation excluding
|
||||
those countries, so that distribution is permitted only in or among
|
||||
countries not thus excluded. In such case, this License incorporates
|
||||
the limitation as if written in the body of this License.
|
||||
Attribution right: the Licensee shall keep intact all copyright, patent or trademarks notices and all notices that refer to the Licence and to the disclaimer of warranties. The Licensee must include a copy of such notices and a copy of the Licence with every copy of the Work he/she distributes and/or communicates. The Licensee must cause any Derivative Work to carry prominent notices stating that the Work has been modified and the date of modification.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
Copyleft clause: If the Licensee distributes and/or communicates copies of the Original Works or Derivative Works based upon the Original Work, this Distribution and/or Communication will be done under the terms of this Licence or of a later version of this Licence unless the Original Work is expressly distributed only under this version of the Licence. The Licensee (becoming Licensor) cannot offer or impose any additional terms or conditions on the Work or Derivative Work that alter or restrict the terms of the Licence.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program
|
||||
specifies a version number of this License which applies to it and "any
|
||||
later version", you have the option of following the terms and conditions
|
||||
either of that version or of any later version published by the Free
|
||||
Software Foundation. If the Program does not specify a version number of
|
||||
this License, you may choose any version ever published by the Free Software
|
||||
Foundation.
|
||||
Compatibility clause: If the Licensee Distributes and/or Communicates Derivative Works or copies thereof based upon both the Original Work and another work licensed under a Compatible Licence, this Distribution and/or Communication can be done under the terms of this Compatible Licence. For the sake of this clause, "Compatible Licence" refers to the licences listed in the appendix attached to this Licence. Should the Licensee’s obligations under the Compatible Licence conflict with his/her obligations under this Licence, the obligations of the Compatible Licence shall prevail.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free
|
||||
programs whose distribution conditions are different, write to the author
|
||||
to ask for permission. For software which is copyrighted by the Free
|
||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
||||
make exceptions for this. Our decision will be guided by the two goals
|
||||
of preserving the free status of all derivatives of our free software and
|
||||
of promoting the sharing and reuse of software generally.
|
||||
Provision of Source Code: When distributing and/or communicating copies of the Work, the Licensee will provide a machine-readable copy of the Source Code or indicate a repository where this Source will be easily and freely available for as long as the Licensee continues to distribute and/or communicate the Work.
|
||||
|
||||
NO WARRANTY
|
||||
Legal Protection: This Licence does not grant permission to use the trade names, trademarks, service marks, or names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the copyright notice.
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
||||
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
||||
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
||||
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
||||
REPAIR OR CORRECTION.
|
||||
6. Chain of Authorship
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGES.
|
||||
The original Licensor warrants that the copyright in the Original Work granted hereunder is owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
Each Contributor warrants that the copyright in the modifications he/she brings to the Work are owned by him/her or licensed to him/her and that he/she has the power and authority to grant the Licence.
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
Each time You accept the Licence, the original Licensor and subsequent Contributors grant You a licence to their contributions to the Work, under the terms of this Licence.
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
7. Disclaimer of Warranty
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
The Work is a work in progress, which is continuously improved by numerous contributors. It is not a finished work and may therefore contain defects or "bugs" inherent to this type of software development.
|
||||
|
||||
{description}
|
||||
Copyright (C) {year} {fullname}
|
||||
For the above reason, the Work is provided under the Licence on an "as is" basis and without warranties of any kind concerning the Work, including without limitation merchantability, fitness for a particular purpose, absence of defects or errors, accuracy, non-infringement of intellectual property rights other than copyright as stated in Article 6 of this Licence.
|
||||
|
||||
This program 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.
|
||||
This disclaimer of warranty is an essential part of the Licence and a condition for the grant of any rights to the Work.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
8. Disclaimer of Liability
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
Except in the cases of wilful misconduct or damages directly caused to natural persons, the Licensor will in no event be liable for any direct or indirect, material or moral, damages of any kind, arising out of the Licence or of the use of the Work, including without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, loss of data or any commercial damage, even if the Licensor has been advised of the possibility of such damage. However, the Licensor will be liable under statutory product liability laws as far such laws apply to the Work.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
9. Additional agreements
|
||||
|
||||
If the program is interactive, make it output a short notice like this
|
||||
when it starts in an interactive mode:
|
||||
While distributing the Original Work or Derivative Works, You may choose to conclude an additional agreement to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or services consistent with this Licence. However, in accepting such obligations, You may act only on your own behalf and on your sole responsibility, not on behalf of the original Licensor or any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against such Contributor by the fact You have accepted any such warranty or additional liability.
|
||||
|
||||
Gnomovision version 69, Copyright (C) year name of author
|
||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
10. Acceptance of the Licence
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, the commands you use may
|
||||
be called something other than `show w' and `show c'; they could even be
|
||||
mouse-clicks or menu items--whatever suits your program.
|
||||
The provisions of this Licence can be accepted by clicking on an icon "I agree" placed under the bottom of a window displaying the text of this Licence or by affirming consent in any other similar way, in accordance with the rules of applicable law. Clicking on that icon indicates your clear and irrevocable acceptance of this Licence and all of its terms and conditions.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the program, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
Similarly, you irrevocably accept this Licence and all of its terms and conditions by exercising any rights granted to You by Article 2 of this Licence, such as the use of the Work, the creation by You of a Derivative Work or the Distribution and/or Communication by You of the Work or copies thereof.
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
||||
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
||||
11. Information to the public
|
||||
|
||||
{signature of Ty Coon}, 1 April 1989
|
||||
Ty Coon, President of Vice
|
||||
In case of any Distribution and/or Communication of the Work by means of electronic communication by You (for example, by offering to download the Work from a remote location) the distribution channel or media (for example, a website) must at least provide to the public the information requested by the applicable law regarding the Licensor, the Licence and the way it may be accessible, concluded, stored and reproduced by the Licensee.
|
||||
|
||||
This General Public License does not permit incorporating your program into
|
||||
proprietary programs. If your program is a subroutine library, you may
|
||||
consider it more useful to permit linking proprietary applications with the
|
||||
library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License.
|
||||
12. Termination of the Licence
|
||||
|
||||
The Licence and the rights granted hereunder will terminate automatically upon any breach by the Licensee of the terms of the Licence.
|
||||
|
||||
Such a termination will not terminate the licences of any person who has received the Work from the Licensee under the Licence, provided such persons remain in full compliance with the Licence.
|
||||
|
||||
13. Miscellaneous
|
||||
|
||||
Without prejudice of Article 9 above, the Licence represents the complete agreement between the Parties as to the Work licensed hereunder.
|
||||
|
||||
If any provision of the Licence is invalid or unenforceable under applicable law, this will not affect the validity or enforceability of the Licence as a whole. Such provision will be construed and/or reformed so as necessary to make it valid and enforceable.
|
||||
|
||||
The European Commission may publish other linguistic versions and/or new versions of this Licence, so far this is required and reasonable, without reducing the scope of the rights granted by the Licence. New versions of the Licence will be published with a unique version number.
|
||||
|
||||
All linguistic versions of this Licence, approved by the European Commission, have identical value. Parties can take advantage of the linguistic version of their choice.
|
||||
|
||||
14. Jurisdiction
|
||||
|
||||
Any litigation resulting from the interpretation of this License, arising between the European Commission, as a Licensor, and any Licensee, will be subject to the jurisdiction of the Court of Justice of the European Communities, as laid down in article 238 of the Treaty establishing the European Community.
|
||||
|
||||
Any litigation arising between Parties, other than the European Commission, and resulting from the interpretation of this License, will be subject to the exclusive jurisdiction of the competent court where the Licensor resides or conducts its primary business.
|
||||
|
||||
15. Applicable Law
|
||||
|
||||
This Licence shall be governed by the law of the European Union country where the Licensor resides or has his registered office.
|
||||
|
||||
This licence shall be governed by the Belgian law if:
|
||||
|
||||
- a litigation arises between the European Commission, as a Licensor, and any Licensee;
|
||||
- the Licensor, other than the European Commission, has no residence or registered office inside a European Union country.
|
||||
|
||||
|
||||
===
|
||||
Appendix
|
||||
|
||||
"Compatible Licences" according to article 5 EUPL are:
|
||||
- GNU General Public License (GNU GPL) v. 2
|
||||
- Open Software License (OSL) v. 2.1, v. 3.0
|
||||
- Common Public License v. 1.0
|
||||
- Eclipse Public License v. 1.0
|
||||
- Cecill v. 2.0
|
||||
|
54
README.md
54
README.md
@@ -5,12 +5,12 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href=https://discourse.pi-hole.net><img src="https://assets.pi-hole.net/static/Vortex_text.png" width=210></a>
|
||||
<a href=https://discourse.pi-hole.net><img src="https://assets.pi-hole.net/static/Vortex_with_text_and_TM.png" width=210></a>
|
||||
</p>
|
||||
|
||||
## The multi-platform, network-wide ad blocker
|
||||
|
||||
Block ads for **all** your devices _without_ the need to install client-side software. The Pi-hole blocks ads at the DNS-level, so all your devices are protected.
|
||||
Block ads for **all** your devices _without_ the need to install client-side software. The Pi-hole™ blocks ads at the DNS-level, so all your devices are protected.
|
||||
|
||||
- Web Browsers
|
||||
- Cell Phones
|
||||
@@ -42,7 +42,7 @@ _If you wish to read over the script before running it, run `nano basic-install.
|
||||
|
||||
```
|
||||
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
|
||||
cd Pi-hole/automated_installer/
|
||||
cd Pi-hole/automated\ install/
|
||||
bash basic-install.sh
|
||||
```
|
||||
|
||||
@@ -53,19 +53,13 @@ wget -O basic-install.sh https://install.pi-hole.net
|
||||
bash basic-install.sh
|
||||
```
|
||||
|
||||
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245) 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**](https://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245) 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 Pi-hole™ as their DNS server.
|
||||
|
||||
## Installing the Pi-hole (Click to Watch!)
|
||||
## What is Pi-hole™ and how do I install it?
|
||||
<p align="center">
|
||||
<a href=https://www.youtube.com/watch?v=TzFLJqUeirA><img src="https://assets.pi-hole.net/static/global.png"></a>
|
||||
<a href=https://www.youtube.com/watch?v=vKWjx1AQYgs><img src="https://assets.pi-hole.net/static/video-explainer.png"></a>
|
||||
</p>
|
||||
|
||||
## Would you like to know more?
|
||||
|
||||
**Watch the 60-second video below to get a quick overview**
|
||||
<p align="center">
|
||||
<a href=https://youtu.be/9Eti3xibiho><img src="https://assets.pi-hole.net/static/blackhole_web.png"></a>
|
||||
</p>
|
||||
|
||||
## Get Help Or Connect With Us On The Web
|
||||
|
||||
@@ -79,7 +73,7 @@ Once installed, [configure your router to have **DHCP clients use the Pi as thei
|
||||
|
||||
## 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.
|
||||
|
||||
### Gravity
|
||||
|
||||
@@ -89,7 +83,7 @@ The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does
|
||||
|
||||
#### Other Operating Systems
|
||||
|
||||
The automated install is only for a clean install of a Debian family or Fedora based system, such as the Raspberry Pi. However, this script will work for most UNIX-like systems, some with some slight **modifications** that we can help you work through. If you can install `dnsmasq` and a Webserver, it should work OK. If there are other platforms you'd like supported, let us know.
|
||||
The automated install is only for a clean install of a Debian family or Fedora based system, such as the Raspberry Pi. However, this script will work for most UNIX-like systems, some with some slight **modifications** that we can help you work through. If you can install `dnsmasq` and a web server, it should work OK. If there are other platforms you'd like supported, let us know.
|
||||
|
||||
### Web Interface
|
||||
|
||||
@@ -97,13 +91,31 @@ The [Web interface](https://github.com/pi-hole/AdminLTE#pi-hole-admin-dashboard)
|
||||
|
||||
`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin`
|
||||
|
||||

|
||||

|
||||
|
||||
### Whitelist and blacklist
|
||||
|
||||
Domains can be whitelisted and blacklisted using either the web interface or the command line. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
||||
<p align="center">
|
||||
<a href=https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting><img src="https://assets.pi-hole.net/static/controlpanel.png"></a>
|
||||
<a href=https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting><img src="https://assets.pi-hole.net/static/whitelist212.png"></a>
|
||||
</p>
|
||||
|
||||
### Settings
|
||||
|
||||
The settings page lets you control and configure your Pi-hole™. You can do things like:
|
||||
|
||||
- enable Pi-hole's built-in DHCP server
|
||||
- exclude domains from the graphs
|
||||
- configure upstream DNS servers
|
||||
- and more!
|
||||
|
||||

|
||||
|
||||
#### Built-in DHCP Server
|
||||
|
||||
Pi-hole™ ships with a built-in DHCP server. This allows you to let your network devices use Pi-hole™ as their DNS server if your router does not let you adjust the DHCP options.
|
||||
<p align="center">
|
||||
<a href=hhttps://discourse.pi-hole.net/t/how-do-i-configure-my-devices-to-use-pi-hole-as-their-dns-server/245><img src="https://assets.pi-hole.net/static/piholedhcpserver.png"></a>
|
||||
</p>
|
||||
|
||||
## API
|
||||
@@ -123,15 +135,16 @@ The same output can be achieved on the CLI by running `chronometer.sh -j`
|
||||
|
||||
## 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](https://discourse.pi-hole.net/t/how-do-i-view-my-pi-holes-stats-over-ssh-or-on-an-lcd-using-chronometer/240) 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 Projects
|
||||
## Pi-hole™ Projects
|
||||
|
||||
- [An ad blocking Magic Mirror](https://zonksec.com/blog/magic-mirror-dns-filtering/#dnssoftware)
|
||||
- [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://thetimmy.silvernight.org/pages/endisbutton/)
|
||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||
- [Docker Pi-hole container (x86 and ARM)](https://hub.docker.com/r/diginc/pi-hole/)
|
||||
- [Splunk: Pi-hole Visualizser](https://splunkbase.splunk.com/app/3023/)
|
||||
- [Splunk: Pi-hole Visualiser](https://splunkbase.splunk.com/app/3023/)
|
||||
- [Pi-hole Chrome extension](https://chrome.google.com/webstore/detail/pi-hole-list-editor/hlnoeoejkllgkjbnnnhfolapllcnaglh) ([open source](https://github.com/packtloss/pihole-extension))
|
||||
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
||||
- [Sky-Hole](http://dlaa.me/blog/post/skyhole)
|
||||
@@ -141,7 +154,8 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd-
|
||||
- [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)
|
||||
- [Let your blink1 device blink when Pi-hole filters ads](https://gist.github.com/elpatron68/ec0b4c582e5abf604885ac1e068d233f)
|
||||
- [Pi-Hole Prometheus exporter](https://github.com/nlamirault/pihole_exporter) : a [Prometheus](https://prometheus.io/) exporter for Pi-Hole
|
||||
- [Pi-hole Prometheus exporter](https://github.com/nlamirault/pihole_exporter): a [Prometheus](https://prometheus.io/) exporter for Pi-hole
|
||||
- [Pi-hole Droid - open source Android client](https://github.com/friimaind/pi-hole-droid)
|
||||
|
||||
## Coverage
|
||||
|
||||
|
@@ -1,53 +1,23 @@
|
||||
## Pi-hole ad-list default sources. Updated 29/10/2016 #########################
|
||||
# #
|
||||
# To make changes to this file: #
|
||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||
# 2. run `nano /etc/pihole/adlists.list` #
|
||||
# 3. Uncomment or comment any of the below lists #
|
||||
# #
|
||||
# Know of any other lists? Feel free to let us know about them, or add them #
|
||||
# to this file! #
|
||||
################################################################################
|
||||
|
||||
# The below list amalgamates several lists we used previously.
|
||||
# See `https://github.com/StevenBlack/hosts` for details
|
||||
##StevenBlack's list
|
||||
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||
|
||||
# Other lists we consider safe:
|
||||
http://mirror1.malwaredomains.com/files/justdomains
|
||||
##MalwareDomains
|
||||
https://mirror1.malwaredomains.com/files/justdomains
|
||||
|
||||
##Cameleon
|
||||
http://sysctl.org/cameleon/hosts
|
||||
|
||||
##Zeustracker
|
||||
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
||||
|
||||
##Disconnect.me Tracking
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
||||
|
||||
##Disconnect.me Ads
|
||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
||||
|
||||
# hosts-file.net list. Updated frequently, but has been known to block legitimate sites.
|
||||
##Hosts-file.net
|
||||
https://hosts-file.net/ad_servers.txt
|
||||
|
||||
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
||||
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
||||
#http://adblock.mahakala.is/
|
||||
|
||||
# ADZHOSTS list. Has been known to block legitimate domains
|
||||
#http://pilotfiber.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||
|
||||
# Windows 10 telemetry list
|
||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
||||
|
||||
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||
#http://securemecca.com/Downloads/hosts.txt
|
||||
|
||||
# Quidsup's tracker list
|
||||
#https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
||||
|
||||
# Block the BBC News website Breaking News banner
|
||||
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
||||
|
||||
# Untested Lists:
|
||||
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||
#https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt
|
||||
#http://malwaredomains.lehigh.edu/files/domains.txt
|
||||
# Following two lists should be used simultaneously: (readme https://github.com/notracking/hosts-blocklists/)
|
||||
#https://raw.github.com/notracking/hosts-blocklists/master/hostnames.txt
|
||||
#https://raw.github.com/notracking/hosts-blocklists/master/domains.txt
|
||||
# Combination of serveral host files on the internet (warning some facebook domains are also blocked but you can go to facebook.com). See https://github.com/mat1th/Dns-add-block for more information.
|
||||
#https://raw.githubusercontent.com/mat1th/Dns-add-block/master/hosts
|
||||
|
@@ -25,6 +25,8 @@ addn-hosts=/etc/pihole/local.list
|
||||
|
||||
domain-needed
|
||||
|
||||
localise-queries
|
||||
|
||||
bogus-priv
|
||||
|
||||
no-resolv
|
||||
|
@@ -1,15 +1,12 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Calculates stats and displays to an LCD
|
||||
#
|
||||
# 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.
|
||||
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
#Functions##############################################################################################################
|
||||
piLog="/var/log/pihole.log"
|
||||
@@ -17,60 +14,49 @@ gravity="/etc/pihole/gravity.list"
|
||||
|
||||
. /etc/pihole/setupVars.conf
|
||||
|
||||
CalcBlockedDomains() {
|
||||
if [ -e "${gravity}" ]; then
|
||||
# if BOTH IPV4 and IPV6 are in use, then we need to divide total domains by 2.
|
||||
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]]; then
|
||||
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
|
||||
else
|
||||
# only one is set.
|
||||
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1}')
|
||||
fi
|
||||
else
|
||||
blockedDomainsTotal="Err."
|
||||
fi
|
||||
}
|
||||
function GetFTLData {
|
||||
# Open connection to FTL
|
||||
exec 3<>/dev/tcp/localhost/"$(cat /var/run/pihole-FTL.port)"
|
||||
|
||||
CalcQueriesToday() {
|
||||
if [ -e "${piLog}" ]; then
|
||||
queriesToday=$(awk '/query\[/ {print $6}' < "${piLog}" | wc -l)
|
||||
else
|
||||
queriesToday="Err."
|
||||
fi
|
||||
}
|
||||
# Test if connection is open
|
||||
if { >&3; } 2> /dev/null; then
|
||||
# Send command to FTL
|
||||
echo -e ">$1" >&3
|
||||
|
||||
CalcblockedToday() {
|
||||
if [ -e "${piLog}" ] && [ -e "${gravity}" ];then
|
||||
blockedToday=$(awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' < "${piLog}" | wc -l)
|
||||
else
|
||||
blockedToday="Err."
|
||||
fi
|
||||
}
|
||||
# Read input
|
||||
read -r -t 1 LINE <&3
|
||||
until [ ! $? ] || [[ "$LINE" == *"EOM"* ]]; do
|
||||
echo "$LINE" >&1
|
||||
read -r -t 1 LINE <&3
|
||||
done
|
||||
|
||||
CalcPercentBlockedToday() {
|
||||
if [ "${queriesToday}" != "Err." ] && [ "${blockedToday}" != "Err." ]; then
|
||||
if [ "${queriesToday}" != 0 ]; then #Fixes divide by zero error :)
|
||||
#scale 2 rounds the number down, so we'll do scale 4 and then trim the last 2 zeros
|
||||
percentBlockedToday=$(echo "scale=4; ${blockedToday}/${queriesToday}*100" | bc)
|
||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "${percentBlockedToday}")
|
||||
else
|
||||
percentBlockedToday=0
|
||||
fi
|
||||
fi
|
||||
# Close connection
|
||||
exec 3>&-
|
||||
exec 3<&-
|
||||
fi
|
||||
}
|
||||
|
||||
outputJSON() {
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
get_summary_data
|
||||
echo "{\"domains_being_blocked\":${domains_being_blocked_raw},\"dns_queries_today\":${dns_queries_today_raw},\"ads_blocked_today\":${ads_blocked_today_raw},\"ads_percentage_today\":${ads_percentage_today_raw}}"
|
||||
}
|
||||
|
||||
CalcBlockedDomains
|
||||
|
||||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||
get_summary_data() {
|
||||
local summary=$(GetFTLData "stats")
|
||||
domains_being_blocked_raw=$(grep "domains_being_blocked" <<< "${summary}" | grep -Eo "[0-9]+$")
|
||||
domains_being_blocked=$(printf "%'.f" ${domains_being_blocked_raw})
|
||||
dns_queries_today_raw=$(grep "dns_queries_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
dns_queries_today=$(printf "%'.f" ${dns_queries_today_raw})
|
||||
ads_blocked_today_raw=$(grep "ads_blocked_today" <<< "$summary" | grep -Eo "[0-9]+$")
|
||||
ads_blocked_today=$(printf "%'.f" ${ads_blocked_today_raw})
|
||||
ads_percentage_today_raw=$(grep "ads_percentage_today" <<< "$summary" | grep -Eo "[0-9.]+$")
|
||||
LC_NUMERIC=C ads_percentage_today=$(printf "%'.f" ${ads_percentage_today_raw})
|
||||
}
|
||||
|
||||
normalChrono() {
|
||||
for (( ; ; )); do
|
||||
get_summary_data
|
||||
domain=$(GetFTLData recentBlocked)
|
||||
clear
|
||||
# Displays a colorful Pi-hole logo
|
||||
echo " [0;1;35;95m_[0;1;31;91m__[0m [0;1;33;93m_[0m [0;1;34;94m_[0m [0;1;36;96m_[0m"
|
||||
@@ -84,25 +70,12 @@ normalChrono() {
|
||||
#uptime -p #Doesn't work on all versions of uptime
|
||||
uptime | awk -F'( |,|:)+' '{if ($7=="min") m=$6; else {if ($7~/^day/) {d=$6;h=$8;m=$9} else {h=$6;m=$7}}} {print d+0,"days,",h+0,"hours,",m+0,"minutes."}'
|
||||
echo "-------------------------------"
|
||||
# Uncomment to continually read the log file and display the current domain being blocked
|
||||
#tail -f /var/log/pihole.log | awk '/\/etc\/pihole\/gravity.list/ {if ($7 != "address" && $7 != "name" && $7 != "/etc/pihole/gravity.list") print $7; else;}'
|
||||
echo "Recently blocked:"
|
||||
echo " $domain"
|
||||
|
||||
#uncomment next 4 lines to use original query count calculation
|
||||
#today=$(date "+%b %e")
|
||||
#todaysQueryCount=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ {print $7}' | wc -l)
|
||||
#todaysQueryCountV4=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[A\]/ {print $7}' | wc -l)
|
||||
#todaysQueryCountV6=$(cat /var/log/pihole.log | grep "$today" | awk '/query/ && /\[AAAA\]/ {print $7}' | wc -l)
|
||||
|
||||
|
||||
CalcQueriesToday
|
||||
CalcblockedToday
|
||||
CalcPercentBlockedToday
|
||||
|
||||
CalcBlockedDomains
|
||||
|
||||
echo "Blocking: ${blockedDomainsTotal}"
|
||||
echo "Queries: ${queriesToday}" #same total calculation as dashboard
|
||||
echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)"
|
||||
echo "Blocking: ${domains_being_blocked}"
|
||||
echo "Queries: ${dns_queries_today}"
|
||||
echo "Pi-holed: ${ads_blocked_today} (${ads_percentage_today}%)"
|
||||
|
||||
sleep 5
|
||||
done
|
||||
|
@@ -1,20 +1,21 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Whitelists and blacklists 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
#globals
|
||||
basename=pihole
|
||||
piholeDir=/etc/${basename}
|
||||
whitelist=${piholeDir}/whitelist.txt
|
||||
blacklist=${piholeDir}/blacklist.txt
|
||||
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
reload=false
|
||||
addmode=true
|
||||
verbose=true
|
||||
@@ -41,19 +42,23 @@ helpFunc() {
|
||||
::: Usage: pihole -${letter} domain1 [domain2 ...]
|
||||
:::
|
||||
::: Options:
|
||||
::: -d, --delmode Remove domains from the ${word}list
|
||||
::: -nr, --noreload Update ${word}list without refreshing dnsmasq
|
||||
::: -q, --quiet output is less verbose
|
||||
::: -h, --help Show this help dialog
|
||||
::: -l, --list Display your ${word}listed domains
|
||||
::: -d, --delmode Remove domains from the ${word}list
|
||||
::: -nr, --noreload Update ${word}list without refreshing dnsmasq
|
||||
::: -q, --quiet Output is less verbose
|
||||
::: -h, --help Show this help dialog
|
||||
::: -l, --list Display your ${word}listed domains
|
||||
EOM
|
||||
if [[ "${letter}" == "b" ]]; then
|
||||
echo "::: -wild, --wildcard Add wildcard entry (only blacklist)"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
EscapeRegexp() {
|
||||
# This way we may safely insert an arbitrary
|
||||
# string in our regular expressions
|
||||
echo $* | sed "s/[]\\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g"
|
||||
# Also remove leading "." if present
|
||||
echo $* | sed 's/^\.*//' | sed "s/[]\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g"
|
||||
}
|
||||
|
||||
HandleOther(){
|
||||
@@ -61,7 +66,7 @@ HandleOther(){
|
||||
domain=$(sed -e "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/" <<< "$1")
|
||||
|
||||
#check validity of domain
|
||||
validDomain=$(perl -ne "print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/" <<< "$domain")
|
||||
validDomain=$(echo "${domain}" | perl -lne 'print if /(?!.*[^a-z0-9-\.].*)^((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9-]+\.)*[a-z]{2,63}/')
|
||||
if [ -z "${validDomain}" ]; then
|
||||
echo "::: $1 is not a valid argument or domain name"
|
||||
else
|
||||
@@ -79,6 +84,9 @@ PoplistFile() {
|
||||
if ${addmode}; then
|
||||
AddDomain "${dom}" "${listMain}"
|
||||
RemoveDomain "${dom}" "${listAlt}"
|
||||
if [[ "${listMain}" == "${whitelist}" || "${listMain}" == "${blacklist}" ]]; then
|
||||
RemoveDomain "${dom}" "${wildcardlist}"
|
||||
fi
|
||||
else
|
||||
RemoveDomain "${dom}" "${listMain}"
|
||||
fi
|
||||
@@ -89,22 +97,51 @@ AddDomain() {
|
||||
list="$2"
|
||||
domain=$(EscapeRegexp "$1")
|
||||
|
||||
bool=true
|
||||
#Is the domain in the list we want to add it to?
|
||||
grep -Ex -q "${domain}" ${list} > /dev/null 2>&1 || bool=false
|
||||
if [[ "${list}" == "${whitelist}" || "${list}" == "${blacklist}" ]]; then
|
||||
|
||||
if [[ "${bool}" == false ]]; then
|
||||
#domain not found in the whitelist file, add it!
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: Adding $1 to $list..."
|
||||
fi
|
||||
reload=true
|
||||
# Add it to the list we want to add it to
|
||||
echo "$1" >> ${list}
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} already exists in ${list}, no need to add!"
|
||||
fi
|
||||
bool=true
|
||||
#Is the domain in the list we want to add it to?
|
||||
grep -Ex -q "${domain}" "${list}" > /dev/null 2>&1 || bool=false
|
||||
|
||||
if [[ "${bool}" == false ]]; then
|
||||
#domain not found in the whitelist file, add it!
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: Adding $1 to $list..."
|
||||
fi
|
||||
reload=true
|
||||
# Add it to the list we want to add it to
|
||||
echo "$1" >> "${list}"
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} already exists in ${list}, no need to add!"
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ "${list}" == "${wildcardlist}" ]]; then
|
||||
|
||||
source "${piholeDir}/setupVars.conf"
|
||||
#Remove the /* from the end of the IPv4addr.
|
||||
IPV4_ADDRESS=${IPV4_ADDRESS%/*}
|
||||
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||
|
||||
bool=true
|
||||
#Is the domain in the list?
|
||||
grep -e "address=\/${domain}\/" "${wildcardlist}" > /dev/null 2>&1 || bool=false
|
||||
|
||||
if [[ "${bool}" == false ]]; then
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: Adding $1 to wildcard blacklist..."
|
||||
fi
|
||||
reload=true
|
||||
echo "address=/$1/${IPV4_ADDRESS}" >> "${wildcardlist}"
|
||||
if [[ ${#IPV6_ADDRESS} > 0 ]] ; then
|
||||
echo "address=/$1/${IPV6_ADDRESS}" >> "${wildcardlist}"
|
||||
fi
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} already exists in wildcard blacklist, no need to add!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -112,18 +149,38 @@ RemoveDomain() {
|
||||
list="$2"
|
||||
domain=$(EscapeRegexp "$1")
|
||||
|
||||
bool=true
|
||||
#Is it in the list? Logic follows that if its whitelisted it should not be blacklisted and vice versa
|
||||
grep -Ex -q "${domain}" ${list} > /dev/null 2>&1 || bool=false
|
||||
if [[ "${bool}" == true ]]; then
|
||||
# Remove it from the other one
|
||||
echo "::: Removing $1 from $list..."
|
||||
# /I flag: search case-insensitive
|
||||
sed -i "/${domain}/Id" ${list}
|
||||
reload=true
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} does not exist in ${list}, no need to remove!"
|
||||
if [[ "${list}" == "${whitelist}" || "${list}" == "${blacklist}" ]]; then
|
||||
|
||||
bool=true
|
||||
#Is it in the list? Logic follows that if its whitelisted it should not be blacklisted and vice versa
|
||||
grep -Ex -q "${domain}" "${list}" > /dev/null 2>&1 || bool=false
|
||||
if [[ "${bool}" == true ]]; then
|
||||
# Remove it from the other one
|
||||
echo "::: Removing $1 from $list..."
|
||||
# /I flag: search case-insensitive
|
||||
sed -i "/${domain}/Id" "${list}"
|
||||
reload=true
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} does not exist in ${list}, no need to remove!"
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ "${list}" == "${wildcardlist}" ]]; then
|
||||
|
||||
bool=true
|
||||
#Is it in the list?
|
||||
grep -e "address=\/${domain}\/" "${wildcardlist}" > /dev/null 2>&1 || bool=false
|
||||
if [[ "${bool}" == true ]]; then
|
||||
# Remove it from the other one
|
||||
echo "::: Removing $1 from $list..."
|
||||
# /I flag: search case-insensitive
|
||||
sed -i "/address=\/${domain}/Id" "${list}"
|
||||
reload=true
|
||||
else
|
||||
if [[ "${verbose}" == true ]]; then
|
||||
echo "::: ${1} does not exist in ${list}, no need to remove!"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
@@ -153,6 +210,7 @@ for var in "$@"; do
|
||||
case "${var}" in
|
||||
"-w" | "whitelist" ) listMain="${whitelist}"; listAlt="${blacklist}";;
|
||||
"-b" | "blacklist" ) listMain="${blacklist}"; listAlt="${whitelist}";;
|
||||
"-wild" | "wildcard" ) listMain="${wildcardlist}";;
|
||||
"-nr"| "--noreload" ) reload=false;;
|
||||
"-d" | "--delmode" ) addmode=false;;
|
||||
"-f" | "--force" ) force=true;;
|
||||
@@ -174,4 +232,3 @@ PoplistFile
|
||||
if ${reload}; then
|
||||
Reload
|
||||
fi
|
||||
|
||||
|
202
advanced/Scripts/piholeCheckout.sh
Normal file
202
advanced/Scripts/piholeCheckout.sh
Normal file
@@ -0,0 +1,202 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Checkout other branches than master
|
||||
#
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||
PH_TEST="true" source "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh"
|
||||
|
||||
# webInterfaceGitUrl set in basic-install.sh
|
||||
# webInterfaceDir set in basic-install.sh
|
||||
# piholeGitURL set in basic-install.sh
|
||||
# is_repo() sourced from basic-install.sh
|
||||
# setupVars set in basic-install.sh
|
||||
|
||||
source "${setupVars}"
|
||||
|
||||
update="false"
|
||||
|
||||
fully_fetch_repo() {
|
||||
# Add upstream branches to shallow clone
|
||||
local directory="${1}"
|
||||
|
||||
cd "${directory}" || return 1
|
||||
if is_repo "${directory}"; then
|
||||
git remote set-branches origin '*' || return 1
|
||||
git fetch --quiet || return 1
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
get_available_branches(){
|
||||
# Return available branches
|
||||
local directory="${1}"
|
||||
|
||||
cd "${directory}" || return 1
|
||||
# Get reachable remote branches
|
||||
git remote show origin | grep 'tracked' | sed 's/tracked//;s/ //g'
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
fetch_checkout_pull_branch() {
|
||||
# Check out specified branch
|
||||
local directory="${1}"
|
||||
local branch="${2}"
|
||||
|
||||
# Set the reference for the requested branch, fetch, check it put and pull it
|
||||
cd "${directory}"
|
||||
git remote set-branches origin "${branch}" || return 1
|
||||
git fetch --quiet || return 1
|
||||
checkout_pull_branch "${directory}" "${branch}" || return 1
|
||||
}
|
||||
|
||||
checkout_pull_branch() {
|
||||
# Check out specified branch
|
||||
local directory="${1}"
|
||||
local branch="${2}"
|
||||
local oldbranch
|
||||
|
||||
cd "${directory}" || return 1
|
||||
|
||||
oldbranch="$(git symbolic-ref HEAD)"
|
||||
|
||||
git checkout "${branch}" || return 1
|
||||
|
||||
if [ "$(git diff "${oldbranch}" | grep -c "^")" -gt "0" ]; then
|
||||
update="true"
|
||||
fi
|
||||
|
||||
git pull || return 1
|
||||
return 0
|
||||
}
|
||||
|
||||
warning1() {
|
||||
echo "::: Note that changing the branch is a severe change of your Pi-hole system."
|
||||
echo "::: This is not supported unless one of the developers explicitly asks you to do this!"
|
||||
read -r -p "::: Have you read and understood this? [y/N] " response
|
||||
case ${response} in
|
||||
[yY][eE][sS]|[yY])
|
||||
echo "::: Continuing."
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo "::: Aborting."
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
checkout()
|
||||
{
|
||||
local corebranches
|
||||
local webbranches
|
||||
|
||||
# Avoid globbing
|
||||
set -f
|
||||
|
||||
#This is unlikely
|
||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||
echo "::: Critical Error: Core Pi-hole repo is missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||
if ! is_repo "${webInterfaceDir}" ; then
|
||||
echo "::: Critical Error: Web Admin repo is missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "${1}" ]]; then
|
||||
echo "::: No option detected. Please use 'pihole checkout <master|dev>'."
|
||||
echo "::: Or enter the repository and branch you would like to check out:"
|
||||
echo "::: 'pihole checkout <web|core> <branchname>'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! warning1 ; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "${1}" == "dev" ]] ; then
|
||||
# Shortcut to check out development branches
|
||||
echo "::: Shortcut \"dev\" detected - checking out development / devel branches ..."
|
||||
echo "::: Pi-hole core"
|
||||
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "development" || { echo "Unable to pull Core developement branch"; exit 1; }
|
||||
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||
echo "::: Web interface"
|
||||
fetch_checkout_pull_branch "${webInterfaceDir}" "devel" || { echo "Unable to pull Web development branch"; exit 1; }
|
||||
fi
|
||||
echo "::: done!"
|
||||
elif [[ "${1}" == "master" ]] ; then
|
||||
# Shortcut to check out master branches
|
||||
echo "::: Shortcut \"master\" detected - checking out master branches ..."
|
||||
echo "::: Pi-hole core"
|
||||
fetch_checkout_pull_branch "${PI_HOLE_FILES_DIR}" "master" || { echo "Unable to pull Core master branch"; exit 1; }
|
||||
if [[ ${INSTALL_WEB} == "true" ]]; then
|
||||
echo "::: Web interface"
|
||||
fetch_checkout_pull_branch "${webInterfaceDir}" "master" || { echo "Unable to pull web master branch"; exit 1; }
|
||||
fi
|
||||
echo "::: done!"
|
||||
elif [[ "${1}" == "core" ]] ; then
|
||||
echo -n "::: Fetching remote branches for Pi-hole core from ${piholeGitUrl} ... "
|
||||
if ! fully_fetch_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||
echo "::: Fetching all branches for Pi-hole core repo failed!"
|
||||
exit 1
|
||||
fi
|
||||
corebranches=($(get_available_branches "${PI_HOLE_FILES_DIR}"))
|
||||
echo " done!"
|
||||
echo "::: ${#corebranches[@]} branches available"
|
||||
echo ":::"
|
||||
# Have to user chosing the branch he wants
|
||||
if ! (for e in "${corebranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
||||
echo "::: Requested branch \"${2}\" is not available!"
|
||||
echo "::: Available branches for core are:"
|
||||
for e in "${corebranches[@]}"; do echo "::: $e"; done
|
||||
exit 1
|
||||
fi
|
||||
checkout_pull_branch "${PI_HOLE_FILES_DIR}" "${2}"
|
||||
elif [[ "${1}" == "web" && "${INSTALL_WEB}" == "true" ]] ; then
|
||||
echo -n "::: Fetching remote branches for the web interface from ${webInterfaceGitUrl} ... "
|
||||
if ! fully_fetch_repo "${webInterfaceDir}" ; then
|
||||
echo "::: Fetching all branches for Pi-hole web interface repo failed!"
|
||||
exit 1
|
||||
fi
|
||||
webbranches=($(get_available_branches "${webInterfaceDir}"))
|
||||
echo " done!"
|
||||
echo "::: ${#webbranches[@]} branches available"
|
||||
echo ":::"
|
||||
# Have to user chosing the branch he wants
|
||||
if ! (for e in "${webbranches[@]}"; do [[ "$e" == "${2}" ]] && exit 0; done); then
|
||||
echo "::: Requested branch \"${2}\" is not available!"
|
||||
echo "::: Available branches for web are:"
|
||||
for e in "${webbranches[@]}"; do echo "::: $e"; done
|
||||
exit 1
|
||||
fi
|
||||
checkout_pull_branch "${webInterfaceDir}" "${2}"
|
||||
else
|
||||
echo "::: Requested option \"${1}\" is not available!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Force updating everything
|
||||
if [[ ! "${1}" == "web" && "${update}" == "true" ]]; then
|
||||
echo "::: Running installer to upgrade your installation"
|
||||
if "${PI_HOLE_FILES_DIR}/automated install/basic-install.sh" --unattended; then
|
||||
exit 0
|
||||
else
|
||||
echo "Unable to complete update, contact Pi-hole"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Generates pihole_debug.log to be used for troubleshooting.
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
set -o pipefail
|
||||
|
||||
@@ -16,7 +16,7 @@ set -o pipefail
|
||||
VARSFILE="/etc/pihole/setupVars.conf"
|
||||
DEBUG_LOG="/var/log/pihole_debug.log"
|
||||
DNSMASQFILE="/etc/dnsmasq.conf"
|
||||
DNSMASQCONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
||||
DNSMASQCONFDIR="/etc/dnsmasq.d/*"
|
||||
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
||||
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
|
||||
GRAVITYFILE="/etc/pihole/gravity.list"
|
||||
@@ -24,9 +24,11 @@ WHITELISTFILE="/etc/pihole/whitelist.txt"
|
||||
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
||||
ADLISTFILE="/etc/pihole/adlists.list"
|
||||
PIHOLELOG="/var/log/pihole.log"
|
||||
PIHOLEGITDIR="/etc/.pihole/"
|
||||
ADMINGITDIR="/var/www/html/admin/"
|
||||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||
readonly FTLLOG="/var/log/pihole-FTL.log"
|
||||
|
||||
IPV6_READY=false
|
||||
TIMEOUT=60
|
||||
# Header info and introduction
|
||||
cat << EOM
|
||||
@@ -35,23 +37,18 @@ cat << EOM
|
||||
::: This process collects information from your Pi-hole, and optionally uploads
|
||||
::: it to a unique and random directory on tricorder.pi-hole.net.
|
||||
:::
|
||||
::: NOTE: All log files auto-delete after 24 hours and ONLY the Pi-hole developers
|
||||
::: NOTE: All log files auto-delete after 48 hours and ONLY the Pi-hole developers
|
||||
::: can access your data via the given token. We have taken these extra steps to
|
||||
::: secure your data and will work to further reduce any personal information gathered.
|
||||
:::
|
||||
::: Please read and note any issues, and follow any directions advised during this process.
|
||||
EOM
|
||||
|
||||
# Ensure the file exists, create if not, clear if exists.
|
||||
truncate --size=0 "${DEBUG_LOG}"
|
||||
chmod 644 ${DEBUG_LOG}
|
||||
chown "$USER":pihole ${DEBUG_LOG}
|
||||
|
||||
source ${VARSFILE}
|
||||
|
||||
### Private functions exist here ###
|
||||
log_write() {
|
||||
echo "${1}" >> "${DEBUG_LOG}"
|
||||
echo "${@}" >&3
|
||||
}
|
||||
|
||||
log_echo() {
|
||||
@@ -76,14 +73,14 @@ log_echo() {
|
||||
|
||||
header_write() {
|
||||
log_echo ""
|
||||
log_echo "${1}"
|
||||
log_echo "---= ${1}"
|
||||
log_write ""
|
||||
}
|
||||
|
||||
file_parse() {
|
||||
while read -r line; do
|
||||
if [ ! -z "${line}" ]; then
|
||||
[[ "${line}" =~ ^#.*$ || ! "${line}" ]] && continue
|
||||
[[ "${line}" =~ ^#.*$ || ! "${line}" || "${line}" == "WEBPASSWORD="* ]] && continue
|
||||
log_write "${line}"
|
||||
fi
|
||||
done < "${1}"
|
||||
@@ -112,28 +109,86 @@ version_check() {
|
||||
header_write "Detecting Installed Package Versions:"
|
||||
|
||||
local error_found
|
||||
local pi_hole_ver
|
||||
local pi_hole_branch
|
||||
local pi_hole_commit
|
||||
local admin_ver
|
||||
local admin_branch
|
||||
local admin_commit
|
||||
local light_ver
|
||||
local php_ver
|
||||
local status
|
||||
error_found=0
|
||||
|
||||
local pi_hole_ver="$(cd /etc/.pihole/ && git describe --tags --abbrev=0)" \
|
||||
&& log_echo -r "Pi-hole: $pi_hole_ver" || (log_echo "Pi-hole git repository not detected." && error_found=1)
|
||||
local admin_ver="$(cd /var/www/html/admin && git describe --tags --abbrev=0)" \
|
||||
&& log_echo -r "WebUI: $admin_ver" || (log_echo "Pi-hole Admin Pages git repository not detected." && error_found=1)
|
||||
local light_ver="$(lighttpd -v |& head -n1 | cut -d " " -f1)" \
|
||||
&& log_echo -r "${light_ver}" || (log_echo "lighttpd not installed." && error_found=1)
|
||||
local php_ver="$(php -v |& head -n1)" \
|
||||
&& log_echo -r "${php_ver}" || (log_echo "PHP not installed." && error_found=1)
|
||||
cd "${PIHOLEGITDIR}" &> /dev/null || \
|
||||
{ status="Pi-hole git directory not found."; error_found=1; }
|
||||
if git status &> /dev/null; then
|
||||
pi_hole_ver=$(git describe --tags --abbrev=0)
|
||||
pi_hole_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
pi_hole_commit=$(git describe --long --dirty --tags --always)
|
||||
log_echo -r "Pi-hole: ${pi_hole_ver:-Untagged} (${pi_hole_branch:-Detached}:${pi_hole_commit})"
|
||||
else
|
||||
status=${status:-"Pi-hole repository damaged."}
|
||||
error_found=1
|
||||
fi
|
||||
if [[ "${status}" ]]; then
|
||||
log_echo "${status}"
|
||||
unset status
|
||||
fi
|
||||
|
||||
cd "${ADMINGITDIR}" || \
|
||||
{ status="Pi-hole Dashboard git directory not found."; error_found=1; }
|
||||
if git status &> /dev/null; then
|
||||
admin_ver=$(git describe --tags --abbrev=0)
|
||||
admin_branch=$(git rev-parse --abbrev-ref HEAD)
|
||||
admin_commit=$(git describe --long --dirty --tags --always)
|
||||
log_echo -r "Pi-hole Dashboard: ${admin_ver:-Untagged} (${admin_branch:-Detached}:${admin_commit})"
|
||||
else
|
||||
status=${status:-"Pi-hole Dashboard repository damaged."}
|
||||
error_found=1
|
||||
fi
|
||||
if [[ "${status}" ]]; then
|
||||
log_echo "${status}"
|
||||
unset status
|
||||
fi
|
||||
|
||||
if light_ver=$(lighttpd -v |& head -n1 | cut -d " " -f1); then
|
||||
log_echo -r "${light_ver}"
|
||||
else
|
||||
log_echo "lighttpd not installed."
|
||||
error_found=1
|
||||
fi
|
||||
if php_ver=$(php -v |& head -n1); then
|
||||
log_echo -r "${php_ver}"
|
||||
else
|
||||
log_echo "PHP not installed."
|
||||
error_found=1
|
||||
fi
|
||||
|
||||
return "${error_found}"
|
||||
}
|
||||
|
||||
dir_check() {
|
||||
header_write "Detecting contents of ${1}:"
|
||||
for file in $1*; do
|
||||
header_write "File ${file} found"
|
||||
echo -n "::: Parsing..."
|
||||
file_parse "${file}"
|
||||
echo "done"
|
||||
done
|
||||
echo ":::"
|
||||
}
|
||||
|
||||
files_check() {
|
||||
#Check non-zero length existence of ${1}
|
||||
header_write "Detecting existence of ${1}:"
|
||||
local search_file="${1}"
|
||||
if [[ -s ${search_file} ]]; then
|
||||
echo "::: File exists"
|
||||
echo -n "::: File exists, parsing..."
|
||||
file_parse "${search_file}"
|
||||
echo "done"
|
||||
return 0
|
||||
else
|
||||
else
|
||||
log_echo "${1} not found!"
|
||||
return 1
|
||||
fi
|
||||
@@ -161,72 +216,70 @@ processor_check() {
|
||||
|
||||
ipv6_check() {
|
||||
# Check if system is IPv6 enabled, for use in other functions
|
||||
if [[ $IPv6_address ]]; then
|
||||
ls /proc/net/if_inet6 &>/dev/null && IPV6_READY=true
|
||||
if [[ $IPV6_ADDRESS ]]; then
|
||||
ls /proc/net/if_inet6 &>/dev/null
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
ip_check() {
|
||||
header_write "IP Address Information"
|
||||
# Get the current interface for Internet traffic
|
||||
|
||||
# Check if IPv6 enabled
|
||||
local IPv6_interface
|
||||
local IPv4_interface
|
||||
ipv6_check && IPv6_interface=${piholeInterface:-$(ip -6 r | grep default | cut -d ' ' -f 5)}
|
||||
# If declared in setupVars.conf use it, otherwise defer to default
|
||||
# http://stackoverflow.com/questions/2013547/assigning-default-values-to-shell-variables-with-a-single-command-in-bash
|
||||
IPv4_interface=${piholeInterface:-$(ip r | grep default | cut -d ' ' -f 5)}
|
||||
|
||||
|
||||
if [[ IPV6_READY ]]; then
|
||||
local IPv6_addr_list="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet6") print $(i+1) }')" \
|
||||
&& (log_write "${IPv6_addr_list}" && echo "::: IPv6 addresses located") \
|
||||
|| log_echo "No IPv6 addresses found."
|
||||
|
||||
local IPv6_def_gateway=$(ip -6 r | grep default | cut -d ' ' -f 3)
|
||||
if [[ $? = 0 ]] && [[ -n ${IPv6_def_gateway} ]]; then
|
||||
echo -n "::: Pinging default IPv6 gateway: "
|
||||
local IPv6_def_gateway_check="$(ping6 -q -W 3 -c 3 -n "${IPv6_def_gateway}" -I "${IPv6_interface}"| tail -n3)" \
|
||||
&& echo "Gateway Responded." \
|
||||
|| echo "Gateway did not respond."
|
||||
block_parse "${IPv6_def_gateway_check}"
|
||||
|
||||
echo -n "::: Pinging Internet via IPv6: "
|
||||
local IPv6_inet_check=$(ping6 -q -W 3 -c 3 -n 2001:4860:4860::8888 -I "${IPv6_interface}"| tail -n3) \
|
||||
&& echo "Query responded." \
|
||||
|| echo "Query did not respond."
|
||||
block_parse "${IPv6_inet_check}"
|
||||
else
|
||||
log_echo="No IPv6 Gateway Detected"
|
||||
fi
|
||||
|
||||
local IPv4_addr_list="$(ip a | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "inet") print $(i+1) }')" \
|
||||
&& (block_parse "${IPv4_addr_list}" && echo "::: IPv4 addresses located")\
|
||||
|| log_echo "No IPv4 addresses found."
|
||||
|
||||
local IPv4_def_gateway=$(ip r | grep default | cut -d ' ' -f 3)
|
||||
if [[ $? = 0 ]]; then
|
||||
echo -n "::: Pinging default IPv4 gateway: "
|
||||
local IPv4_def_gateway_check="$(ping -q -w 3 -c 3 -n "${IPv4_def_gateway}" -I "${IPv4_interface}" | tail -n3)" \
|
||||
&& echo "Gateway responded." \
|
||||
|| echo "Gateway did not respond."
|
||||
block_parse "${IPv4_def_gateway_check}"
|
||||
|
||||
echo -n "::: Pinging Internet via IPv4: "
|
||||
local IPv4_inet_check="$(ping -q -w 5 -c 3 -n 8.8.8.8 -I "${IPv4_interface}" | tail -n3)" \
|
||||
&& echo "Query responded." \
|
||||
|| echo "Query did not respond."
|
||||
block_parse "${IPv4_inet_check}"
|
||||
fi
|
||||
local protocol=${1}
|
||||
local gravity=${2}
|
||||
header_write "Checking IPv${protocol} Stack"
|
||||
|
||||
local ip_addr_list="$(ip -${protocol} addr show dev ${PIHOLE_INTERFACE} | awk -F ' ' '{ for(i=1;i<=NF;i++) if ($i ~ '/^inet/') print $(i+1) }')"
|
||||
if [[ -n ${ip_addr_list} ]]; then
|
||||
log_write "IPv${protocol} on ${PIHOLE_INTERFACE}"
|
||||
log_write "Gravity configured for: ${2:-NOT CONFIGURED}"
|
||||
log_write "----"
|
||||
log_write "${ip_addr_list}"
|
||||
echo "::: IPv${protocol} addresses located on ${PIHOLE_INTERFACE}"
|
||||
ip_ping_check ${protocol}
|
||||
return $(( 0 + $? ))
|
||||
else
|
||||
log_echo "No IPv${protocol} found on ${PIHOLE_INTERFACE}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
ip_ping_check() {
|
||||
local protocol=${1}
|
||||
local cmd
|
||||
|
||||
if [[ ${protocol} == "6" ]]; then
|
||||
cmd="ping6"
|
||||
g_addr="2001:4860:4860::8888"
|
||||
else
|
||||
cmd="ping"
|
||||
g_addr="8.8.8.8"
|
||||
fi
|
||||
|
||||
local ip_def_gateway=$(ip -${protocol} route | grep default | cut -d ' ' -f 3)
|
||||
if [[ -n ${ip_def_gateway} ]]; then
|
||||
echo -n "::: Pinging default IPv${protocol} gateway: "
|
||||
if ! ping_gateway="$(${cmd} -q -W 3 -c 3 -n ${ip_def_gateway} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
||||
echo "Gateway did not respond."
|
||||
return 1
|
||||
else
|
||||
echo "Gateway responded."
|
||||
log_write "${ping_gateway}"
|
||||
fi
|
||||
echo -n "::: Pinging Internet via IPv${protocol}: "
|
||||
if ! ping_inet="$(${cmd} -q -W 3 -c 3 -n ${g_addr} -I ${PIHOLE_INTERFACE} | tail -n 3)"; then
|
||||
echo "Query did not respond."
|
||||
return 1
|
||||
else
|
||||
echo "Query responded."
|
||||
log_write "${ping_inet}"
|
||||
fi
|
||||
else
|
||||
log_echo " No gateway detected."
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
port_check() {
|
||||
local lsof_value
|
||||
|
||||
@@ -249,62 +302,78 @@ daemon_check() {
|
||||
}
|
||||
|
||||
testResolver() {
|
||||
header_write "Resolver Functions Check"
|
||||
local protocol="${1}"
|
||||
header_write "Resolver Functions Check (IPv${protocol})"
|
||||
local IP="${2}"
|
||||
local g_addr
|
||||
local l_addr
|
||||
local url
|
||||
local testurl
|
||||
local localdig
|
||||
local piholedig
|
||||
local remotedig
|
||||
|
||||
if [[ ${protocol} == "6" ]]; then
|
||||
g_addr="2001:4860:4860::8888"
|
||||
l_addr="::1"
|
||||
r_type="AAAA"
|
||||
else
|
||||
g_addr="8.8.8.8"
|
||||
l_addr="127.0.0.1"
|
||||
r_type="A"
|
||||
fi
|
||||
|
||||
# Find a blocked url that has not been whitelisted.
|
||||
TESTURL="doubleclick.com"
|
||||
if [ -s "${WHITELISTMATCHES}" ]; then
|
||||
while read -r line; do
|
||||
CUTURL=${line#*" "}
|
||||
if [ "${CUTURL}" != "Pi-Hole.IsWorking.OK" ]; then
|
||||
while read -r line2; do
|
||||
CUTURL2=${line2#*" "}
|
||||
if [ "${CUTURL}" != "${CUTURL2}" ]; then
|
||||
TESTURL="${CUTURL}"
|
||||
break 2
|
||||
fi
|
||||
done < "${WHITELISTMATCHES}"
|
||||
fi
|
||||
done < "${GRAVITYFILE}"
|
||||
fi
|
||||
url=$(shuf -n 1 "${GRAVITYFILE}" | awk -F ' ' '{ print $2 }')
|
||||
|
||||
log_write "Resolution of ${TESTURL} from Pi-hole:"
|
||||
LOCALDIG=$(dig "${TESTURL}" @127.0.0.1)
|
||||
if [[ $? = 0 ]]; then
|
||||
log_write "${LOCALDIG}"
|
||||
testurl="${url:-doubleclick.com}"
|
||||
|
||||
|
||||
log_write "Resolution of ${testurl} from Pi-hole (${l_addr}):"
|
||||
if localdig=$(dig -"${protocol}" "${testurl}" @${l_addr} +short "${r_type}"); then
|
||||
log_write "${localdig}"
|
||||
else
|
||||
log_write "Failed to resolve ${TESTURL} on Pi-hole"
|
||||
log_write "Failed to resolve ${testurl} on Pi-hole (${l_addr})"
|
||||
fi
|
||||
log_write ""
|
||||
|
||||
log_write "Resolution of ${testurl} from Pi-hole (${IP}):"
|
||||
if piholedig=$(dig -"${protocol}" "${testurl}" @"${IP}" +short "${r_type}"); then
|
||||
log_write "${piholedig}"
|
||||
else
|
||||
log_write "Failed to resolve ${testurl} on Pi-hole (${IP})"
|
||||
fi
|
||||
log_write ""
|
||||
|
||||
|
||||
log_write "Resolution of ${TESTURL} from 8.8.8.8:"
|
||||
REMOTEDIG=$(dig "${TESTURL}" @8.8.8.8)
|
||||
if [[ $? = 0 ]]; then
|
||||
log_write "${REMOTEDIG}"
|
||||
log_write "Resolution of ${testurl} from ${g_addr}:"
|
||||
if remotedig=$(dig -"${protocol}" "${testurl}" @${g_addr} +short "${r_type}"); then
|
||||
log_write "${remotedig:-NXDOMAIN}"
|
||||
else
|
||||
log_write "Failed to resolve ${TESTURL} on 8.8.8.8"
|
||||
log_write "Failed to resolve ${testurl} on upstream server ${g_addr}"
|
||||
fi
|
||||
log_write ""
|
||||
|
||||
log_write "Pi-hole dnsmasq specific records lookups"
|
||||
log_write "Cache Size:"
|
||||
dig +short chaos txt cachesize.bind >> ${DEBUG_LOG}
|
||||
log_write "Upstream Servers:"
|
||||
dig +short chaos txt servers.bind >> ${DEBUG_LOG}
|
||||
log_write ""
|
||||
}
|
||||
|
||||
testChaos(){
|
||||
# Check Pi-hole specific records
|
||||
|
||||
log_write "Pi-hole dnsmasq specific records lookups"
|
||||
log_write "Cache Size:"
|
||||
log_write $(dig +short chaos txt cachesize.bind)
|
||||
log_write "Upstream Servers:"
|
||||
log_write $(dig +short chaos txt servers.bind)
|
||||
log_write ""
|
||||
|
||||
}
|
||||
checkProcesses() {
|
||||
header_write "Processes Check"
|
||||
|
||||
echo "::: Logging status of lighttpd and dnsmasq..."
|
||||
PROCESSES=( lighttpd dnsmasq )
|
||||
echo "::: Logging status of lighttpd, dnsmasq and pihole-FTL..."
|
||||
PROCESSES=( lighttpd dnsmasq pihole-FTL )
|
||||
for i in "${PROCESSES[@]}"; do
|
||||
log_write ""
|
||||
log_write "${i}"
|
||||
log_write " processes status:"
|
||||
systemctl -l status "${i}" >> "${DEBUG_LOG}"
|
||||
log_write "Status for ${i} daemon:"
|
||||
log_write $(systemctl is-active "${i}")
|
||||
done
|
||||
log_write ""
|
||||
}
|
||||
@@ -317,46 +386,21 @@ debugLighttpd() {
|
||||
}
|
||||
|
||||
countdown() {
|
||||
local tuvix
|
||||
tuvix=${TIMEOUT}
|
||||
printf "::: Logging will automatically teminate in ${TIMEOUT} seconds\n"
|
||||
printf "::: Logging will automatically teminate in %s seconds\n" "${TIMEOUT}"
|
||||
while [ $tuvix -ge 1 ]
|
||||
do
|
||||
printf ":::\t${tuvix} seconds left. \r"
|
||||
printf ":::\t%s seconds left. " "${tuvix}"
|
||||
if [[ -z "${WEBCALL}" ]]; then
|
||||
printf "\r"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
sleep 5
|
||||
tuvix=$(( tuvix - 5 ))
|
||||
done
|
||||
}
|
||||
### END FUNCTIONS ###
|
||||
|
||||
# Gather version of required packages / repositories
|
||||
version_check || echo "REQUIRED FILES MISSING"
|
||||
# Check for newer setupVars storage file
|
||||
source_file "/etc/pihole/setupVars.conf"
|
||||
# Gather information about the running distribution
|
||||
distro_check || echo "Distro Check soft fail"
|
||||
# Gather processor type
|
||||
processor_check || echo "Processor Check soft fail"
|
||||
|
||||
ip_check
|
||||
|
||||
daemon_check lighttpd http
|
||||
daemon_check dnsmasq domain
|
||||
checkProcesses
|
||||
testResolver
|
||||
debugLighttpd
|
||||
|
||||
files_check "${DNSMASQFILE}"
|
||||
files_check "${DNSMASQCONFFILE}"
|
||||
files_check "${WHITELISTFILE}"
|
||||
files_check "${BLACKLISTFILE}"
|
||||
files_check "${ADLISTFILE}"
|
||||
|
||||
|
||||
header_write "Analyzing gravity.list"
|
||||
|
||||
gravity_length=$(wc -l "${GRAVITYFILE}") \
|
||||
&& log_write "${GRAVITYFILE} is ${gravity_length} lines long." \
|
||||
|| log_echo "Warning: No gravity.list file found!"
|
||||
|
||||
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||
dumpPiHoleLog() {
|
||||
@@ -368,7 +412,7 @@ dumpPiHoleLog() {
|
||||
if [ -e "${PIHOLELOG}" ]; then
|
||||
# Dummy process to use for flagging down tail to terminate
|
||||
countdown &
|
||||
tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG}
|
||||
tail -n0 -f --pid=$! "${PIHOLELOG}" >&4
|
||||
else
|
||||
log_write "No pihole.log file found!"
|
||||
printf ":::\tNo pihole.log file found!\n"
|
||||
@@ -379,21 +423,35 @@ dumpPiHoleLog() {
|
||||
finalWork() {
|
||||
local tricorder
|
||||
echo "::: Finshed debugging!"
|
||||
echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only."
|
||||
read -r -p "::: Would you like to upload the log? [y/N] " response
|
||||
case ${response} in
|
||||
[yY][eE][sS]|[yY])
|
||||
tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999)
|
||||
;;
|
||||
*)
|
||||
echo "::: Log will NOT be uploaded to tricorder."
|
||||
;;
|
||||
esac
|
||||
|
||||
# Ensure the file exists, create if not, clear if exists.
|
||||
truncate --size=0 "${DEBUG_LOG}"
|
||||
chmod 644 ${DEBUG_LOG}
|
||||
chown "$USER":pihole ${DEBUG_LOG}
|
||||
# copy working temp file to final log location
|
||||
cat /proc/$$/fd/3 >> "${DEBUG_LOG}"
|
||||
# Straight dump of tailing the logs, can sanitize later if needed.
|
||||
cat /proc/$$/fd/4 >> "${DEBUG_LOG}"
|
||||
|
||||
echo "::: The debug log can be uploaded to tricorder.pi-hole.net for sharing with developers only."
|
||||
if [[ "${AUTOMATED}" ]]; then
|
||||
echo "::: Debug script running in automated mode, uploading log to tricorder..."
|
||||
tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999)
|
||||
else
|
||||
read -r -p "::: Would you like to upload the log? [y/N] " response
|
||||
case ${response} in
|
||||
[yY][eE][sS]|[yY])
|
||||
tricorder=$(cat /var/log/pihole_debug.log | nc tricorder.pi-hole.net 9999)
|
||||
;;
|
||||
*)
|
||||
echo "::: Log will NOT be uploaded to tricorder."
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
# Check if tricorder.pi-hole.net is reachable and provide token.
|
||||
if [ -n "${tricorder}" ]; then
|
||||
echo "::: Your debug token is : ${tricorder}"
|
||||
echo "::: Please contact the Pi-hole team with your token for assistance."
|
||||
echo "::: ---=== Your debug token is : ${tricorder} Please make a note of it. ===---"
|
||||
echo "::: Contact the Pi-hole team with your token for assistance."
|
||||
echo "::: Thank you."
|
||||
else
|
||||
echo "::: There was an error uploading your debug log."
|
||||
@@ -402,6 +460,82 @@ finalWork() {
|
||||
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
||||
}
|
||||
|
||||
### END FUNCTIONS ###
|
||||
# Create temporary file for log
|
||||
TEMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX)
|
||||
# Open handle 3 for templog
|
||||
exec 3>"$TEMPLOG"
|
||||
# Delete templog, but allow for addressing via file handle.
|
||||
rm "$TEMPLOG"
|
||||
|
||||
# Create temporary file for logdump using file handle 4
|
||||
DUMPLOG=$(mktemp /tmp/pihole_temp.XXXXXX)
|
||||
exec 4>"$DUMPLOG"
|
||||
rm "$DUMPLOG"
|
||||
|
||||
# Gather version of required packages / repositories
|
||||
version_check || echo "REQUIRED FILES MISSING"
|
||||
# Check for newer setupVars storage file
|
||||
source_file "/etc/pihole/setupVars.conf"
|
||||
# Gather information about the running distribution
|
||||
distro_check || echo "Distro Check soft fail"
|
||||
# Gather processor type
|
||||
processor_check || echo "Processor Check soft fail"
|
||||
|
||||
ip_check 6 ${IPV6_ADDRESS}
|
||||
ip_check 4 ${IPV4_ADDRESS}
|
||||
|
||||
daemon_check lighttpd http
|
||||
daemon_check dnsmasq domain
|
||||
daemon_check pihole-FTL 4711
|
||||
checkProcesses
|
||||
|
||||
# Check local/IP/Google for IPv4 Resolution
|
||||
testResolver 4 "${IPV4_ADDRESS%/*}"
|
||||
# If IPv6 enabled, check resolution
|
||||
if [[ "${IPV6_ADDRESS}" ]]; then
|
||||
testResolver 6 "${IPV6_ADDRESS%/*}"
|
||||
fi
|
||||
# Poll dnsmasq Pi-hole specific queries
|
||||
testChaos
|
||||
|
||||
debugLighttpd
|
||||
|
||||
files_check "${DNSMASQFILE}"
|
||||
dir_check "${DNSMASQCONFDIR}"
|
||||
files_check "${WHITELISTFILE}"
|
||||
files_check "${BLACKLISTFILE}"
|
||||
files_check "${ADLISTFILE}"
|
||||
|
||||
|
||||
header_write "Analyzing gravity.list"
|
||||
|
||||
gravity_length=$(grep -c ^ "${GRAVITYFILE}") \
|
||||
&& log_write "${GRAVITYFILE} is ${gravity_length} lines long." \
|
||||
|| log_echo "Warning: No gravity.list file found!"
|
||||
|
||||
header_write "Analyzing pihole.log"
|
||||
|
||||
pihole_length=$(grep -c ^ "${PIHOLELOG}") \
|
||||
&& log_write "${PIHOLELOG} is ${pihole_length} lines long." \
|
||||
|| log_echo "Warning: No pihole.log file found!"
|
||||
|
||||
pihole_size=$(du -h "${PIHOLELOG}" | awk '{ print $1 }') \
|
||||
&& log_write "${PIHOLELOG} is ${pihole_size}." \
|
||||
|| log_echo "Warning: No pihole.log file found!"
|
||||
|
||||
header_write "Analyzing pihole-FTL.log"
|
||||
|
||||
FTL_length=$(grep -c ^ "${FTLLOG}") \
|
||||
&& log_write "${FTLLOG} is ${FTL_length} lines long." \
|
||||
|| log_echo "Warning: No pihole-FTL.log file found!"
|
||||
|
||||
FTL_size=$(du -h "${FTLLOG}" | awk '{ print $1 }') \
|
||||
&& log_write "${FTLLOG} is ${FTL_size}." \
|
||||
|| log_echo "Warning: No pihole-FTL.log file found!"
|
||||
|
||||
tail -n50 "${FTLLOG}" >&3
|
||||
|
||||
trap finalWork EXIT
|
||||
|
||||
### Method calls for additional logging ###
|
||||
|
@@ -1,15 +1,24 @@
|
||||
#!/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
|
||||
# Flushes /var/log/pihole.log
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# 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.
|
||||
# Flushes Pi-hole's log file
|
||||
#
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||
echo " " > /var/log/pihole.log
|
||||
# Test if logrotate is available on this system
|
||||
if command -v /usr/sbin/logrotate &> /dev/null; then
|
||||
# Flush twice to move all data out of sight of FTL
|
||||
/usr/sbin/logrotate --force /etc/pihole/logrotate
|
||||
/usr/sbin/logrotate --force /etc/pihole/logrotate
|
||||
else
|
||||
# Flush both pihole.log and pihole.log.1 (if existing)
|
||||
echo " " > /var/log/pihole.log
|
||||
if [ -f /var/log/pihole.log.1 ]; then
|
||||
echo " " > /var/log/pihole.log.1
|
||||
fi
|
||||
fi
|
||||
echo "... done!"
|
||||
|
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Automatically configures the Pi to use the 2.8 LCD screen to display stats on it (also works over ssh)
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
############ FUNCTIONS ###########
|
||||
|
||||
|
@@ -1,16 +1,16 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Check Pi-hole core and admin pages versions and determine what
|
||||
# upgrade (if any) is required. Automatically updates and reinstalls
|
||||
# application if update is detected.
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
# Variables
|
||||
|
||||
@@ -19,84 +19,52 @@ readonly ADMIN_INTERFACE_DIR="/var/www/html/admin"
|
||||
readonly PI_HOLE_GIT_URL="https://github.com/pi-hole/pi-hole.git"
|
||||
readonly PI_HOLE_FILES_DIR="/etc/.pihole"
|
||||
|
||||
is_repo() {
|
||||
# Use git to check if directory is currently under VCS, return the value
|
||||
local directory="${1}"
|
||||
local curdir
|
||||
local rc
|
||||
PH_TEST=true
|
||||
source ${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh
|
||||
|
||||
curdir="${PWD}"
|
||||
cd "${directory}" &> /dev/null || return 1
|
||||
git status --short &> /dev/null
|
||||
rc=$?
|
||||
cd "${curdir}" &> /dev/null || return 1
|
||||
return "${rc}"
|
||||
}
|
||||
|
||||
prep_repo() {
|
||||
# Prepare directory for local repository building
|
||||
local directory="${1}"
|
||||
|
||||
rm -rf "${directory}" &> /dev/null
|
||||
return
|
||||
}
|
||||
|
||||
make_repo() {
|
||||
# Remove the non-repod interface and clone the interface
|
||||
local remoteRepo="${2}"
|
||||
local directory="${1}"
|
||||
|
||||
(prep_repo "${directory}" && git clone -q --depth 1 "${remoteRepo}" "${directory}")
|
||||
return
|
||||
}
|
||||
|
||||
update_repo() {
|
||||
local directory="${1}"
|
||||
local curdir
|
||||
|
||||
curdir="${PWD}"
|
||||
cd "${directory}" &> /dev/null || return 1
|
||||
# Pull the latest commits
|
||||
# Stash all files not tracked for later retrieval
|
||||
git stash --all --quiet
|
||||
# Force a clean working directory for cloning
|
||||
git clean --force -d
|
||||
# Fetch latest changes and apply
|
||||
git pull --quiet
|
||||
cd "${curdir}" &> /dev/null || return 1
|
||||
}
|
||||
|
||||
getGitFiles() {
|
||||
# Setup git repos for directory and repository passed
|
||||
# as arguments 1 and 2
|
||||
local directory="${1}"
|
||||
local remoteRepo="${2}"
|
||||
echo ":::"
|
||||
echo "::: Checking for existing repository..."
|
||||
if is_repo "${directory}"; then
|
||||
echo -n "::: Updating repository in ${directory}..."
|
||||
update_repo "${directory}" || (echo "*** Error: Could not update local repository. Contact support."; exit 1)
|
||||
echo " done!"
|
||||
else
|
||||
echo -n "::: Cloning ${remoteRepo} into ${directory}..."
|
||||
make_repo "${directory}" "${remoteRepo}" || (echo "Unable to clone repository, please contact support"; exit 1)
|
||||
echo " done!"
|
||||
fi
|
||||
}
|
||||
# is_repo() sourced from basic-install.sh
|
||||
# make_repo() sourced from basic-install.sh
|
||||
# update_repo() source from basic-install.sh
|
||||
# getGitFiles() sourced from basic-install.sh
|
||||
|
||||
GitCheckUpdateAvail() {
|
||||
local directory="${1}"
|
||||
curdir=$PWD;
|
||||
curdir=$PWD
|
||||
cd "${directory}"
|
||||
|
||||
# Fetch latest changes in this repo
|
||||
git fetch --quiet origin
|
||||
status="$(git status -sb)"
|
||||
|
||||
# @ alone is a shortcut for HEAD. Older versions of git
|
||||
# need @{0}
|
||||
LOCAL="$(git rev-parse @{0})"
|
||||
|
||||
# The suffix @{upstream} to a branchname
|
||||
# (short form <branchname>@{u}) refers
|
||||
# to the branch that the branch specified
|
||||
# by branchname is set to build on top of#
|
||||
# (configured with branch.<name>.remote and
|
||||
# branch.<name>.merge). A missing branchname
|
||||
# defaults to the current one.
|
||||
REMOTE="$(git rev-parse @{upstream})"
|
||||
|
||||
if [[ ${#LOCAL} == 0 ]]; then
|
||||
echo "::: Error: Local revision could not be obtained, ask Pi-hole support."
|
||||
echo "::: Additional debugging output:"
|
||||
git status
|
||||
exit
|
||||
fi
|
||||
if [[ ${#REMOTE} == 0 ]]; then
|
||||
echo "::: Error: Remote revision could not be obtained, ask Pi-hole support."
|
||||
echo "::: Additional debugging output:"
|
||||
git status
|
||||
exit
|
||||
fi
|
||||
|
||||
# Change back to original directory
|
||||
cd "${curdir}"
|
||||
|
||||
if [[ $status == *"behind"* ]]; then
|
||||
if [[ "${LOCAL}" != "${REMOTE}" ]]; then
|
||||
# Local branch is behind remote branch -> Update
|
||||
return 0
|
||||
else
|
||||
@@ -107,13 +75,26 @@ GitCheckUpdateAvail() {
|
||||
fi
|
||||
}
|
||||
|
||||
FTLcheckUpdate() {
|
||||
|
||||
local FTLversion=$(/usr/bin/pihole-FTL tag)
|
||||
local FTLlatesttag=$(curl -sI https://github.com/pi-hole/FTL/releases/latest | grep 'Location' | awk -F '/' '{print $NF}' | tr -d '\r\n')
|
||||
|
||||
if [[ "${FTLversion}" != "${FTLlatesttag}" ]]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
main() {
|
||||
local pihole_version_current
|
||||
local web_version_current
|
||||
source "${setupVars}"
|
||||
|
||||
#This is unlikely
|
||||
if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
||||
echo "::: Critical Error: One or more Pi-Hole repos are missing from system!"
|
||||
if ! is_repo "${PI_HOLE_FILES_DIR}" ; then
|
||||
echo "::: Critical Error: Core Pi-hole repo is missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
@@ -128,48 +109,86 @@ main() {
|
||||
echo "::: Pi-hole Core: up to date"
|
||||
fi
|
||||
|
||||
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
||||
web_update=true
|
||||
echo "::: Web Interface: update available"
|
||||
if FTLcheckUpdate ; then
|
||||
FTL_update=true
|
||||
echo "::: FTL: update available"
|
||||
else
|
||||
web_update=false
|
||||
echo "::: Web Interface: up to date"
|
||||
FTL_update=false
|
||||
echo "::: FTL: up to date"
|
||||
fi
|
||||
|
||||
# Logic
|
||||
# If Core up to date AND web up to date:
|
||||
# Do nothing
|
||||
# If Core up to date AND web NOT up to date:
|
||||
# Pull web repo
|
||||
# If Core NOT up to date AND web up to date:
|
||||
# pull pihole repo, run install --unattended -- reconfigure
|
||||
# if Core NOT up to date AND web NOT up to date:
|
||||
# pull pihole repo run install --unattended
|
||||
|
||||
if ! ${core_update} && ! ${web_update} ; then
|
||||
if ${FTL_update}; then
|
||||
echo ":::"
|
||||
echo "::: Everything is up to date!"
|
||||
exit 0
|
||||
|
||||
elif ! ${core_update} && ${web_update} ; then
|
||||
echo "::: FTL out of date"
|
||||
FTLdetect
|
||||
echo ":::"
|
||||
echo "::: Pi-hole Web Admin files out of date"
|
||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||
fi
|
||||
|
||||
elif ${core_update} && ! ${web_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Pi-hole core files out of date"
|
||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||
/etc/.pihole/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||
if [[ ${INSTALL_WEB} == true ]]; then
|
||||
if ! is_repo "${ADMIN_INTERFACE_DIR}" ; then
|
||||
echo "::: Critical Error: Web Admin repo is missing from system!"
|
||||
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
elif ${core_update} && ${web_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Updating Everything"
|
||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||
/etc/.pihole/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||
else
|
||||
echo "*** Update script has malfunctioned, fallthrough reached. Please contact support"
|
||||
exit 1
|
||||
if GitCheckUpdateAvail "${ADMIN_INTERFACE_DIR}" ; then
|
||||
web_update=true
|
||||
echo "::: Web Interface: update available"
|
||||
else
|
||||
web_update=false
|
||||
echo "::: Web Interface: up to date"
|
||||
fi
|
||||
|
||||
# Logic
|
||||
# If Core up to date AND web up to date:
|
||||
# Do nothing
|
||||
# If Core up to date AND web NOT up to date:
|
||||
# Pull web repo
|
||||
# If Core NOT up to date AND web up to date:
|
||||
# pull pihole repo, run install --unattended -- reconfigure
|
||||
# if Core NOT up to date AND web NOT up to date:
|
||||
# pull pihole repo run install --unattended
|
||||
|
||||
if ! ${core_update} && ! ${web_update} ; then
|
||||
if ! ${FTL_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Everything is up to date!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
elif ! ${core_update} && ${web_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Pi-hole Web Admin files out of date"
|
||||
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||
|
||||
elif ${core_update} && ! ${web_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Pi-hole core files out of date"
|
||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||
|
||||
elif ${core_update} && ${web_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Updating Pi-hole core and web admin files"
|
||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||
else
|
||||
echo "*** Update script has malfunctioned, fallthrough reached. Please contact support"
|
||||
exit 1
|
||||
fi
|
||||
else # Web Admin not installed, so only verify if core is up to date
|
||||
if ! ${core_update}; then
|
||||
if ! ${FTL_update} ; then
|
||||
echo ":::"
|
||||
echo "::: Everything is up to date!"
|
||||
exit 0
|
||||
fi
|
||||
else
|
||||
echo ":::"
|
||||
echo "::: Pi-hole core files out of date"
|
||||
getGitFiles "${PI_HOLE_FILES_DIR}" "${PI_HOLE_GIT_URL}"
|
||||
${PI_HOLE_FILES_DIR}/automated\ install/basic-install.sh --reconfigure --unattended || echo "Unable to complete update, contact Pi-hole" && exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ "${web_update}" == true ]]; then
|
||||
@@ -186,6 +205,15 @@ main() {
|
||||
echo "::: If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
||||
fi
|
||||
|
||||
if [[ ${FTL_update} == true ]]; then
|
||||
FTL_version_current="$(/usr/bin/pihole-FTL tag)"
|
||||
echo ":::"
|
||||
echo "::: FTL version is now at ${FTL_version_current}"
|
||||
start_service pihole-FTL
|
||||
enable_service pihole-FTL
|
||||
fi
|
||||
|
||||
|
||||
echo ""
|
||||
exit 0
|
||||
|
||||
|
@@ -1,74 +1,111 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# shows version numbers
|
||||
#
|
||||
# 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.
|
||||
|
||||
# Flags:
|
||||
latest=false
|
||||
current=false
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
# Variables
|
||||
DEFAULT="-1"
|
||||
PHGITDIR="/etc/.pihole/"
|
||||
WEBGITDIR="/var/www/html/admin/"
|
||||
|
||||
getLocalVersion() {
|
||||
# Get the tagged version of the local repository
|
||||
local directory="${1}"
|
||||
local version
|
||||
|
||||
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
|
||||
version=$(git describe --tags --always || \
|
||||
echo "${DEFAULT}")
|
||||
if [[ "${version}" =~ ^v ]]; then
|
||||
echo "${version}"
|
||||
elif [[ "${version}" == "${DEFAULT}" ]]; then
|
||||
echo "ERROR"
|
||||
return 1
|
||||
else
|
||||
echo "Untagged"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
getLocalHash() {
|
||||
# Get the short hash of the local repository
|
||||
local directory="${1}"
|
||||
local hash
|
||||
|
||||
cd "${directory}" || { echo "${DEFAULT}"; return 1; }
|
||||
hash=$(git rev-parse --short HEAD || \
|
||||
echo "${DEFAULT}")
|
||||
if [[ "${hash}" == "${DEFAULT}" ]]; then
|
||||
echo "ERROR"
|
||||
return 1
|
||||
else
|
||||
echo "${hash}"
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
getRemoteVersion(){
|
||||
# Get the version from the remote origin
|
||||
local daemon="${1}"
|
||||
local version
|
||||
|
||||
version=$(curl --silent --fail https://api.github.com/repos/pi-hole/${daemon}/releases/latest | \
|
||||
awk -F: '$1 ~/tag_name/ { print $2 }' | \
|
||||
tr -cd '[[:alnum:]]._-')
|
||||
if [[ "${version}" =~ ^v ]]; then
|
||||
echo "${version}"
|
||||
else
|
||||
echo "ERROR"
|
||||
return 1
|
||||
fi
|
||||
return 0
|
||||
}
|
||||
|
||||
#PHHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/pi-hole/commits/master | \
|
||||
# grep sha | \
|
||||
# head -n1 | \
|
||||
# awk -F ' ' '{ print $2 }' | \
|
||||
# tr -cd '[[:alnum:]]._-')
|
||||
|
||||
#WEBHASHLATEST=$(curl -s https://api.github.com/repos/pi-hole/AdminLTE/commits/master | \
|
||||
# grep sha | \
|
||||
# head -n1 | \
|
||||
# awk -F ' ' '{ print $2 }' | \
|
||||
# tr -cd '[[:alnum:]]._-')
|
||||
|
||||
|
||||
normalOutput() {
|
||||
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:-${DEFAULT}})"
|
||||
echo "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
||||
echo "::: Pi-hole version is $(getLocalVersion "${PHGITDIR}") (Latest version is $(getRemoteVersion pi-hole))"
|
||||
if [ -d "${WEBGITDIR}" ]; then
|
||||
echo "::: Web-Admin version is $(getLocalVersion "${WEBGITDIR}") (Latest version is $(getRemoteVersion AdminLTE))"
|
||||
fi
|
||||
}
|
||||
|
||||
webOutput() {
|
||||
for var in "$@"; do
|
||||
case "${var}" in
|
||||
"-l" | "--latest" ) latest=true;;
|
||||
"-c" | "--current" ) current=true;;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||
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 "${webVersionLatest:--1}"
|
||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||
webVersion=$(cd /var/www/html/admin/ && git describe --tags --abbrev=0)
|
||||
echo "${webVersion}"
|
||||
else
|
||||
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 "::: Web-Admin version is ${webVersion} (Latest version is ${webVersionLatest:-${DEFAULT}})"
|
||||
fi
|
||||
if [ -d "${WEBGITDIR}" ]; then
|
||||
case "${1}" in
|
||||
"-l" | "--latest" ) echo $(getRemoteVersion AdminLTE);;
|
||||
"-c" | "--current" ) echo $(getLocalVersion "${WEBGITDIR}");;
|
||||
"-h" | "--hash" ) echo $(getLocalHash "${WEBGITDIR}");;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
else
|
||||
echo "::: Web interface not installed!"; exit 1;
|
||||
fi
|
||||
}
|
||||
|
||||
coreOutput() {
|
||||
for var in "$@"; do
|
||||
case "${var}" in
|
||||
"-l" | "--latest" ) latest=true;;
|
||||
"-c" | "--current" ) current=true;;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${latest}" == true && "${current}" == false ]]; then
|
||||
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/",$//')
|
||||
echo "${piholeVersionLatest:--1}"
|
||||
elif [[ "${latest}" == false && "${current}" == true ]]; then
|
||||
piholeVersion=$(cd /etc/.pihole/ && git describe --tags --abbrev=0)
|
||||
echo "${piholeVersion}"
|
||||
else
|
||||
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/",$//')
|
||||
echo "::: Pi-hole version is ${piholeVersion} (Latest version is ${piholeVersionLatest:-${DEFAULT}})"
|
||||
fi
|
||||
case "${1}" in
|
||||
"-l" | "--latest" ) echo $(getRemoteVersion pi-hole);;
|
||||
"-c" | "--current" ) echo $(getLocalVersion "${PHGITDIR}");;
|
||||
"-h" | "--hash" ) echo $(getLocalHash "${PHGITDIR}");;
|
||||
* ) echo "::: Invalid Option!"; exit 1;
|
||||
esac
|
||||
}
|
||||
|
||||
helpFunc() {
|
||||
@@ -93,10 +130,8 @@ if [[ $# = 0 ]]; then
|
||||
normalOutput
|
||||
fi
|
||||
|
||||
for var in "$@"; do
|
||||
case "${var}" in
|
||||
"-a" | "--admin" ) shift; webOutput "$@";;
|
||||
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
esac
|
||||
done
|
||||
case "${1}" in
|
||||
"-a" | "--admin" ) shift; webOutput "$@";;
|
||||
"-p" | "--pihole" ) shift; coreOutput "$@" ;;
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
esac
|
||||
|
@@ -1,17 +1,19 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Web interface settings
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
readonly setupVars="/etc/pihole/setupVars.conf"
|
||||
readonly dnsmasqconfig="/etc/dnsmasq.d/01-pihole.conf"
|
||||
readonly dhcpconfig="/etc/dnsmasq.d/02-pihole-dhcp.conf"
|
||||
# 03 -> wildcards
|
||||
readonly dhcpstaticconfig="/etc/dnsmasq.d/04-pihole-static-dhcp.conf"
|
||||
|
||||
helpFunc() {
|
||||
cat << EOM
|
||||
@@ -25,6 +27,11 @@ helpFunc() {
|
||||
::: -f, fahrenheit Set Fahrenheit temperature unit
|
||||
::: -k, kelvin Set Kelvin temperature unit
|
||||
::: -h, --help Show this help dialog
|
||||
::: -i, interface Setup interface listening behavior of dnsmasq
|
||||
::: pihole -a -i local : Listen on all interfaces, but allow only queries from
|
||||
::: devices that are at most one hop away (local devices)
|
||||
::: pihole -a -i single : Listen only on one interface (see PIHOLE_INTERFACE)
|
||||
::: pihole -a -i all : Listen on all interfaces, permit all origins
|
||||
EOM
|
||||
exit 0
|
||||
}
|
||||
@@ -60,6 +67,13 @@ SetTemperatureUnit(){
|
||||
|
||||
}
|
||||
|
||||
HashPassword(){
|
||||
# Compute password hash twice to avoid rainbow table vulnerability
|
||||
return=$(echo -n ${1} | sha256sum | sed 's/\s.*$//')
|
||||
return=$(echo -n ${return} | sha256sum | sed 's/\s.*$//')
|
||||
echo ${return}
|
||||
}
|
||||
|
||||
SetWebPassword(){
|
||||
|
||||
if [ "${SUDO_USER}" == "www-data" ]; then
|
||||
@@ -74,30 +88,48 @@ SetWebPassword(){
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Set password only if there is one to be set
|
||||
if (( ${#args[2]} > 0 )) ; then
|
||||
# Compute password hash twice to avoid rainbow table vulnerability
|
||||
hash=$(echo -n ${args[2]} | sha256sum | sed 's/\s.*$//')
|
||||
hash=$(echo -n ${hash} | sha256sum | sed 's/\s.*$//')
|
||||
if (( ${#args[2]} > 0 )) ; then
|
||||
readonly PASSWORD="${args[2]}"
|
||||
readonly CONFIRM="${PASSWORD}"
|
||||
else
|
||||
read -s -p "Enter New Password (Blank for no password): " PASSWORD
|
||||
echo ""
|
||||
|
||||
if [ "${PASSWORD}" == "" ]; then
|
||||
change_setting "WEBPASSWORD" ""
|
||||
echo "Password Removed"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
read -s -p "Confirm Password: " CONFIRM
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [ "${PASSWORD}" == "${CONFIRM}" ] ; then
|
||||
hash=$(HashPassword ${PASSWORD})
|
||||
# Save hash to file
|
||||
change_setting "WEBPASSWORD" "${hash}"
|
||||
echo "New password set"
|
||||
else
|
||||
change_setting "WEBPASSWORD" ""
|
||||
echo "Password removed"
|
||||
echo "Passwords don't match. Your password has not been changed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
ProcessDNSSettings() {
|
||||
source "${setupVars}"
|
||||
|
||||
delete_dnsmasq_setting "server="
|
||||
add_dnsmasq_setting "server" "${PIHOLE_DNS_1}"
|
||||
delete_dnsmasq_setting "server"
|
||||
|
||||
if [[ "${PIHOLE_DNS_2}" != "" ]]; then
|
||||
add_dnsmasq_setting "server" "${PIHOLE_DNS_2}"
|
||||
fi
|
||||
COUNTER=1
|
||||
while [[ 1 ]]; do
|
||||
var=PIHOLE_DNS_${COUNTER}
|
||||
if [ -z "${!var}" ]; then
|
||||
break;
|
||||
fi
|
||||
add_dnsmasq_setting "server" "${!var}"
|
||||
let COUNTER=COUNTER+1
|
||||
done
|
||||
|
||||
delete_dnsmasq_setting "domain-needed"
|
||||
|
||||
@@ -111,32 +143,67 @@ ProcessDNSSettings() {
|
||||
add_dnsmasq_setting "bogus-priv"
|
||||
fi
|
||||
|
||||
delete_dnsmasq_setting "dnssec"
|
||||
delete_dnsmasq_setting "trust-anchor="
|
||||
|
||||
if [[ "${DNSSEC}" == true ]]; then
|
||||
echo "dnssec
|
||||
trust-anchor=.,19036,8,2,49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5
|
||||
" >> "${dnsmasqconfig}"
|
||||
fi
|
||||
|
||||
delete_dnsmasq_setting "host-record"
|
||||
|
||||
if [ ! -z "${HOSTRECORD}" ]; then
|
||||
add_dnsmasq_setting "host-record" "${HOSTRECORD}"
|
||||
fi
|
||||
|
||||
# Setup interface listening behavior of dnsmasq
|
||||
delete_dnsmasq_setting "interface"
|
||||
delete_dnsmasq_setting "local-service"
|
||||
|
||||
if [[ "${DNSMASQ_LISTENING}" == "all" ]]; then
|
||||
# Listen on all interfaces, permit all origins
|
||||
add_dnsmasq_setting "except-interface" "nonexisting"
|
||||
elif [[ "${DNSMASQ_LISTENING}" == "local" ]]; then
|
||||
# Listen only on all interfaces, but only local subnets
|
||||
add_dnsmasq_setting "local-service"
|
||||
else
|
||||
# Listen only on one interface
|
||||
add_dnsmasq_setting "interface" "${PIHOLE_INTERFACE}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
SetDNSServers(){
|
||||
|
||||
# Save setting to file
|
||||
change_setting "PIHOLE_DNS_1" "${args[2]}"
|
||||
delete_setting "PIHOLE_DNS"
|
||||
IFS=',' read -r -a array <<< "${args[2]}"
|
||||
for index in "${!array[@]}"
|
||||
do
|
||||
add_setting "PIHOLE_DNS_$((index+1))" "${array[index]}"
|
||||
done
|
||||
|
||||
if [[ "${args[3]}" != "none" ]]; then
|
||||
change_setting "PIHOLE_DNS_2" "${args[3]}"
|
||||
else
|
||||
change_setting "PIHOLE_DNS_2" ""
|
||||
fi
|
||||
|
||||
if [[ "${args[4]}" == "domain-needed" ]]; then
|
||||
if [[ "${args[3]}" == "domain-needed" ]]; then
|
||||
change_setting "DNS_FQDN_REQUIRED" "true"
|
||||
else
|
||||
change_setting "DNS_FQDN_REQUIRED" "false"
|
||||
fi
|
||||
|
||||
if [[ "${args[4]}" == "bogus-priv" || "${args[5]}" == "bogus-priv" ]]; then
|
||||
if [[ "${args[4]}" == "bogus-priv" ]]; then
|
||||
change_setting "DNS_BOGUS_PRIV" "true"
|
||||
else
|
||||
change_setting "DNS_BOGUS_PRIV" "false"
|
||||
fi
|
||||
|
||||
ProcessDnsmasqSettings
|
||||
if [[ "${args[5]}" == "dnssec" ]]; then
|
||||
change_setting "DNSSEC" "true"
|
||||
else
|
||||
change_setting "DNSSEC" "false"
|
||||
fi
|
||||
|
||||
ProcessDNSSettings
|
||||
|
||||
# Restart dnsmasq to load new configuration
|
||||
RestartDNS
|
||||
@@ -213,10 +280,13 @@ dhcp-authoritative
|
||||
dhcp-range=${DHCP_START},${DHCP_END},${leasetime}
|
||||
dhcp-option=option:router,${DHCP_ROUTER}
|
||||
dhcp-leasefile=/etc/pihole/dhcp.leases
|
||||
domain=${PIHOLE_DOMAIN}
|
||||
#quiet-dhcp
|
||||
" > "${dhcpconfig}"
|
||||
|
||||
if [[ "${PIHOLE_DOMAIN}" != "none" ]]; then
|
||||
echo "domain=${PIHOLE_DOMAIN}" >> "${dhcpconfig}"
|
||||
fi
|
||||
|
||||
if [[ "${DHCP_IPv6}" == "true" ]]; then
|
||||
echo "#quiet-dhcp6
|
||||
#enable-ra
|
||||
@@ -227,7 +297,7 @@ ra-param=*,0,0
|
||||
fi
|
||||
|
||||
else
|
||||
rm "${dhcpconfig}"
|
||||
rm "${dhcpconfig}" &> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -269,6 +339,25 @@ SetWebUILayout(){
|
||||
|
||||
}
|
||||
|
||||
CustomizeAdLists() {
|
||||
|
||||
list="/etc/pihole/adlists.list"
|
||||
|
||||
if [[ "${args[2]}" == "enable" ]] ; then
|
||||
sed -i "\\@${args[3]}@s/^#http/http/g" "${list}"
|
||||
elif [[ "${args[2]}" == "disable" ]] ; then
|
||||
sed -i "\\@${args[3]}@s/^http/#http/g" "${list}"
|
||||
elif [[ "${args[2]}" == "add" ]] ; then
|
||||
echo "${args[3]}" >> ${list}
|
||||
elif [[ "${args[2]}" == "del" ]] ; then
|
||||
var=$(echo "${args[3]}" | sed 's/\//\\\//g')
|
||||
sed -i "/${var}/Id" "${list}"
|
||||
else
|
||||
echo "Not permitted"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
SetPrivacyMode(){
|
||||
|
||||
if [[ "${args[2]}" == "true" ]] ; then
|
||||
@@ -289,6 +378,81 @@ ResolutionSettings() {
|
||||
elif [[ "${typ}" == "clients" ]]; then
|
||||
change_setting "API_GET_CLIENT_HOSTNAME" "${state}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
AddDHCPStaticAddress() {
|
||||
|
||||
mac="${args[2]}"
|
||||
ip="${args[3]}"
|
||||
host="${args[4]}"
|
||||
|
||||
if [[ "${ip}" == "noip" ]]; then
|
||||
# Static host name
|
||||
echo "dhcp-host=${mac},${host}" >> "${dhcpstaticconfig}"
|
||||
elif [[ "${host}" == "nohost" ]]; then
|
||||
# Static IP
|
||||
echo "dhcp-host=${mac},${ip}" >> "${dhcpstaticconfig}"
|
||||
else
|
||||
# Full info given
|
||||
echo "dhcp-host=${mac},${ip},${host}" >> "${dhcpstaticconfig}"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
RemoveDHCPStaticAddress() {
|
||||
|
||||
mac="${args[2]}"
|
||||
sed -i "/dhcp-host=${mac}.*/d" "${dhcpstaticconfig}"
|
||||
|
||||
}
|
||||
|
||||
SetHostRecord(){
|
||||
|
||||
if [ -n "${args[3]}" ]; then
|
||||
change_setting "HOSTRECORD" "${args[2]},${args[3]}"
|
||||
echo "Setting host record for ${args[2]} -> ${args[3]}"
|
||||
else
|
||||
change_setting "HOSTRECORD" ""
|
||||
echo "Removing host record"
|
||||
fi
|
||||
|
||||
ProcessDNSSettings
|
||||
|
||||
# Restart dnsmasq to load new configuration
|
||||
RestartDNS
|
||||
|
||||
}
|
||||
|
||||
SetListeningMode(){
|
||||
|
||||
source "${setupVars}"
|
||||
|
||||
if [[ "${args[2]}" == "all" ]] ; then
|
||||
echo "Listening on all interfaces, permiting all origins, hope you have a firewall!"
|
||||
change_setting "DNSMASQ_LISTENING" "all"
|
||||
elif [[ "${args[2]}" == "local" ]] ; then
|
||||
echo "Listening on all interfaces, permitting only origins that are at most one hop away (local devices)"
|
||||
change_setting "DNSMASQ_LISTENING" "local"
|
||||
else
|
||||
echo "Listening only on interface ${PIHOLE_INTERFACE}"
|
||||
change_setting "DNSMASQ_LISTENING" "single"
|
||||
fi
|
||||
|
||||
# Don't restart DNS server yet because other settings
|
||||
# will be applied afterwards if "-web" is set
|
||||
if [[ "${args[3]}" != "-web" ]]; then
|
||||
ProcessDNSSettings
|
||||
# Restart dnsmasq to load new configuration
|
||||
RestartDNS
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
Teleporter()
|
||||
{
|
||||
local datetimestamp=$(date "+%Y-%m-%d_%H-%M-%S")
|
||||
php /var/www/html/admin/scripts/pi-hole/php/teleporter.php > "pi-hole-teleporter_${datetimestamp}.zip"
|
||||
}
|
||||
|
||||
main() {
|
||||
@@ -312,6 +476,12 @@ main() {
|
||||
"-h" | "--help" ) helpFunc;;
|
||||
"privacymode" ) SetPrivacyMode;;
|
||||
"resolve" ) ResolutionSettings;;
|
||||
"addstaticdhcp" ) AddDHCPStaticAddress;;
|
||||
"removestaticdhcp" ) RemoveDHCPStaticAddress;;
|
||||
"hostrecord" ) SetHostRecord;;
|
||||
"-i" | "interface" ) SetListeningMode;;
|
||||
"-t" | "teleporter" ) Teleporter;;
|
||||
"adlist" ) CustomizeAdLists;;
|
||||
* ) helpFunc;;
|
||||
esac
|
||||
|
||||
|
@@ -3,7 +3,7 @@ _pihole() {
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist"
|
||||
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist checkout"
|
||||
|
||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||
return 0
|
||||
|
@@ -1,15 +1,55 @@
|
||||
<?php
|
||||
/* Detailed Pi-Hole Block Page: Show "Website Blocked" if user browses to site, but not to image/file requests based on the work of WaLLy3K for DietPi & Pi-Hole */
|
||||
/* Detailed Pi-hole Block Page: Show "Website Blocked" if user browses to site, but not to image/file requests based on the work of WaLLy3K for DietPi & Pi-Hole */
|
||||
|
||||
function validIP($address){
|
||||
if (preg_match('/[.:0]/', $address) && !preg_match('/[1-9a-f]/', $address)) {
|
||||
// Test if address contains either `:` or `0` but not 1-9 or a-f
|
||||
return false;
|
||||
}
|
||||
return !filter_var($address, FILTER_VALIDATE_IP) === false;
|
||||
}
|
||||
|
||||
$uri = escapeshellcmd($_SERVER['REQUEST_URI']);
|
||||
$serverName = escapeshellcmd($_SERVER['SERVER_NAME']);
|
||||
|
||||
// If the server name is 'pi.hole', it's likely a user trying to get to the admin panel.
|
||||
// Let's be nice and redirect them.
|
||||
if ($serverName === 'pi.hole')
|
||||
{
|
||||
header('HTTP/1.1 301 Moved Permanently');
|
||||
header("Location: /admin/");
|
||||
}
|
||||
|
||||
// Retrieve server URI extension (EG: jpg, exe, php)
|
||||
ini_set('pcre.recursion_limit',100);
|
||||
$uriExt = pathinfo($uri, PATHINFO_EXTENSION);
|
||||
|
||||
// Define which URL extensions get rendered as "Website Blocked"
|
||||
$webExt = array('asp', 'htm', 'html', 'php', 'rss', 'xml');
|
||||
|
||||
// Get IPv4 and IPv6 addresses from setupVars.conf (if available)
|
||||
$setupVars = parse_ini_file("/etc/pihole/setupVars.conf");
|
||||
$ipv4 = isset($setupVars["IPV4_ADDRESS"]) ? explode("/", $setupVars["IPV4_ADDRESS"])[0] : $_SERVER['SERVER_ADDR'];
|
||||
$ipv6 = isset($setupVars["IPV6_ADDRESS"]) ? explode("/", $setupVars["IPV6_ADDRESS"])[0] : $_SERVER['SERVER_ADDR'];
|
||||
|
||||
$AUTHORIZED_HOSTNAMES = array(
|
||||
$ipv4,
|
||||
$ipv6,
|
||||
str_replace(array("[","]"), array("",""), $_SERVER["SERVER_ADDR"]),
|
||||
"pi.hole",
|
||||
"localhost");
|
||||
// Allow user set virtual hostnames
|
||||
$virtual_host = getenv('VIRTUAL_HOST');
|
||||
if (!empty($virtual_host))
|
||||
array_push($AUTHORIZED_HOSTNAMES, $virtual_host);
|
||||
|
||||
// Immediately quit since we didn't block this page (the IP address or pi.hole is explicitly requested)
|
||||
if(validIP($serverName) || in_array($serverName,$AUTHORIZED_HOSTNAMES))
|
||||
{
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
if(in_array($uriExt, $webExt) || empty($uriExt))
|
||||
{
|
||||
// Requested resource has an extension listed in $webExt
|
||||
@@ -37,7 +77,7 @@ if (!$showPage)
|
||||
die();
|
||||
}
|
||||
|
||||
// Get Pi-Hole version
|
||||
// Get Pi-hole version
|
||||
$piHoleVersion = exec('cd /etc/.pihole/ && git describe --tags --abbrev=0');
|
||||
|
||||
// Don't show the URI if it is the root directory
|
||||
@@ -48,6 +88,7 @@ if($uri == "/")
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='UTF-8'/>
|
||||
<title>Website Blocked</title>
|
||||
@@ -74,7 +115,9 @@ if($uri == "/")
|
||||
<a class='safe33' id="whitelisting">Whitelist this page</a>
|
||||
<a class='safe33' href='javascript:window.close()'>Close window</a>
|
||||
</div>
|
||||
<div style="width: 98%; text-align: center; padding: 10px;" hidden="true" id="whitelistingform">Password required!<br/>
|
||||
<div style="width: 98%; text-align: center; padding: 10px;" hidden="true" id="whitelistingform">
|
||||
<p>Note that whitelisting domains which are blocked using the wildcard method won't work.</p>
|
||||
<p>Password required!</p><br/>
|
||||
<form>
|
||||
<input name="list" type="hidden" value="white"><br/>
|
||||
Domain:<br/>
|
||||
@@ -88,6 +131,16 @@ if($uri == "/")
|
||||
</main>
|
||||
<footer>Generated <?php echo date('D g:i A, M d'); ?> by Pi-hole <?php echo $piHoleVersion; ?></footer>
|
||||
<script src="http://pi.hole/admin/scripts/vendor/jquery.min.js"></script>
|
||||
<script>
|
||||
// Create event for when the output is appended to
|
||||
(function($) {
|
||||
var origAppend = $.fn.append;
|
||||
|
||||
$.fn.append = function () {
|
||||
return origAppend.apply(this, arguments).trigger("append");
|
||||
};
|
||||
})(jQuery);
|
||||
</script>
|
||||
<script src="http://pi.hole/admin/scripts/pi-hole/js/queryads.js"></script>
|
||||
<script>
|
||||
function inIframe () {
|
||||
@@ -115,6 +168,15 @@ else
|
||||
|
||||
$( "#whitelisting" ).on( "click", function(){ $( "#whitelistingform" ).removeAttr( "hidden" ); });
|
||||
|
||||
// Remove whitelist functionality if the domain was blocked because of a wildcard
|
||||
$( "#output" ).bind("append", function(){
|
||||
if($( "#output" ).contents()[0].data.indexOf("Wildcard blocking") !== -1)
|
||||
{
|
||||
$( "#whitelisting" ).hide();
|
||||
$( "#whitelistingform" ).hide();
|
||||
}
|
||||
});
|
||||
|
||||
function add() {
|
||||
var domain = $("#domain");
|
||||
var pw = $("#pw");
|
||||
|
@@ -1,13 +1,21 @@
|
||||
# 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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# lighttpd config for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
# FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE. #
|
||||
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
|
||||
# #
|
||||
# CHANGES SHOULD BE MADE IN A SEPERATE CONFIG FILE: #
|
||||
# /etc/lighttpd/external.conf #
|
||||
###############################################################################
|
||||
|
||||
server.modules = (
|
||||
"mod_access",
|
||||
@@ -21,15 +29,15 @@ server.modules = (
|
||||
)
|
||||
|
||||
server.document-root = "/var/www/html"
|
||||
server.error-handler-404 = "pihole/index.php"
|
||||
server.error-handler-404 = "pihole/index.php"
|
||||
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
|
||||
server.errorlog = "/var/log/lighttpd/error.log"
|
||||
server.pid-file = "/var/run/lighttpd.pid"
|
||||
server.username = "www-data"
|
||||
server.groupname = "www-data"
|
||||
server.port = 80
|
||||
accesslog.filename = "/var/log/lighttpd/access.log"
|
||||
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
||||
accesslog.filename = "/var/log/lighttpd/access.log"
|
||||
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
||||
|
||||
|
||||
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
|
||||
@@ -62,5 +70,12 @@ $HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||
}
|
||||
|
||||
# Entering just "pi.hole" into a browser redirects to "pi.hole/admin/"
|
||||
$HTTP["host"] == "pi.hole" {
|
||||
$HTTP["url"] == "/" {
|
||||
url.redirect = ( "" => "/admin/" )
|
||||
}
|
||||
}
|
||||
|
||||
# Add user chosen options held in external file
|
||||
include_shell "cat external.conf 2>/dev/null"
|
||||
|
@@ -1,13 +1,21 @@
|
||||
# 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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# lighttpd config for Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
###############################################################################
|
||||
# FILE AUTOMATICALLY OVERWRITTEN BY PI-HOLE INSTALL/UPDATE PROCEDURE. #
|
||||
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
|
||||
# #
|
||||
# CHANGES SHOULD BE MADE IN A SEPERATE CONFIG FILE: #
|
||||
# /etc/lighttpd/external.conf #
|
||||
###############################################################################
|
||||
|
||||
server.modules = (
|
||||
"mod_access",
|
||||
@@ -22,15 +30,15 @@ server.modules = (
|
||||
)
|
||||
|
||||
server.document-root = "/var/www/html"
|
||||
server.error-handler-404 = "pihole/index.php"
|
||||
server.error-handler-404 = "pihole/index.php"
|
||||
server.upload-dirs = ( "/var/cache/lighttpd/uploads" )
|
||||
server.errorlog = "/var/log/lighttpd/error.log"
|
||||
server.pid-file = "/var/run/lighttpd.pid"
|
||||
server.username = "lighttpd"
|
||||
server.groupname = "lighttpd"
|
||||
server.port = 80
|
||||
accesslog.filename = "/var/log/lighttpd/access.log"
|
||||
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
||||
accesslog.filename = "/var/log/lighttpd/access.log"
|
||||
accesslog.format = "%{%s}t|%V|%r|%s|%b"
|
||||
|
||||
|
||||
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
|
||||
@@ -79,5 +87,12 @@ $HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||
}
|
||||
|
||||
# Entering just "pi.hole" into a browser redirects to "pi.hole/admin/"
|
||||
$HTTP["host"] == "pi.hole" {
|
||||
$HTTP["url"] == "/" {
|
||||
url.redirect = ( "" => "/admin/" )
|
||||
}
|
||||
}
|
||||
|
||||
# Add user chosen options held in external file
|
||||
include_shell "cat external.conf 2>/dev/null"
|
||||
|
10
advanced/logrotate
Normal file
10
advanced/logrotate
Normal file
@@ -0,0 +1,10 @@
|
||||
/var/log/pihole.log {
|
||||
# su #
|
||||
daily
|
||||
copytruncate
|
||||
rotate 5
|
||||
compress
|
||||
delaycompress
|
||||
notifempty
|
||||
nomail
|
||||
}
|
80
advanced/pihole-FTL.service
Normal file
80
advanced/pihole-FTL.service
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: pihole-FTL
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: pihole-FTL daemon
|
||||
# Description: Enable service provided by pihole-FTL daemon
|
||||
### END INIT INFO
|
||||
|
||||
FTLUSER=pihole
|
||||
PIDFILE=/var/run/pihole-FTL.pid
|
||||
|
||||
get_pid() {
|
||||
pidof "pihole-FTL"
|
||||
}
|
||||
|
||||
is_running() {
|
||||
ps "$(get_pid)" > /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Start the service
|
||||
start() {
|
||||
if is_running; then
|
||||
echo "pihole-FTL is already running"
|
||||
else
|
||||
touch /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port
|
||||
chown pihole:pihole /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port
|
||||
chmod 0644 /var/log/pihole-FTL.log /run/pihole-FTL.pid /run/pihole-FTL.port
|
||||
su -s /bin/sh -c "/usr/bin/pihole-FTL" "$FTLUSER"
|
||||
echo
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop the service
|
||||
stop() {
|
||||
if is_running; then
|
||||
kill "$(get_pid)"
|
||||
for i in {1..5}; do
|
||||
if ! is_running; then
|
||||
break
|
||||
fi
|
||||
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
echo
|
||||
|
||||
if is_running; then
|
||||
echo "Not stopped; may still be shutting down or shutdown may have failed, killing now"
|
||||
kill -9 "$(get_pid)"
|
||||
exit 1
|
||||
else
|
||||
echo "Stopped"
|
||||
fi
|
||||
else
|
||||
echo "Not running"
|
||||
fi
|
||||
echo
|
||||
}
|
||||
|
||||
### main logic ###
|
||||
case "$1" in
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
status)
|
||||
status pihole-FTL
|
||||
;;
|
||||
start|restart|reload|condrestart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|reload|status}"
|
||||
exit 1
|
||||
esac
|
||||
|
||||
exit 0
|
@@ -1,13 +1,13 @@
|
||||
# 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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Updates ad sources every week
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
#
|
||||
#
|
||||
#
|
||||
# This file is under source-control of the Pi-hole installation and update
|
||||
# scripts, any changes made to this file will be overwritten when the softare
|
||||
@@ -23,4 +23,7 @@
|
||||
|
||||
# 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
|
||||
# The flush script will use logrotate if available
|
||||
00 00 * * * root PATH="$PATH:/usr/local/bin/" pihole flush
|
||||
|
||||
@reboot root /usr/sbin/logrotate /etc/pihole/logrotate
|
||||
|
@@ -1,11 +1,9 @@
|
||||
# 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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Allows the WebUI to use Pi-hole commands
|
||||
#
|
||||
# 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.
|
||||
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
#
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -1,14 +1,14 @@
|
||||
#!/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Completely uninstalls Pi-hole
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
# Must be root to uninstall
|
||||
if [[ ${EUID} -eq 0 ]]; then
|
||||
@@ -154,7 +154,7 @@ removeNoPurge() {
|
||||
${SUDO} rm /usr/local/bin/pihole &> /dev/null
|
||||
${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null
|
||||
${SUDO} rm /etc/sudoers.d/pihole &> /dev/null
|
||||
|
||||
|
||||
# If the pihole user exists, then remove
|
||||
if id "pihole" >/dev/null 2>&1; then
|
||||
echo "::: Removing pihole user..."
|
||||
@@ -164,7 +164,7 @@ removeNoPurge() {
|
||||
echo ":::"
|
||||
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||
printf "::: Reach out to us at https://github.com/pi-hole/pi-hole/issues if you need help\n"
|
||||
printf "::: Reinstall by simpling running\n:::\n:::\tcurl -L https://install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n"
|
||||
printf "::: Reinstall by simpling running\n:::\n:::\tcurl -sSL https://install.pi-hole.net | bash\n:::\n::: at any time!\n:::\n"
|
||||
printf "::: PLEASE RESET YOUR DNS ON YOUR ROUTER/CLIENTS TO RESTORE INTERNET CONNECTIVITY!\n"
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ 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
|
||||
case ${yn} in
|
||||
[Yy]* ) removeAndPurge; break;;
|
||||
|
||||
|
||||
[Nn]* ) removeNoPurge; break;;
|
||||
esac
|
||||
done
|
||||
|
113
gravity.sh
113
gravity.sh
@@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env bash
|
||||
# Pi-hole: A black hole for Internet advertisements
|
||||
# (c) 2015 by Jacob Salmela
|
||||
# Network-wide ad blocking via your Raspberry Pi
|
||||
# http://pi-hole.net
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Compiles a list of ad-serving domains by downloading them from multiple sources
|
||||
#
|
||||
# Pi-hole is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
|
||||
|
||||
# Run this script as root or under sudo
|
||||
echo ":::"
|
||||
@@ -26,12 +26,15 @@ EOM
|
||||
exit 0
|
||||
}
|
||||
|
||||
PIHOLE_COMMAND="/usr/local/bin/pihole"
|
||||
|
||||
adListFile=/etc/pihole/adlists.list
|
||||
adListDefault=/etc/pihole/adlists.default
|
||||
whitelistScript="pihole -w"
|
||||
adListDefault=/etc/pihole/adlists.default #being deprecated
|
||||
adListRepoDefault=/etc/.pihole/adlists.default
|
||||
whitelistScript="${PIHOLE_COMMAND} -w"
|
||||
whitelistFile=/etc/pihole/whitelist.txt
|
||||
blacklistFile=/etc/pihole/blacklist.txt
|
||||
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
|
||||
#Source the setupVars from install script for the IP
|
||||
setupVars=/etc/pihole/setupVars.conf
|
||||
@@ -69,36 +72,34 @@ fi
|
||||
###########################
|
||||
# collapse - begin formation of pihole
|
||||
gravity_collapse() {
|
||||
|
||||
#New Logic:
|
||||
# Does /etc/pihole/adlists.list exist? If so leave it alone
|
||||
# If not, cp /etc/.pihole/adlists.default /etc/pihole/adlists.list
|
||||
# Read from adlists.list
|
||||
|
||||
#The following two blocks will sort out any missing adlists in the /etc/pihole directory, and remove legacy adlists.default
|
||||
if [ -f ${adListDefault} ] && [ -f ${adListFile} ]; then
|
||||
rm ${adListDefault}
|
||||
fi
|
||||
|
||||
if [ ! -f ${adListFile} ]; then
|
||||
cp ${adListRepoDefault} ${adListFile}
|
||||
fi
|
||||
|
||||
echo "::: Neutrino emissions detected..."
|
||||
echo ":::"
|
||||
#Decide if we're using a custom ad block list, or defaults.
|
||||
if [ -f ${adListFile} ]; then
|
||||
#custom file found, use this instead of default
|
||||
echo -n "::: Custom adList file detected. Reading..."
|
||||
sources=()
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||
echo "" > /dev/null
|
||||
else
|
||||
sources+=(${line})
|
||||
fi
|
||||
done < ${adListFile}
|
||||
echo " done!"
|
||||
else
|
||||
#no custom file found, use defaults!
|
||||
echo -n "::: No custom adlist file detected, reading from default file..."
|
||||
sources=()
|
||||
while read -r line; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||
echo "" > /dev/null
|
||||
else
|
||||
sources+=(${line})
|
||||
fi
|
||||
done < ${adListDefault}
|
||||
echo " done!"
|
||||
fi
|
||||
echo -n "::: Pulling source lists into range..."
|
||||
sources=()
|
||||
while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
#Do not read commented out or blank lines
|
||||
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||
echo "" > /dev/null
|
||||
else
|
||||
sources+=(${line})
|
||||
fi
|
||||
done < ${adListFile}
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
# patternCheck - check to see if curl downloaded any new files.
|
||||
@@ -167,6 +168,10 @@ gravity_transport() {
|
||||
# Process result
|
||||
gravity_patternCheck "${patternBuffer}" ${success} "${err}"
|
||||
|
||||
# Delete temp file if it hasn't been moved
|
||||
if [[ -f "${patternBuffer}" ]]; then
|
||||
rm "${patternBuffer}"
|
||||
fi
|
||||
}
|
||||
|
||||
# spinup - main gravity function
|
||||
@@ -182,22 +187,26 @@ gravity_spinup() {
|
||||
saveLocation=${piholeDir}/list.${i}.${domain}.${justDomainsExtension}
|
||||
activeDomains[$i]=${saveLocation}
|
||||
|
||||
agent="Mozilla/10.0"
|
||||
agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2227.0 Safari/537.36"
|
||||
|
||||
# Use a case statement to download lists that need special cURL commands
|
||||
# to complete properly and reset the user agent when required
|
||||
case "${domain}" in
|
||||
"adblock.mahakala.is")
|
||||
"adblock.mahakala.is")
|
||||
agent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
||||
cmd_ext="-e http://forum.xda-developers.com/"
|
||||
;;
|
||||
|
||||
"adaway.org")
|
||||
agent='Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
||||
;;
|
||||
|
||||
"pgl.yoyo.org")
|
||||
cmd_ext="-d mimetype=plaintext -d hostformat=hosts"
|
||||
;;
|
||||
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
# Default is a simple request
|
||||
*) cmd_ext=""
|
||||
esac
|
||||
if [[ "${skipDownload}" == false ]]; then
|
||||
echo -n "::: Getting $domain list..."
|
||||
@@ -235,6 +244,21 @@ gravity_Blacklist() {
|
||||
|
||||
}
|
||||
|
||||
gravity_Wildcard() {
|
||||
# Return number of wildcards in output - don't actually handle wildcards
|
||||
if [[ -f "${wildcardlist}" ]]; then
|
||||
numWildcards=$(grep -c ^ "${wildcardlist}")
|
||||
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
||||
let numWildcards/=2
|
||||
fi
|
||||
plural=; [[ "$numWildcards" != "1" ]] && plural=s
|
||||
echo "::: Wildcard blocked domain${plural}: $numWildcards"
|
||||
else
|
||||
echo "::: No wildcards used!"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
gravity_Whitelist() {
|
||||
#${piholeDir}/${eventHorizon})
|
||||
echo ":::"
|
||||
@@ -369,7 +393,7 @@ gravity_reload() {
|
||||
#Now replace the line in dnsmasq file
|
||||
# sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||
|
||||
pihole restartdns
|
||||
"${PIHOLE_COMMAND}" restartdns
|
||||
echo " done!"
|
||||
}
|
||||
|
||||
@@ -387,8 +411,6 @@ if [[ "${forceGrav}" == true ]]; then
|
||||
echo " done!"
|
||||
fi
|
||||
|
||||
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
|
||||
#cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
||||
gravity_collapse
|
||||
gravity_spinup
|
||||
if [[ "${skipDownload}" == false ]]; then
|
||||
@@ -401,9 +423,10 @@ else
|
||||
fi
|
||||
gravity_Whitelist
|
||||
gravity_Blacklist
|
||||
gravity_Wildcard
|
||||
|
||||
gravity_hostFormat
|
||||
gravity_blackbody
|
||||
|
||||
gravity_reload
|
||||
pihole status
|
||||
"${PIHOLE_COMMAND}" status
|
||||
|
137
pihole
137
pihole
@@ -1,16 +1,16 @@
|
||||
#!/bin/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
|
||||
# (c) 2017 Pi-hole, LLC (https://pi-hole.net)
|
||||
# Network-wide ad blocking via your own hardware.
|
||||
#
|
||||
# Controller for all pihole scripts and functions.
|
||||
#
|
||||
# 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.
|
||||
# This file is copyright under the latest version of the EUPL.
|
||||
# Please see LICENSE file for your rights under this license.
|
||||
|
||||
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||
readonly PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||
|
||||
readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf"
|
||||
# Must be root to use this tool
|
||||
if [[ ! $EUID -eq 0 ]];then
|
||||
if [ -x "$(command -v sudo)" ];then
|
||||
@@ -38,8 +38,25 @@ blacklistFunc() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
wildcardFunc() {
|
||||
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
||||
exit 0
|
||||
}
|
||||
|
||||
debugFunc() {
|
||||
"${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh
|
||||
local automated
|
||||
local web
|
||||
|
||||
# Pull off the `debug` leaving passed call augmentation flags in $1
|
||||
shift
|
||||
if [[ "$@" == *"-a"* ]]; then
|
||||
automated="true"
|
||||
fi
|
||||
if [[ "$@" == *"-w"* ]]; then
|
||||
web="true"
|
||||
fi
|
||||
|
||||
AUTOMATED=${automated:-} WEBCALL=${web:-} "${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -63,11 +80,6 @@ updateGravityFunc() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
setupLCDFunction() {
|
||||
"${PI_HOLE_SCRIPT_DIR}"/setupLCD.sh
|
||||
exit 0
|
||||
}
|
||||
|
||||
scanList(){
|
||||
domain="${1}"
|
||||
list="${2}"
|
||||
@@ -79,20 +91,55 @@ scanList(){
|
||||
fi
|
||||
}
|
||||
|
||||
processWildcards() {
|
||||
IFS="." read -r -a array <<< "${1}"
|
||||
for (( i=${#array[@]}-1; i>=0; i-- )); do
|
||||
ar=""
|
||||
for (( j=${#array[@]}-1; j>${#array[@]}-i-2; j-- )); do
|
||||
if [[ $j == $((${#array[@]}-1)) ]]; then
|
||||
ar="${array[$j]}"
|
||||
else
|
||||
ar="${array[$j]}.${ar}"
|
||||
fi
|
||||
done
|
||||
echo "${ar}"
|
||||
done
|
||||
}
|
||||
|
||||
queryFunc() {
|
||||
domain="${2}"
|
||||
method="${3}"
|
||||
lists=( /etc/pihole/list.* /etc/pihole/blacklist.txt)
|
||||
for list in ${lists[@]}; do
|
||||
result=$(scanList ${domain} ${list} ${method})
|
||||
# Remove empty lines before couting number of results
|
||||
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||
echo "::: ${list} (${count} results)"
|
||||
if [[ ${count} > 0 ]]; then
|
||||
echo "${result}"
|
||||
if [ -e "${list}" ]; then
|
||||
result=$(scanList ${domain} ${list} ${method})
|
||||
# Remove empty lines before couting number of results
|
||||
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||
echo "::: ${list} (${count} results)"
|
||||
if [[ ${count} > 0 ]]; then
|
||||
echo "${result}"
|
||||
fi
|
||||
echo ""
|
||||
else
|
||||
echo "::: ${list} does not exist"
|
||||
echo ""
|
||||
fi
|
||||
echo ""
|
||||
done
|
||||
|
||||
# Scan for possible wildcard matches
|
||||
if [ -e "${wildcardlist}" ]; then
|
||||
local wildcards=($(processWildcards "${domain}"))
|
||||
for domain in ${wildcards[@]}; do
|
||||
result=$(scanList "\/${domain}\/" ${wildcardlist})
|
||||
# Remove empty lines before couting number of results
|
||||
count=$(sed '/^\s*$/d' <<< "$result" | wc -l)
|
||||
if [[ ${count} > 0 ]]; then
|
||||
echo "::: Wildcard blocking ${domain} (${count} results)"
|
||||
echo "${result}"
|
||||
echo ""
|
||||
fi
|
||||
done
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
@@ -232,37 +279,46 @@ tailFunc() {
|
||||
exit 0
|
||||
}
|
||||
|
||||
piholeCheckoutFunc() {
|
||||
source "${PI_HOLE_SCRIPT_DIR}"/piholeCheckout.sh
|
||||
shift
|
||||
checkout "$@"
|
||||
}
|
||||
|
||||
helpFunc() {
|
||||
cat << EOM
|
||||
::: Control all PiHole specific functions!
|
||||
::: Control all Pi-hole specific functions
|
||||
:::
|
||||
::: Usage: pihole [options]
|
||||
::: Add -h after -w (whitelist), -b (blacklist), -c (chronometer), or -a (admin) for more information on usage
|
||||
::: Add -h after -w (whitelist), -b (blacklist), -c (chronometer), or -a (admin) for more information on usage
|
||||
:::
|
||||
::: Options:
|
||||
::: -w, whitelist Whitelist domains
|
||||
::: -b, blacklist Blacklist domains
|
||||
::: -d, debug Start a debugging session if having trouble
|
||||
::: -f, flush Flush the pihole.log file
|
||||
::: -t, tail Output the last lines of the pihole.log file. Lines are appended as the file grows
|
||||
::: -up, updatePihole Update Pi-hole
|
||||
::: -w, whitelist Whitelist domain(s)
|
||||
::: -b, blacklist Blacklist domain(s) (exact match)
|
||||
::: -wild, wildcard Blacklist whole domain(s) (wildcard)
|
||||
::: -d, debug Start a debugging session
|
||||
::: Automated debugging can be enabled with '-a'.
|
||||
::: 'pihole -d -a'
|
||||
::: -f, flush Flush the 'pihole.log' file
|
||||
::: -t, tail Output the last lines of the 'pihole.log' file. Lines are appended as the file grows
|
||||
::: -up, updatePihole Update Pi-hole components
|
||||
::: -r, reconfigure Reconfigure or Repair Pi-hole
|
||||
::: -g, updateGravity Update the list of ad-serving domains
|
||||
::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it
|
||||
::: -c, chronometer Calculates stats and displays to an LCD
|
||||
::: -h, help Show this help dialog
|
||||
::: -v, version Show current versions
|
||||
::: -v, version Show installed versions of Pi-hole and Web-Admin
|
||||
::: -q, query Query the adlists for a specific domain
|
||||
::: Use pihole -q domain -exact if you want to see exact matches only
|
||||
::: 'pihole -q domain -exact' shows exact matches only
|
||||
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
||||
::: -a, admin Admin webpage options
|
||||
::: uninstall Uninstall Pi-Hole from your system :(!
|
||||
::: status Is Pi-Hole Enabled or Disabled
|
||||
::: enable Enable Pi-Hole DNS Blocking
|
||||
::: disable Disable Pi-Hole DNS Blocking
|
||||
::: Blocking can also be disabled only temporarily, e.g.,
|
||||
::: pihole disable 5m - will disable blocking for 5 minutes
|
||||
::: uninstall Uninstall Pi-hole from your system! :(
|
||||
::: status Display if Pi-hole is Enabled or Disabled
|
||||
::: enable Enable Pi-hole DNS Blocking
|
||||
::: disable Disable Pi-hole DNS Blocking
|
||||
::: Blocking can also be disabled only temporarily, e.g.,
|
||||
::: 'pihole disable 5m' - will disable blocking for 5 minutes
|
||||
::: restartdns Restart dnsmasq
|
||||
::: checkout Check out different branches
|
||||
EOM
|
||||
exit 0
|
||||
}
|
||||
@@ -275,12 +331,12 @@ fi
|
||||
case "${1}" in
|
||||
"-w" | "whitelist" ) whitelistFunc "$@";;
|
||||
"-b" | "blacklist" ) blacklistFunc "$@";;
|
||||
"-d" | "debug" ) debugFunc;;
|
||||
"-wild" | "wildcard" ) wildcardFunc "$@";;
|
||||
"-d" | "debug" ) debugFunc "$@";;
|
||||
"-f" | "flush" ) flushFunc;;
|
||||
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
||||
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||
"-h" | "help" ) helpFunc;;
|
||||
"-v" | "version" ) versionFunc "$@";;
|
||||
@@ -293,5 +349,6 @@ case "${1}" in
|
||||
"restartdns" ) restartDNS;;
|
||||
"-a" | "admin" ) webpageFunc "$@";;
|
||||
"-t" | "tail" ) tailFunc;;
|
||||
"checkout" ) piholeCheckoutFunc "$@";;
|
||||
* ) helpFunc;;
|
||||
esac
|
||||
|
@@ -1,4 +1,4 @@
|
||||
FROM debian:jessie
|
||||
FROM buildpack-deps:jessie-scm
|
||||
|
||||
ENV GITDIR /etc/.pihole
|
||||
ENV SCRIPTDIR /opt/pihole
|
||||
|
@@ -64,35 +64,365 @@ def test_setupVars_saved_to_file(Pihole):
|
||||
for k,v in SETUPVARS.iteritems():
|
||||
assert "{}={}".format(k, v) in output
|
||||
|
||||
def test_configureFirewall_firewalld_no_errors(Pihole):
|
||||
''' confirms firewalld rules are applied when appopriate '''
|
||||
mock_command('firewall-cmd', '0', Pihole)
|
||||
def test_configureFirewall_firewalld_running_no_errors(Pihole):
|
||||
''' confirms firewalld rules are applied when firewallD is running '''
|
||||
# firewallD returns 'running' as status
|
||||
mock_command('firewall-cmd', {'*':('running', 0)}, Pihole)
|
||||
# Whiptail dialog returns Ok for user prompt
|
||||
mock_command('whiptail', {'*':('', 0)}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = '::: Configuring FirewallD for httpd and dnsmasq.'
|
||||
expected_stdout = 'Configuring FirewallD for httpd and dnsmasq.'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout
|
||||
assert 'firewall-cmd --state' in firewall_calls
|
||||
assert 'firewall-cmd --permanent --add-port=80/tcp --add-port=53/tcp --add-port=53/udp' in firewall_calls
|
||||
assert 'firewall-cmd --permanent --add-service=http --add-service=dns' in firewall_calls
|
||||
assert 'firewall-cmd --reload' in firewall_calls
|
||||
|
||||
def test_configureFirewall_firewalld_disabled_no_errors(Pihole):
|
||||
''' confirms firewalld rules are not applied when firewallD is not running '''
|
||||
# firewallD returns non-running status
|
||||
mock_command('firewall-cmd', {'*':('not running', '1')}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'No active firewall detected.. skipping firewall configuration.'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
|
||||
def test_configureFirewall_firewalld_enabled_declined_no_errors(Pihole):
|
||||
''' confirms firewalld rules are not applied when firewallD is running, user declines ruleset '''
|
||||
# firewallD returns running status
|
||||
mock_command('firewall-cmd', {'*':('running', 0)}, Pihole)
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*':('', 1)}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'Not installing firewall rulesets.'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
|
||||
def test_configureFirewall_no_firewall(Pihole):
|
||||
''' confirms firewall skipped no daemon is running '''
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'No active firewall detected'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
|
||||
def test_configureFirewall_IPTables_enabled_declined_no_errors(Pihole):
|
||||
''' confirms IPTables rules are not applied when IPTables is running, user declines ruleset '''
|
||||
# iptables command exists
|
||||
mock_command('iptables', {'*':('', '0')}, Pihole)
|
||||
# modinfo returns always true (ip_tables module check)
|
||||
mock_command('modinfo', {'*':('', '0')}, Pihole)
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*':('', '1')}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'Not installing firewall rulesets.'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
|
||||
def test_configureFirewall_IPTables_enabled_rules_exist_no_errors(Pihole):
|
||||
''' confirms IPTables rules are not applied when IPTables is running and rules exist '''
|
||||
# iptables command exists and returns 0 on calls (should return 0 on iptables -C)
|
||||
mock_command('iptables', {'-S':('-P INPUT DENY', '0')}, Pihole)
|
||||
# modinfo returns always true (ip_tables module check)
|
||||
mock_command('modinfo', {'*':('', '0')}, Pihole)
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*':('', '0')}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'Installing new IPTables firewall rulesets'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
firewall_calls = Pihole.run('cat /var/log/iptables').stdout
|
||||
assert 'iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT' not in firewall_calls
|
||||
assert 'iptables -I INPUT 1 -p tcp -m tcp --dport 53 -j ACCEPT' not in firewall_calls
|
||||
assert 'iptables -I INPUT 1 -p udp -m udp --dport 53 -j ACCEPT' not in firewall_calls
|
||||
|
||||
def test_configureFirewall_IPTables_enabled_not_exist_no_errors(Pihole):
|
||||
''' confirms IPTables rules are applied when IPTables is running and rules do not exist '''
|
||||
# iptables command and returns 0 on calls (should return 1 on iptables -C)
|
||||
mock_command('iptables', {'-S':('-P INPUT DENY', '0'), '-C':('', 1), '-I':('', 0)}, Pihole)
|
||||
# modinfo returns always true (ip_tables module check)
|
||||
mock_command('modinfo', {'*':('', '0')}, Pihole)
|
||||
# Whiptail dialog returns Cancel for user prompt
|
||||
mock_command('whiptail', {'*':('', '0')}, Pihole)
|
||||
configureFirewall = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
configureFirewall
|
||||
''')
|
||||
expected_stdout = 'Installing new IPTables firewall rulesets'
|
||||
assert expected_stdout in configureFirewall.stdout
|
||||
firewall_calls = Pihole.run('cat /var/log/iptables').stdout
|
||||
assert 'iptables -I INPUT 1 -p tcp -m tcp --dport 80 -j ACCEPT' in firewall_calls
|
||||
assert 'iptables -I INPUT 1 -p tcp -m tcp --dport 53 -j ACCEPT' in firewall_calls
|
||||
assert 'iptables -I INPUT 1 -p udp -m udp --dport 53 -j ACCEPT' in firewall_calls
|
||||
|
||||
def test_installPiholeWeb_fresh_install_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed on a fresh build '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_installPiholeWeb_empty_directory_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed in an emtpy directory '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
mkdir -p /var/www/html/pihole
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
||||
assert 'index.php missing, replacing...' in installWeb.stdout
|
||||
assert 'index.js missing, replacing...' in installWeb.stdout
|
||||
assert 'blockingpage.css missing, replacing...' in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_installPiholeWeb_index_php_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
mkdir -p /var/www/html/pihole
|
||||
touch /var/www/html/pihole/index.php
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
||||
assert 'Existing index.php detected, not overwriting' in installWeb.stdout
|
||||
assert 'index.js missing, replacing...' in installWeb.stdout
|
||||
assert 'blockingpage.css missing, replacing...' in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_installPiholeWeb_index_js_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
mkdir -p /var/www/html/pihole
|
||||
touch /var/www/html/pihole/index.js
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
||||
assert 'index.php missing, replacing...' in installWeb.stdout
|
||||
assert 'Existing index.js detected, not overwriting' in installWeb.stdout
|
||||
assert 'blockingpage.css missing, replacing...' in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_installPiholeWeb_blockingpage_css_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
mkdir -p /var/www/html/pihole
|
||||
touch /var/www/html/pihole/blockingpage.css
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
||||
assert 'index.php missing, replacing...' in installWeb.stdout
|
||||
assert 'index.js missing, replacing...' in installWeb.stdout
|
||||
assert 'Existing blockingpage.css detected, not overwriting' in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_installPiholeWeb_already_populated_no_errors(Pihole):
|
||||
''' confirms all web page assets from Core repo are installed when necessary '''
|
||||
installWeb = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
mkdir -p /var/www/html/pihole
|
||||
touch /var/www/html/pihole/index.php
|
||||
touch /var/www/html/pihole/index.js
|
||||
touch /var/www/html/pihole/blockingpage.css
|
||||
installPiholeWeb
|
||||
''')
|
||||
assert 'Installing pihole custom index page...' in installWeb.stdout
|
||||
assert 'No default index.lighttpd.html file found... not backing up' not in installWeb.stdout
|
||||
assert 'Existing index.php detected, not overwriting' in installWeb.stdout
|
||||
assert 'index.php missing, replacing...' not in installWeb.stdout
|
||||
assert 'Existing index.js detected, not overwriting' in installWeb.stdout
|
||||
assert 'index.js missing, replacing...' not in installWeb.stdout
|
||||
assert 'Existing blockingpage.css detected, not overwriting' in installWeb.stdout
|
||||
assert 'blockingpage.css missing, replacing... ' not in installWeb.stdout
|
||||
web_directory = Pihole.run('ls -r /var/www/html/pihole').stdout
|
||||
assert 'index.php' in web_directory
|
||||
assert 'index.js' in web_directory
|
||||
assert 'blockingpage.css' in web_directory
|
||||
|
||||
def test_update_package_cache_success_no_errors(Pihole):
|
||||
''' confirms package cache was updated without any errors'''
|
||||
updateCache = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
update_package_cache
|
||||
''')
|
||||
assert 'Updating local cache of available packages...' in updateCache.stdout
|
||||
assert 'ERROR' not in updateCache.stdout
|
||||
assert 'done!' in updateCache.stdout
|
||||
|
||||
def test_update_package_cache_failure_no_errors(Pihole):
|
||||
''' confirms package cache was not updated'''
|
||||
mock_command('apt-get', {'update':('', '1')}, Pihole)
|
||||
updateCache = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
distro_check
|
||||
update_package_cache
|
||||
''')
|
||||
assert 'Updating local cache of available packages...' in updateCache.stdout
|
||||
assert 'ERROR' in updateCache.stdout
|
||||
assert 'done!' not in updateCache.stdout
|
||||
|
||||
def test_FTL_detect_aarch64_no_errors(Pihole):
|
||||
''' confirms only aarch64 package is downloaded for FTL engine '''
|
||||
# mock uname to return aarch64 platform
|
||||
mock_command('uname', {'-m':('aarch64', '0')}, Pihole)
|
||||
# mock ldd to respond with aarch64 shared library
|
||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-aarch64.so.1', '0')}, Pihole)
|
||||
detectPlatform = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
''')
|
||||
expected_stdout = 'Detected ARM-aarch64 architecture'
|
||||
assert expected_stdout in detectPlatform.stdout
|
||||
|
||||
def test_FTL_detect_armv6l_no_errors(Pihole):
|
||||
''' confirms only armv6l package is downloaded for FTL engine '''
|
||||
# mock uname to return armv6l platform
|
||||
mock_command('uname', {'-m':('armv6l', '0')}, Pihole)
|
||||
# mock ldd to respond with aarch64 shared library
|
||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||
detectPlatform = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
''')
|
||||
expected_stdout = 'Detected ARM-hf architecture (armv6 or lower)'
|
||||
assert expected_stdout in detectPlatform.stdout
|
||||
|
||||
def test_FTL_detect_armv7l_no_errors(Pihole):
|
||||
''' confirms only armv7l package is downloaded for FTL engine '''
|
||||
# mock uname to return armv7l platform
|
||||
mock_command('uname', {'-m':('armv7l', '0')}, Pihole)
|
||||
# mock ldd to respond with aarch64 shared library
|
||||
mock_command('ldd', {'/bin/ls':('/lib/ld-linux-armhf.so.3', '0')}, Pihole)
|
||||
detectPlatform = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
''')
|
||||
expected_stdout = 'Detected ARM-hf architecture (armv7+)'
|
||||
assert expected_stdout in detectPlatform.stdout
|
||||
|
||||
def test_FTL_detect_x86_64_no_errors(Pihole):
|
||||
''' confirms only x86_64 package is downloaded for FTL engine '''
|
||||
detectPlatform = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
''')
|
||||
expected_stdout = 'Detected x86_64 architecture'
|
||||
assert expected_stdout in detectPlatform.stdout
|
||||
|
||||
def test_FTL_detect_unknown_no_errors(Pihole):
|
||||
''' confirms only generic package is downloaded for FTL engine '''
|
||||
# mock uname to return generic platform
|
||||
mock_command('uname', {'-m':('mips', '0')}, Pihole)
|
||||
detectPlatform = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
''')
|
||||
expected_stdout = 'Not able to detect architecture (unknown: mips)'
|
||||
assert expected_stdout in detectPlatform.stdout
|
||||
|
||||
def test_FTL_download_aarch64_no_errors(Pihole):
|
||||
''' confirms only aarch64 package is downloaded for FTL engine '''
|
||||
# mock uname to return generic platform
|
||||
download_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLinstall pihole-FTL-aarch64-linux-gnu
|
||||
''')
|
||||
expected_stdout = 'done'
|
||||
assert expected_stdout in download_binary.stdout
|
||||
assert 'failed' not in download_binary.stdout
|
||||
|
||||
def test_FTL_download_unknown_fails_no_errors(Pihole):
|
||||
''' confirms unknown binary is not downloaded for FTL engine '''
|
||||
# mock uname to return generic platform
|
||||
download_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLinstall pihole-FTL-mips
|
||||
''')
|
||||
expected_stdout = 'failed'
|
||||
assert expected_stdout in download_binary.stdout
|
||||
assert 'done' not in download_binary.stdout
|
||||
|
||||
def test_FTL_binary_installed_and_responsive_no_errors(Pihole):
|
||||
''' confirms FTL binary is copied and functional in installed location '''
|
||||
installed_binary = Pihole.run('''
|
||||
source /opt/pihole/basic-install.sh
|
||||
FTLdetect
|
||||
pihole-FTL version
|
||||
''')
|
||||
expected_stdout = 'v'
|
||||
assert expected_stdout in installed_binary.stdout
|
||||
|
||||
# def test_FTL_support_files_installed(Pihole):
|
||||
# ''' confirms FTL support files are installed '''
|
||||
# support_files = Pihole.run('''
|
||||
# source /opt/pihole/basic-install.sh
|
||||
# FTLdetect
|
||||
# stat -c '%a %n' /var/log/pihole-FTL.log
|
||||
# stat -c '%a %n' /run/pihole-FTL.port
|
||||
# stat -c '%a %n' /run/pihole-FTL.pid
|
||||
# ls -lac /run
|
||||
# ''')
|
||||
# assert '644 /run/pihole-FTL.port' in support_files.stdout
|
||||
# assert '644 /run/pihole-FTL.pid' in support_files.stdout
|
||||
# assert '644 /var/log/pihole-FTL.log' in support_files.stdout
|
||||
|
||||
# Helper functions
|
||||
def mock_command(script, result, container):
|
||||
def mock_command(script, args, container):
|
||||
''' Allows for setup of commands we don't really want to have to run for real in unit tests '''
|
||||
''' TODO: support array of results that enable the results to change over multiple executions of a command '''
|
||||
full_script_path = '/usr/local/bin/{}'.format(script)
|
||||
mock_script = dedent('''\
|
||||
#!/bin/bash -e
|
||||
echo "\$0 \$@" >> /var/log/{script}
|
||||
exit {retcode}
|
||||
'''.format(script=script, retcode=result))
|
||||
case "\$1" in'''.format(script=script))
|
||||
for k, v in args.iteritems():
|
||||
case = dedent('''
|
||||
{arg})
|
||||
echo {res}
|
||||
exit {retcode}
|
||||
;;'''.format(arg=k, res=v[0], retcode=v[1]))
|
||||
mock_script += case
|
||||
mock_script += dedent('''
|
||||
esac''')
|
||||
container.run('''
|
||||
cat <<EOF> {script}\n{content}\nEOF
|
||||
chmod +x {script}
|
||||
'''.format(script=full_script_path, content=mock_script))
|
||||
rm -f /var/log/{scriptlog}'''.format(script=full_script_path, content=mock_script, scriptlog=script))
|
||||
|
||||
def run_script(Pihole, script):
|
||||
result = Pihole.run(script)
|
||||
|
Reference in New Issue
Block a user