Compare commits
978 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
bfe5506cc1 | ||
|
ffd31d8330 | ||
|
d89254fedf | ||
|
a771ddf667 | ||
|
ce2e410468 | ||
|
c1982c04ff | ||
|
9a62026830 | ||
|
d12efccd0b | ||
|
54afffed19 | ||
|
fc8fcdbece | ||
|
abd1fedc9d | ||
|
9725985037 | ||
|
754f3359ec | ||
|
4c131b8c28 | ||
|
15c674ba29 | ||
|
00aff6a906 | ||
|
c45c3a72b5 | ||
|
662d450651 | ||
|
a8897becd2 | ||
|
d0126f4454 | ||
|
fdb64a5702 | ||
|
73a80ff7dc | ||
|
a795fd698d | ||
|
2fb0dc0a4a | ||
|
5b4653cf39 | ||
|
aa8e1497a3 | ||
|
eb13d846ef | ||
|
c674a175ee | ||
|
afabf30ec6 | ||
|
420158494d | ||
|
6b7b0e0eb3 | ||
|
ad70db7e0e | ||
|
ef1ce66793 | ||
|
c364fd80b6 | ||
|
3bc5d1bae0 | ||
|
e4e34acba1 | ||
|
ff3c36a7a2 | ||
|
1e7e3259b5 | ||
|
5e53f484be | ||
|
513bc32d87 | ||
|
9355a8ad0e | ||
|
a74e48a138 | ||
|
ea5ee7b0f9 | ||
|
a4f58b0a22 | ||
|
bcf8139708 | ||
|
9b0390c9da | ||
|
e88f58c34e | ||
|
8f402f5c77 | ||
|
60054da582 | ||
|
4626b8ced5 | ||
|
cbf84c1840 | ||
|
420fb69166 | ||
|
c9c28cb59a | ||
|
4244f716e0 | ||
|
bef0a2fef0 | ||
|
c48e6c91f5 | ||
|
f082b5ba54 | ||
|
8841bdd252 | ||
|
58261098fb | ||
|
9432d3035a | ||
|
9907fc2770 | ||
|
d42caa8672 | ||
|
8117ec8e20 | ||
|
ff2783f9fc | ||
|
156a51c945 | ||
|
c72ffae4a2 | ||
|
7f3b0030ea | ||
|
9a626948f8 | ||
|
5c43df66a8 | ||
|
d0e3c546f8 | ||
|
a9cb93d801 | ||
|
ee8f29d178 | ||
|
da363070c7 | ||
|
50cf891e01 | ||
|
715838cf89 | ||
|
cd0c3f9418 | ||
|
efaee2b68b | ||
|
372c699cc6 | ||
|
8cb01cdd29 | ||
|
10982a0f45 | ||
|
d4c378ed5d | ||
|
7872f68a45 | ||
|
ec8c848106 | ||
|
3b50ce8c54 | ||
|
afabb5957b | ||
|
1eeaa01234 | ||
|
e2898217d2 | ||
|
f81dadc5d0 | ||
|
a0019d86c5 | ||
|
4348653431 | ||
|
09cfa9bb20 | ||
|
e7713a9028 | ||
|
906a1753be | ||
|
a3d519b671 | ||
|
8591f9d576 | ||
|
c10ec5548f | ||
|
684ac98c8e | ||
|
db89fa9881 | ||
|
9a80421d73 | ||
|
2ddacf40c0 | ||
|
92f4824884 | ||
|
9a2ffabc33 | ||
|
2977168da1 | ||
|
85e3f37503 | ||
|
ba015c1918 | ||
|
1556adb678 | ||
|
6bfe729112 | ||
|
c340668870 | ||
|
207422f83a | ||
|
004ba28378 | ||
|
6f38801ed8 | ||
|
1509eb7d82 | ||
|
b8d2bfc890 | ||
|
8a2ee95e4a | ||
|
bc91716082 | ||
|
a00034a6a7 | ||
|
8dc0dc4d69 | ||
|
2f4b7ce3dd | ||
|
d4f83cb1d4 | ||
|
aaab3306a8 | ||
|
2bafa2f2ac | ||
|
9ac378ae09 | ||
|
bf867bd9fd | ||
|
7fd9ff43af | ||
|
bebb569c43 | ||
|
74e33bb1a0 | ||
|
b591df55b0 | ||
|
bddf31443c | ||
|
b9e0e88fe9 | ||
|
5120d9ec33 | ||
|
0a423ffd40 | ||
|
c0886cb5c6 | ||
|
294df8690c | ||
|
fb72ac9904 | ||
|
b6639d9e7e | ||
|
74cb79252c | ||
|
6cd3c93472 | ||
|
eb63e75379 | ||
|
f98de3d5db | ||
|
fab7d60373 | ||
|
b4e5358145 | ||
|
486db1e797 | ||
|
78cb43d0dc | ||
|
870454330d | ||
|
509cfd15f2 | ||
|
2061daa902 | ||
|
629ca970a1 | ||
|
c8ad6f23a8 | ||
|
d8912fd0a7 | ||
|
925c80edd4 | ||
|
2f6afd375b | ||
|
d92646324c | ||
|
c9fe62a691 | ||
|
cb52ad3ba3 | ||
|
2ec4acfe52 | ||
|
1c64f1d0cf | ||
|
48f4f44289 | ||
|
80c19cbf7d | ||
|
c97cfde9f9 | ||
|
7b26b308ad | ||
|
4c10634d85 | ||
|
3ba7d7640f | ||
|
907995a221 | ||
|
7bf0985a57 | ||
|
3ca21d8c8a | ||
|
a3a87c8883 | ||
|
de4401823e | ||
|
3ee10f5983 | ||
|
0fc8ac8d4d | ||
|
41bb53a29f | ||
|
cdee6d55d3 | ||
|
e5a1afaa26 | ||
|
f50cbe74cb | ||
|
5dbbf91917 | ||
|
7424a29960 | ||
|
eb22ca2467 | ||
|
ddbcbe5458 | ||
|
6e54cfd2ac | ||
|
fc3d4b3def | ||
|
df55b2c516 | ||
|
4d9fb57e22 | ||
|
3ed08b5c39 | ||
|
d715471426 | ||
|
486a4929da | ||
|
aacddb745b | ||
|
924f499303 | ||
|
e863a200e8 | ||
|
bb7f8ae69d | ||
|
33b6fe72da | ||
|
733919be4a | ||
|
4333e5487b | ||
|
22ead933b6 | ||
|
d53a3af191 | ||
|
08e7b7e0ad | ||
|
68cb0782c0 | ||
|
0e5a8e0033 | ||
|
4945f33254 | ||
|
3fa05293fc | ||
|
27e5f2798d | ||
|
291ca0874a | ||
|
96f2aa1803 | ||
|
c6857501aa | ||
|
3aba1607b2 | ||
|
f667298b64 | ||
|
0f4c8d4923 | ||
|
6d2c5b2312 | ||
|
a95ce11ca6 | ||
|
808503d526 | ||
|
d4b6fb9214 | ||
|
9bce5a09f3 | ||
|
bd61f38169 | ||
|
cac9c63325 | ||
|
e6d555ac31 | ||
|
fd0dd9f54c | ||
|
88c161769d | ||
|
01bf1ae92d | ||
|
9193c71cff | ||
|
db278d81e4 | ||
|
bdad454a0d | ||
|
ac8064c754 | ||
|
736e963cef | ||
|
b191cd73a7 | ||
|
86d3ca48ae | ||
|
fd7e4f2268 | ||
|
e9475a9739 | ||
|
d4270e02e9 | ||
|
b9a263ecb2 | ||
|
4929d415a6 | ||
|
b9e1f518aa | ||
|
0caa44e979 | ||
|
ca56ca5bd8 | ||
|
a0f0dff88e | ||
|
e5cc38a210 | ||
|
6cb5bb7200 | ||
|
563696e291 | ||
|
c755b3c49e | ||
|
b9f3493dbc | ||
|
8c08e9e473 | ||
|
c2930b0ca5 | ||
|
4300759287 | ||
|
fc1854cadd | ||
|
933973b12c | ||
|
5b54b9cb11 | ||
|
d2f815bba7 | ||
|
a5a067d50f | ||
|
699e299345 | ||
|
05e114173d | ||
|
d958b3ff65 | ||
|
0d7e06a141 | ||
|
633095aee1 | ||
|
a4aeb9a1dd | ||
|
71005e1db3 | ||
|
d7d6d6f991 | ||
|
5986121cfc | ||
|
c452a4569e | ||
|
a182a208dc | ||
|
d273b4b48b | ||
|
afed7d4af0 | ||
|
b429e890ad | ||
|
2f976504e8 | ||
|
b5fc88227b | ||
|
4b7b859db9 | ||
|
f7d0de53bb | ||
|
603ec997ba | ||
|
f7266ef4c8 | ||
|
3d43e1568c | ||
|
3cf6a65da9 | ||
|
c1a3f003e8 | ||
|
3f61aea7fc | ||
|
bd68db51e0 | ||
|
b8a5ed710e | ||
|
34be601dd7 | ||
|
1d64ad1ccd | ||
|
dfb4ac0365 | ||
|
f2d7a3d26d | ||
|
6d415a7384 | ||
|
0ef8832b04 | ||
|
e42a037b7d | ||
|
fe18d69b65 | ||
|
a1a9a7fa9e | ||
|
07029f93e3 | ||
|
e99ef9c093 | ||
|
fef9ab674e | ||
|
ee37c37cab | ||
|
b636c1e1f8 | ||
|
8b9f0487c0 | ||
|
a6cbd5a2fd | ||
|
ece1667fb0 | ||
|
50bd8b4a09 | ||
|
93d91353a1 | ||
|
8dc9143b34 | ||
|
a0d9a1133c | ||
|
7740e4268c | ||
|
f36e4ba336 | ||
|
3df2ef8587 | ||
|
354309fcad | ||
|
e832bfc61e | ||
|
99057ed859 | ||
|
c47c5e466f | ||
|
edd00e8e70 | ||
|
82e7de2aaa | ||
|
b723714c0c | ||
|
a2903b6e63 | ||
|
9a1876571b | ||
|
c07d7165ab | ||
|
d695c5972f | ||
|
bbc09ed313 | ||
|
1d21b0da9a | ||
|
617a147706 | ||
|
d4dccfdb2d | ||
|
035e4bf727 | ||
|
9ec5bbd560 | ||
|
34482c5ed6 | ||
|
7d414b5628 | ||
|
d9528dfd09 | ||
|
12f5f8ba00 | ||
|
db0f3307e0 | ||
|
9c83825cb8 | ||
|
7a22471787 | ||
|
7548d9a8fe | ||
|
26789f9b36 | ||
|
b4524839bb | ||
|
6605c269cf | ||
|
c30478bf4a | ||
|
d986746ef9 | ||
|
a8fa061f2e | ||
|
72015b0226 | ||
|
f8e9726922 | ||
|
884363bd05 | ||
|
bdd240ecb6 | ||
|
04da292df9 | ||
|
85b8676b8e | ||
|
114bc13c23 | ||
|
5fef5f1ed4 | ||
|
807b60b0e6 | ||
|
fbc800e556 | ||
|
1991ee7a7d | ||
|
ffbfadbccf | ||
|
c3e2bce956 | ||
|
0c9520d7e3 | ||
|
1e7e5230cc | ||
|
f1efc97357 | ||
|
fb5ac6d6d7 | ||
|
4e7ca51beb | ||
|
d561600a31 | ||
|
024e843998 | ||
|
126f275e18 | ||
|
c65e5ff8e0 | ||
|
ef13e67572 | ||
|
7920fcbb5e | ||
|
fa36fdeb03 | ||
|
c143b5ccb4 | ||
|
05c8406fca | ||
|
69e3a45083 | ||
|
45259b6ec6 | ||
|
d6fe48112c | ||
|
dcf6e6b14d | ||
|
908697a963 | ||
|
bdaf961196 | ||
|
6bd5d9b1a4 | ||
|
beb0dae5a7 | ||
|
fad2d6b1d1 | ||
|
9cd830b6aa | ||
|
d9a16b0ff4 | ||
|
cb5c94ef5e | ||
|
85fbd66871 | ||
|
3da75d6125 | ||
|
d4a3a5c180 | ||
|
65e0fcbf10 | ||
|
e22aca49c8 | ||
|
71e3a473d6 | ||
|
c2cfc09f63 | ||
|
cbfad28f7e | ||
|
6a4a468022 | ||
|
01f10b56e8 | ||
|
90ec0a610e | ||
|
42bff1ce1b | ||
|
e3c7a1f31f | ||
|
0debbffa70 | ||
|
473b58d26d | ||
|
7e9498f04c | ||
|
300001e766 | ||
|
21fc6344bf | ||
|
a38edd891f | ||
|
794fa21137 | ||
|
977d1d1998 | ||
|
cde003bc98 | ||
|
9e4e1d1cb2 | ||
|
60142cd960 | ||
|
f9570a82cc | ||
|
36285ead57 | ||
|
13e488dace | ||
|
f169da8fd0 | ||
|
60741298b7 | ||
|
f73734acb0 | ||
|
fc360abe43 | ||
|
3996e11425 | ||
|
3a4fe3e391 | ||
|
98db002770 | ||
|
7c89b6934a | ||
|
380a19274d | ||
|
f1c1caf7bd | ||
|
e2997b8135 | ||
|
4ed6e4d016 | ||
|
ac8d24a1ce | ||
|
fc776921d5 | ||
|
55a653aca4 | ||
|
0d6a6b97f9 | ||
|
469ff45f01 | ||
|
bc077acfb8 | ||
|
4269626f5d | ||
|
8fa897aadb | ||
|
f549618d12 | ||
|
2fa47aaf31 | ||
|
b0874fb23a | ||
|
fb70fd77e8 | ||
|
01f17f9cbb | ||
|
4c853defb2 | ||
|
bd0db56ba0 | ||
|
95f0b3710d | ||
|
e0ac109dd1 | ||
|
86349527e7 | ||
|
18005ceee8 | ||
|
7653b3d088 | ||
|
911053f63f | ||
|
eb52f81a5c | ||
|
4839953328 | ||
|
aba0d93fda | ||
|
0de74c0448 | ||
|
ee927346b7 | ||
|
2f8015cbca | ||
|
f3bf7c4b38 | ||
|
e37c4d57da | ||
|
acff90c000 | ||
|
5f9e72dd71 | ||
|
be0bcb8f7d | ||
|
44c3d56439 | ||
|
519d731ddd | ||
|
119c00c22a | ||
|
12596dd697 | ||
|
cb38f5f0d7 | ||
|
b49384ffe4 | ||
|
7fb622638b | ||
|
bd0cc134bf | ||
|
476fd1f695 | ||
|
96053d13be | ||
|
c958bed418 | ||
|
2b2c240d39 | ||
|
1f0ae16216 | ||
|
b79392ba2c | ||
|
8ee98f0a4a | ||
|
82e78fb651 | ||
|
d0826b2c33 | ||
|
ff588200c0 | ||
|
5d6072524c | ||
|
07a66a70fc | ||
|
69ba8a3c2f | ||
|
a30c75ef71 | ||
|
d0b3727c5d | ||
|
6e94bf5b6d | ||
|
0f04e270a7 | ||
|
ec4f5007e7 | ||
|
21b906e0e0 | ||
|
7ebaf8e843 | ||
|
640398ced4 | ||
|
ebbe1fc236 | ||
|
aac8e45397 | ||
|
5ebfa5ecf7 | ||
|
12e041c9ef | ||
|
54913f06a3 | ||
|
44a36368a2 | ||
|
8f9ff930b3 | ||
|
e199f6db87 | ||
|
c83dd3ccd7 | ||
|
78fbafa1cd | ||
|
c0012540ed | ||
|
9ab6df0e54 | ||
|
685b775b68 | ||
|
9056a5a7b6 | ||
|
e1c56bcbfe | ||
|
15d68467a1 | ||
|
3b6ecc573e | ||
|
9427b1e594 | ||
|
3ca3eaa62c | ||
|
dda448e050 | ||
|
60873144ea | ||
|
a9d17c96be | ||
|
aaee895b2b | ||
|
7d7e17b351 | ||
|
c71a976e76 | ||
|
3623183072 | ||
|
e6bd979aeb | ||
|
266c160108 | ||
|
b5b6350cc7 | ||
|
bbcf4800de | ||
|
41056ace02 | ||
|
60a80dd678 | ||
|
0efda04920 | ||
|
8819e58882 | ||
|
28eeaf201b | ||
|
74bfcea6a8 | ||
|
16f1d7fad9 | ||
|
9aa38cf0ae | ||
|
a7fa7466fb | ||
|
3f73c61cee | ||
|
a64f4cd871 | ||
|
a41eff1276 | ||
|
b88fe572fe | ||
|
59ba6f8aec | ||
|
25343da6b7 | ||
|
60d17b97f5 | ||
|
8cb72d87e4 | ||
|
8872594ab9 | ||
|
b50584119b | ||
|
975f4f2a17 | ||
|
16e4f79f09 | ||
|
76cae20c33 | ||
|
b66f23cfd0 | ||
|
27d6e5d8cf | ||
|
ff5d5b97c3 | ||
|
ce46c4dec4 | ||
|
77e8be09a1 | ||
|
013d77488a | ||
|
29ad2496b6 | ||
|
97a013b2b7 | ||
|
77808223dc | ||
|
fc89851ce9 | ||
|
c4c6555814 | ||
|
df0087fb23 | ||
|
ef3c13fe2b | ||
|
0ad704e532 | ||
|
2220d2dab8 | ||
|
49f48e2aaa | ||
|
dce24df379 | ||
|
b59136c262 | ||
|
fb9664b636 | ||
|
5b736ae05e | ||
|
ee114b3075 | ||
|
123b16991b | ||
|
5792fc0bef | ||
|
42c93917ef | ||
|
8c0f860601 | ||
|
df30a4c0d1 | ||
|
9ce13f0035 | ||
|
3884b01503 | ||
|
a84c3adeab | ||
|
a65b784907 | ||
|
05dadad2e1 | ||
|
3a9b39b842 | ||
|
e612003293 | ||
|
a43577fa26 | ||
|
7e10dcdcf0 | ||
|
7ee1110351 | ||
|
51c4c51d9e | ||
|
fc4fe54099 | ||
|
b5b240d0be | ||
|
4c42f00a86 | ||
|
090fbd04af | ||
|
461de48625 | ||
|
9352ba6e4a | ||
|
5e883239f9 | ||
|
5ea08a2120 | ||
|
a6fa60868b | ||
|
99878ae7d6 | ||
|
26202014a2 | ||
|
f4f8b96788 | ||
|
e5ede16749 | ||
|
fbe3547129 | ||
|
23f7363c70 | ||
|
97c44042e1 | ||
|
a03caea549 | ||
|
aa23fb1d56 | ||
|
4f35aac6dd | ||
|
4418ca9e9f | ||
|
570611fc09 | ||
|
94dd5b1ebe | ||
|
74524e024d | ||
|
324e00194f | ||
|
e42b6dcc8e | ||
|
d71b799e75 | ||
|
87e7121332 | ||
|
94f6354c94 | ||
|
b79059ebdb | ||
|
07b7e8a1a6 | ||
|
7ae2fc37c0 | ||
|
4f98c1bebb | ||
|
2feec01e10 | ||
|
72b95e192e | ||
|
47aad254d8 | ||
|
bc14074d2a | ||
|
5ab5b1a190 | ||
|
b055f190f5 | ||
|
84b8953352 | ||
|
93a591d487 | ||
|
e6c0f38a7c | ||
|
d169305e5d | ||
|
f107ae4f9b | ||
|
bad7a08804 | ||
|
25cbf4cb35 | ||
|
7f179f9a58 | ||
|
5287ea8537 | ||
|
43e2aaebf0 | ||
|
e60eb66283 | ||
|
ca59b808d8 | ||
|
8a15fd44d5 | ||
|
dac2b8942e | ||
|
54a1c5b63a | ||
|
61b02bf6d3 | ||
|
9d048b2fdf | ||
|
d9e28a7422 | ||
|
1fecdf42ca | ||
|
d4bf85b67c | ||
|
7131ff27c3 | ||
|
a30f78c1c8 | ||
|
7e0afffca8 | ||
|
293c60fb9c | ||
|
f5be8b2a5e | ||
|
6772603c15 | ||
|
a22904f99b | ||
|
6710d2852f | ||
|
b157bc5cd7 | ||
|
10e1a03c76 | ||
|
d20df92e9f | ||
|
44170207ac | ||
|
9354799a26 | ||
|
33745be745 | ||
|
6a28070017 | ||
|
91b948332e | ||
|
d1a7fe2d44 | ||
|
8224ef20a4 | ||
|
a4c3464bc8 | ||
|
5966d76e9a | ||
|
c39324d11f | ||
|
8c151c62ce | ||
|
50d16d8215 | ||
|
3bbac9a5f2 | ||
|
3600fd277e | ||
|
e8bb4a7e36 | ||
|
36987cb1cc | ||
|
5382b4fa37 | ||
|
28ef8068c8 | ||
|
ca0cbd68d6 | ||
|
c281b47905 | ||
|
aca5064743 | ||
|
6f780316c4 | ||
|
4e262d81f0 | ||
|
6c2ff950ee | ||
|
7684069d0b | ||
|
73c85ae68a | ||
|
911e39ba09 | ||
|
9a421d510a | ||
|
3bc7172e5e | ||
|
1a83988e26 | ||
|
0d0fc2504a | ||
|
0d4402ee0c | ||
|
722def9362 | ||
|
6a8bef83b3 | ||
|
a9c3e2c7ba | ||
|
7fcb40739d | ||
|
5a3d319677 | ||
|
8466d0b681 | ||
|
5de179f1eb | ||
|
36e10595cc | ||
|
78c8723629 | ||
|
edd7f28104 | ||
|
dba1ab3fc0 | ||
|
3df9c48012 | ||
|
6f6450bcff | ||
|
1f34203167 | ||
|
fed20648c6 | ||
|
3fc3c5cae4 | ||
|
daa5366b57 | ||
|
ac1c299369 | ||
|
5bbb3ac49a | ||
|
014bdf911a | ||
|
874853fe18 | ||
|
274b71f8bc | ||
|
c41d543d81 | ||
|
7729ddab30 | ||
|
60c0e59a83 | ||
|
ac49e639bd | ||
|
f01b20c2af | ||
|
a0d47be088 | ||
|
521374e238 | ||
|
34806ee2c2 | ||
|
4a0d5138a1 | ||
|
e6a3758899 | ||
|
fcb7d9111e | ||
|
d907731027 | ||
|
ac8d295bb9 | ||
|
a963beb96e | ||
|
737b510116 | ||
|
47cba83450 | ||
|
21d4199a38 | ||
|
655c422c3c | ||
|
b6f8bd408f | ||
|
a3edd0b976 | ||
|
8e8efa5caf | ||
|
a41b8f62a2 | ||
|
452ee8c2df | ||
|
5ca6599ca9 | ||
|
dcedf6bfd0 | ||
|
1f4b43645b | ||
|
3d5140458b | ||
|
f16574085f | ||
|
3ed62d45f5 | ||
|
b1a7b0a186 | ||
|
ec0c68621c | ||
|
a0977af081 | ||
|
a3ef9efd2f | ||
|
d58f7c6ec9 | ||
|
d124c2c12e | ||
|
0229f70761 | ||
|
dde9281139 | ||
|
6eedfb572e | ||
|
edf81a232d | ||
|
c2cb92a0b0 | ||
|
640af300cb | ||
|
6c0c6182e9 | ||
|
05ad4445b5 | ||
|
1dd9f0747e | ||
|
150e01be8b | ||
|
95ee3216c4 | ||
|
3b5e409b38 | ||
|
eb201b614a | ||
|
162a6b8b5c | ||
|
4ec01769cb | ||
|
19b656132d | ||
|
6305c7e2ab | ||
|
04c60e8a1c | ||
|
b6ceb06a32 | ||
|
8cb2f85a08 | ||
|
7ccfb6ea88 | ||
|
531398b532 | ||
|
ec6ecf0d60 | ||
|
fdb0e31a78 | ||
|
01a9534729 | ||
|
921278c5ea | ||
|
d938f73207 | ||
|
344e63c2dc | ||
|
681144b2a3 | ||
|
e4295f5d3c | ||
|
77135ca3c7 | ||
|
29b548f07c | ||
|
cb33ef77f7 | ||
|
49ded54306 | ||
|
6c0a8a4337 | ||
|
e9a0ddf798 | ||
|
d217626318 | ||
|
4f5fcc2a37 | ||
|
ed94f4b1df | ||
|
a57b097afc | ||
|
eb42b894c4 | ||
|
af666e2209 | ||
|
2f2e746e56 | ||
|
b3e7619048 | ||
|
0121136498 | ||
|
7eb43a0b47 | ||
|
c0430a2248 | ||
|
6796b8bdad | ||
|
475d016029 | ||
|
201304e678 | ||
|
fdb104348c | ||
|
f54828352d | ||
|
cc157def63 | ||
|
8fc83655ab | ||
|
9fb549293a | ||
|
e4cc5b5b70 | ||
|
6f0b659b38 | ||
|
652bdf1518 | ||
|
f6ac0d73b4 | ||
|
ae47be0ce9 | ||
|
491c37eafe | ||
|
3ade7a8b0e | ||
|
3c7738b6d0 | ||
|
037318e2ff | ||
|
a9a499939e | ||
|
7e5bcd2ec3 | ||
|
f49ca48a22 | ||
|
9cb4e8bde8 | ||
|
95edb49bb8 | ||
|
fb69bf551e | ||
|
fe8d0f8ea8 | ||
|
acc5fa2a95 | ||
|
f2e33f8581 | ||
|
4748cdc2c9 | ||
|
2bc364023a | ||
|
3070f61e20 | ||
|
57df56dc62 | ||
|
e11ef5a7f0 | ||
|
6a17a3eeec | ||
|
66ff9a24c6 | ||
|
a3b3a7a34d | ||
|
c04b3559d0 | ||
|
e642b41b5b | ||
|
ba6881d685 | ||
|
20d8c9053b | ||
|
0749e4ed70 | ||
|
b0cc69ff80 | ||
|
02c4669e95 | ||
|
8550b76e23 | ||
|
fdf27e3d24 | ||
|
069023fca2 | ||
|
1fd6648db1 | ||
|
7a08c8b694 | ||
|
60aad3f19b | ||
|
51dcc2bc0f | ||
|
941525d1e0 | ||
|
5fb6c5b012 | ||
|
3affa73257 | ||
|
c647e27e15 | ||
|
f696ed48b3 | ||
|
73645f299a | ||
|
6aeb5f1172 | ||
|
ce8f07750f | ||
|
a32ad0dbf2 | ||
|
61ff12e8d4 | ||
|
02b0e96db8 | ||
|
e942440bb7 | ||
|
a27f1f17de | ||
|
e106ff0fef | ||
|
6f068e0b9c | ||
|
ada531c88a | ||
|
f0a2248c81 | ||
|
11f2524b9b | ||
|
b011e5f838 | ||
|
f45eb84d6b | ||
|
412c0a172d | ||
|
c1d8496b93 | ||
|
4657959790 | ||
|
2b0ba281a4 | ||
|
325a41c598 | ||
|
9b8efe1b27 | ||
|
024b741552 | ||
|
4e95f4678f | ||
|
a86b982591 | ||
|
ec8da00485 | ||
|
bcfe130d51 | ||
|
0e143f7275 | ||
|
7670b4e380 | ||
|
636a9123b8 | ||
|
caaee40889 | ||
|
1f130b6550 | ||
|
2ce47f49b1 | ||
|
0250e03b86 | ||
|
ce110aab90 | ||
|
fd92752f52 | ||
|
3c4a305976 | ||
|
791e5bbd55 | ||
|
46df6e7dd3 | ||
|
9ccf9d57a8 | ||
|
fa89bd830a | ||
|
3ba05d0274 | ||
|
0d9a8d70bf | ||
|
5c79184d3b | ||
|
3d619d9ccc | ||
|
afdf3ae7a1 | ||
|
943f7c06b5 | ||
|
27a9642090 | ||
|
d0b6ff2d08 | ||
|
97737ee9e3 | ||
|
5e27ccc37c | ||
|
682113892a | ||
|
376eb81181 | ||
|
4fc40d96d9 | ||
|
e6634531c7 | ||
|
66724826f5 | ||
|
04e375a523 | ||
|
65638973ea | ||
|
9c26bdd676 | ||
|
b31931c907 | ||
|
c74af2c21f | ||
|
c160b2e54b | ||
|
c4234f4542 | ||
|
62fa9c0f6e | ||
|
8198f06073 | ||
|
6f2117d786 | ||
|
b3ec3b487c | ||
|
d67957d015 | ||
|
94f131a0b7 | ||
|
7af0029175 | ||
|
f4228b04f8 | ||
|
ffaf243160 | ||
|
29d48bbd9a | ||
|
37dda79db2 | ||
|
063e3e85e1 | ||
|
42afaa9f66 | ||
|
366fcf76f6 | ||
|
72e8ec7d93 | ||
|
13a479a9f6 | ||
|
1194e48bd8 | ||
|
1e0666d1ef | ||
|
1c53ad6876 | ||
|
dc2a537f6b | ||
|
a5d3022e9f | ||
|
4541da1f17 | ||
|
a16cd9aef7 | ||
|
6cf446032f | ||
|
3fda2d9ac3 | ||
|
c03268707a | ||
|
7829e907c9 | ||
|
b5529e5138 | ||
|
d601afcebc | ||
|
892a90bf51 | ||
|
d52a8f08ed | ||
|
b7e27bf6b4 | ||
|
9ee96d6176 | ||
|
c0e1772e21 | ||
|
62dc160c65 | ||
|
f03303e5aa | ||
|
7bc2844b9d | ||
|
ba283755be | ||
|
2209beff8a | ||
|
00cc480bc1 | ||
|
d7de5b2afa | ||
|
221b72439b | ||
|
08e6f60941 | ||
|
10066209e7 | ||
|
08e95ed606 | ||
|
a5ad48aa18 | ||
|
81fdfcba22 | ||
|
24de6d6fc9 | ||
|
aec6fcd00b | ||
|
619082dbed | ||
|
09cdf5081c | ||
|
d7abbbfac4 | ||
|
c714196647 | ||
|
b702c1d9a8 | ||
|
56ac04c48e | ||
|
b58519b974 | ||
|
ad574f5e90 | ||
|
4941a657bf | ||
|
3d4bff9414 | ||
|
2d03616c10 | ||
|
fcb9ba08a8 | ||
|
77f4126f9b | ||
|
4c890ab202 | ||
|
d10e9b1b6e | ||
|
a6bee76581 | ||
|
2f4f5a6ad2 | ||
|
3853997295 | ||
|
76899c9ac5 | ||
|
99a5b3a98a | ||
|
219aff9a93 | ||
|
b6e1b3bff0 | ||
|
1ce888e828 | ||
|
1c10a801dc | ||
|
48fa83c9ac | ||
|
31ea3a2757 | ||
|
05e0003555 | ||
|
be79281418 | ||
|
01f53f6d6c | ||
|
107e0404de | ||
|
ab99e80333 | ||
|
3154a378a6 | ||
|
8e04f1c03e | ||
|
c0aadeab3d | ||
|
6c87698f1a | ||
|
db2e9f8bf3 | ||
|
9a4c5cef86 | ||
|
bdfc86f850 | ||
|
70dadfba28 | ||
|
01e1e34874 | ||
|
28a3cbfa87 | ||
|
0b480c2d3f | ||
|
391dea445a | ||
|
e074c72130 | ||
|
96f3f863e5 | ||
|
3877f6fd94 | ||
|
cbbc6df05a | ||
|
32ff7fb321 | ||
|
5537e57eec | ||
|
9c94af04cc | ||
|
3f0b15902d | ||
|
4d3835dde2 | ||
|
8514f42d0d | ||
|
834bf30a10 | ||
|
22ea384ac8 |
38
.gitattributes
vendored
Normal file
38
.gitattributes
vendored
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
# FROM https://github.com/libgit2/libgit2sharp
|
||||||
|
# Text files that should be normalized to LF in odb.
|
||||||
|
*.cs text diff=csharp
|
||||||
|
*.config text
|
||||||
|
|
||||||
|
*.sln text
|
||||||
|
*.csproj text
|
||||||
|
|
||||||
|
*.md text
|
||||||
|
*.sh text
|
||||||
|
*.ps1 text
|
||||||
|
*.cmd text
|
||||||
|
*.bat text
|
||||||
|
*.markdown text
|
||||||
|
*.msbuild text
|
||||||
|
|
||||||
|
Lib/* binary
|
||||||
|
GitHub.Tests.Integration/Resources/* binary
|
||||||
|
|
||||||
|
|
||||||
|
# Binary files that should not be normalized or diffed
|
||||||
|
*.png binary
|
||||||
|
*.jpg binary
|
||||||
|
*.gif binary
|
||||||
|
|
||||||
|
*.pfx binary
|
||||||
|
*.snk binary
|
||||||
|
*.dll binary
|
||||||
|
*.exe binary
|
||||||
|
*.lib binary
|
||||||
|
*.exp binary
|
||||||
|
*.pdb binary
|
||||||
|
*.sdf binary
|
||||||
|
*.7z binary
|
||||||
|
|
||||||
|
|
||||||
|
# Catch all for anything we forgot. Add rules if you get CRLF -> LF warnings.
|
||||||
|
* text=auto
|
32
.github/ISSUE_TEMPLATE.md
vendored
32
.github/ISSUE_TEMPLATE.md
vendored
@@ -1,7 +1,33 @@
|
|||||||
##### Expected Behaviour:
|
**In raising this issue, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your issue:**
|
||||||
|
|
||||||
|
- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
|
||||||
|
- [] The issue I am reporting can be *replicated*
|
||||||
|
- [] The issue I'm reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)).
|
||||||
|
|
||||||
|
**How familiar are you with the codebase?:**
|
||||||
|
|
||||||
|
_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_
|
||||||
|
|
||||||
|
---
|
||||||
|
**[FEATURE REQUEST | QUESTION | OTHER]:**
|
||||||
|
|
||||||
|
Please [submit your feature request here](https://discourse.pi-hole.net/c/feature-requests), so it is votable by the community. It's also easier for us to track.
|
||||||
|
|
||||||
|
**[BUG | ISSUE] Expected Behaviour:**
|
||||||
|
|
||||||
|
|
||||||
##### Actual Behaviour:
|
**[BUG | ISSUE] Actual Behaviour:**
|
||||||
|
|
||||||
|
|
||||||
##### Steps to reproduce this issue:
|
**[BUG | ISSUE] Steps to reproduce:**
|
||||||
|
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
**(Optional) Debug token generated by `pihole -d`:**
|
||||||
|
|
||||||
|
`<token>`
|
||||||
|
|
||||||
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
20
.github/PULL_REQUEST_TEMPLATE.md
vendored
20
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -1,11 +1,19 @@
|
|||||||
Fixes #[issue number] .
|
**By submitting this pull request, I confirm the following (please check boxes, eg [X]) _Failure to fill the template will close your PR_:**
|
||||||
|
|
||||||
Changes proposed in this pull request:
|
***Please submit all pull requests against the `development` branch. Failure to do so will delay or deny your request***
|
||||||
|
|
||||||
-
|
- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md).
|
||||||
|
- [] I have checked that [another pull request](https://github.com/pi-hole/pi-hole/pulls) for this purpose does not exist.
|
||||||
|
- [] I have considered, and confirmed that this submission will be valuable to others.
|
||||||
|
- [] I accept that this submission may not be used, and the pull request closed at the will of the maintainer.
|
||||||
|
- [] I give this submission freely, and claim no ownership to its content.
|
||||||
|
|
||||||
-
|
**How familiar are you with the codebase?:**
|
||||||
|
|
||||||
-
|
_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_
|
||||||
|
|
||||||
@pi-hole/gravity
|
---
|
||||||
|
_{replace this line with your pull request content}_
|
||||||
|
|
||||||
|
|
||||||
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1 +1,7 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
__pycache__
|
||||||
|
.cache
|
||||||
|
.pullapprove.yml
|
||||||
|
|
||||||
|
22
.idea/codeStyleSettings.xml
generated
Normal file
22
.idea/codeStyleSettings.xml
generated
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<?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>
|
||||||
|
</option>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</component>
|
||||||
|
</project>
|
38
.pullapprove.yml
Normal file
38
.pullapprove.yml
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
version: 2
|
||||||
|
|
||||||
|
always_pending:
|
||||||
|
title_regex: '(WIP|wip)'
|
||||||
|
labels:
|
||||||
|
- wip
|
||||||
|
explanation: 'This PR is a work in progress...'
|
||||||
|
|
||||||
|
group_defaults:
|
||||||
|
reset_on_push:
|
||||||
|
enabled: true
|
||||||
|
reject_value: -2
|
||||||
|
approve_regex: '^(Approved|:shipit:|:\+1:|Engage)'
|
||||||
|
reject_regex: '^(Rejected|:-1:|Borg)'
|
||||||
|
author_approval:
|
||||||
|
auto: true
|
||||||
|
|
||||||
|
|
||||||
|
groups:
|
||||||
|
development:
|
||||||
|
approve_by_comment:
|
||||||
|
enabled: true
|
||||||
|
conditions:
|
||||||
|
branches:
|
||||||
|
- development
|
||||||
|
required: 2
|
||||||
|
teams:
|
||||||
|
- approvers
|
||||||
|
|
||||||
|
master:
|
||||||
|
approve_by_comment:
|
||||||
|
enabled: true
|
||||||
|
conditions:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
required: -1
|
||||||
|
teams:
|
||||||
|
- admin
|
10
.travis.yml
Normal file
10
.travis.yml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
sudo: required
|
||||||
|
services:
|
||||||
|
- docker
|
||||||
|
language: python
|
||||||
|
python:
|
||||||
|
- "2.7"
|
||||||
|
install:
|
||||||
|
- pip install -r requirements.txt
|
||||||
|
|
||||||
|
script: py.test -vv
|
@@ -1,8 +1,38 @@
|
|||||||
This is a basic checklist for now, We will update it in the future.
|
_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._
|
||||||
|
|
||||||
* Fork the repo and create your new branch based on the `development` branch.
|
# Contributors Guide
|
||||||
* Commit Unix line endings
|
|
||||||
* If you want, try to keep to the theme of black holes/gravity. This can add some fun to your submission.
|
Please read and understand the contribution guide before creating an issue or pull request.
|
||||||
* Submit Pull Requests to the development branch only.
|
|
||||||
* Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
## Etiquette
|
||||||
* Be patient. We will review all submitted pull requests, but our focus is on stability.. please don't be offended if we reject your PR, or it appears we're doing nothing with it! We'll get around to it..
|
|
||||||
|
- Our goal for Pi-hole is **stability before features**. This means we focus on squashing critical bugs before adding new features. Often, we can do both in tandem, but bugs will take priority over a new feature.
|
||||||
|
- Pi-hole is open source and [powered by donations](https://pi-hole.net/donate/), and as such, we give our **free time** to build, maintain, and **provide user support** for this project. It would be extremely unfair for us to suffer abuse or anger for our hard work, so please take a moment to consider that.
|
||||||
|
- Please be considerate towards the developers and other users when raising issues or presenting pull requests.
|
||||||
|
- Respect our decision(s), and do not be upset or abusive if your submission is not used.
|
||||||
|
|
||||||
|
## Viability
|
||||||
|
|
||||||
|
When requesting or submitting new features, first consider whether it might be useful to others. Open source projects are used by many people, who may have entirely different needs to your own. Think about whether or not your feature is likely to be used by other users of the project.
|
||||||
|
|
||||||
|
## Procedure
|
||||||
|
|
||||||
|
**Before filing an issue:**
|
||||||
|
|
||||||
|
- Attempt to replicate and **document** the problem, to ensure that it wasn't a coincidental incident.
|
||||||
|
- Check to make sure your feature suggestion isn't already present within the project.
|
||||||
|
- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
|
||||||
|
- Check the pull requests tab to ensure that the feature isn't already in progress.
|
||||||
|
|
||||||
|
**Before submitting a pull request:**
|
||||||
|
|
||||||
|
- Check the codebase to ensure that your feature doesn't already exist.
|
||||||
|
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
|
||||||
|
|
||||||
|
## Technical Requirements
|
||||||
|
|
||||||
|
- Submit Pull Requests to the **development branch only**.
|
||||||
|
- Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!)
|
||||||
|
- Please use the [Google Style Guide for Shell](https://google.github.io/styleguide/shell.xml) for your code submission styles.
|
||||||
|
- Commit Unix line endings.
|
||||||
|
- (Optional fun) keep to the theme of Star Trek/black holes/gravity.
|
||||||
|
189
README.md
189
README.md
@@ -1,41 +1,136 @@
|
|||||||
# Automated Install
|
<p align="center">
|
||||||
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
|
<a href=https://www.bountysource.com/trackers/3011939-pi-hole-pi-hole?utm_source=3011939&utm_medium=shield&utm_campaign=TRACKER_BADGE><img src="https://www.bountysource.com/badge/tracker?tracker_id=3011939"></a>
|
||||||
|
<a href="https://www.codacy.com/app/Pi-hole/pi-hole?utm_source=github.com&utm_medium=referral&utm_content=pi-hole/pi-hole&utm_campaign=Badge_Grade"><img src="https://api.codacy.com/project/badge/Grade/c558a0f8d7124c99b02b84f0f5564238"/></a>
|
||||||
|
<a href=https://travis-ci.org/pi-hole/pi-hole><img src="https://travis-ci.org/pi-hole/pi-hole.svg?branch=development"></a>
|
||||||
|
</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>
|
||||||
|
</p>
|
||||||
|
|
||||||
[](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
## The multi-platform, network-wide ad blocker
|
||||||
|
|
||||||
1. Install Raspbian
|
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.
|
||||||
|
|
||||||
2. Run the command below
|
- Web Browsers
|
||||||
|
- Cell Phones
|
||||||
|
- Smart TV's
|
||||||
|
- Internet-connected home automation
|
||||||
|
- Anything that communicates with the Internet
|
||||||
|
|
||||||
### ```curl -L https://install.pi-hole.net | bash```
|
<p align="center">
|
||||||
|
<a href=http://www.digitalocean.com/?refcode=344d234950e1><img src="https://assets.pi-hole.net/static/DOHostingSlug.png"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Your Support Still Matters
|
||||||
|
|
||||||
|
Digital Ocean helps with our infrastructure, but our developers are all volunteers so *your donations help keep us innovating*. Sending a donation using our links below helps us offset a portion of our monthly costs.
|
||||||
|
|
||||||
|
-  [Donate via PayPal](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY)
|
||||||
|
-  Bitcoin Address: 1GKnevUnVaQM2pQieMyeHkpr8DXfkpfAtL
|
||||||
|
|
||||||
|
### One-Step Automated Install
|
||||||
|
1. Install a [supported operating system](https://discourse.pi-hole.net/t/hardware-software-requirements/273/1)
|
||||||
|
2. Run the command below (it downloads [this script](https://github.com/pi-hole/pi-hole/blob/master/automated%20install/basic-install.sh) in case you want to read over it first!)
|
||||||
|
|
||||||
|
### `curl -sSL https://install.pi-hole.net | bash`
|
||||||
|
|
||||||
|
#### Alternative Semi-Automated Install Methods
|
||||||
|
_If you wish to read over the script before running it, run `nano basic-install.sh` to open the file in a text viewer._
|
||||||
|
|
||||||
|
##### Clone our repository and run the automated installer from your device.
|
||||||
|
|
||||||
#### Alternative Semi-Automated install ####
|
|
||||||
```
|
```
|
||||||
|
git clone --depth 1 https://github.com/pi-hole/pi-hole.git Pi-hole
|
||||||
|
cd Pi-hole/automated_installer/
|
||||||
|
bash basic-install.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
##### Or
|
||||||
|
|
||||||
|
```bash
|
||||||
wget -O basic-install.sh https://install.pi-hole.net
|
wget -O basic-install.sh https://install.pi-hole.net
|
||||||
chmod +x basic-install.sh
|
bash basic-install.sh
|
||||||
./basic-install.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](http://pi-hole.net/faq/can-i-set-the-pi-hole-to-be-the-dns-server-at-my-router-so-i-dont-have-to-change-settings-for-my-devices/) and then any device that connects to your network will have ads blocked without any further configuration. Alternatively, you can manually set each device to [use the Raspberry Pi as its DNS server](http://pi-hole.net/faq/how-do-i-use-the-pi-hole-as-my-dns-server/).
|
Once installed, [configure your router to have **DHCP clients use the Pi as their DNS server**](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/).
|
||||||
|
|
||||||
## Pi-hole Is Free, But Powered By Your Donations
|
## Installing the Pi-hole (Click to Watch!)
|
||||||
[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3J2L3Z4DHW9UY "Donate")
|
<p align="center">
|
||||||
|
<a href=https://www.youtube.com/watch?v=TzFLJqUeirA><img src="https://assets.pi-hole.net/static/global.png"></a>
|
||||||
|
</p>
|
||||||
|
|
||||||
## Catch us out on the net:
|
## Would you like to know more?
|
||||||
Twitter: [@The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
|
||||||
|
|
||||||
reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
|
||||||
|
|
||||||
## How Does It Work?
|
|
||||||
**Watch the 60-second video below to get a quick overview**
|
**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>
|
||||||
|
|
||||||
[](https://vimeo.com/135965232)
|
## Get Help Or Connect With Us On The Web
|
||||||
|
|
||||||
|
- [Users Forum](https://discourse.pi-hole.net/)
|
||||||
|
- [FAQs](https://discourse.pi-hole.net/c/faqs)
|
||||||
|
- [Wiki](https://github.com/pi-hole/pi-hole/wiki)
|
||||||
|
-  [Tweet @The_Pi_Hole](https://twitter.com/The_Pi_Hole)
|
||||||
|
-  [Reddit /r/pihole](https://www.reddit.com/r/pihole/)
|
||||||
|
-  [Pi-hole channel](https://www.youtube.com/channel/UCT5kq9w0wSjogzJb81C9U0w)
|
||||||
|
- [](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
### Gravity
|
||||||
|
|
||||||
|
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)). This script is controlled by the `pihole` command. Please run `pihole -h` to see what commands can be run via `pihole`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#### 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.
|
||||||
|
|
||||||
|
### Web Interface
|
||||||
|
|
||||||
|
The [Web interface](https://github.com/pi-hole/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
|
||||||
|
|
||||||
|
`http://192.168.1.x/admin/index.php` or `http://pi.hole/admin`
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### 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>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## API
|
||||||
|
|
||||||
|
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
||||||
|
|
||||||
|
``` json
|
||||||
|
{
|
||||||
|
"domains_being_blocked": "136708",
|
||||||
|
"dns_queries_today": "18108",
|
||||||
|
"ads_blocked_today": "14648",
|
||||||
|
"ads_percentage_today": "80.89"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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). 
|
||||||
|
|
||||||
## Pi-hole Projects
|
## Pi-hole Projects
|
||||||
|
|
||||||
|
- [Pi-hole stats in your Mac's menu bar](https://getbitbar.com/plugins/Network/pi-hole.1m.py)
|
||||||
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
- [Get LED alerts for each blocked ad](http://www.stinebaugh.info/get-led-alerts-for-each-blocked-ad-using-pi-hole/)
|
||||||
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
- [Pi-hole on Ubuntu 14.04 on VirtualBox](http://hbalagtas.blogspot.com/2016/02/adblocking-with-pi-hole-and-ubuntu-1404.html)
|
||||||
- [x86 Docker container that runs Pi-hole](https://hub.docker.com/r/diginc/pi-hole/)
|
- [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 Visualizser](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))
|
- [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)
|
- [Go Bananas for CHiP-hole ad blocking](https://www.hackster.io/jacobsalmela/chip-hole-network-wide-ad-blocker-98e037)
|
||||||
@@ -44,8 +139,13 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
|||||||
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
|
- [unRaid-hole](https://github.com/spants/unraidtemplates/blob/master/Spants/unRaid-hole.xml#L13)--[Repo and more info](http://lime-technology.com/forum/index.php?PHPSESSID=c0eae3e5ef7e521f7866034a3336489d&topic=38486.0)
|
||||||
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
|
- [Pi-hole on/off button](http://thetimmy.silvernight.org/pages/endisbutton/)
|
||||||
- [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole)
|
- [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
|
||||||
|
|
||||||
## Coverage
|
## Coverage
|
||||||
|
|
||||||
|
- [Adafruit livestream install](https://www.youtube.com/watch?v=eg4u2j1HYlI)
|
||||||
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
|
- [TekThing: 5 fun, easy projects for a Raspberry Pi](https://youtu.be/QwrKlyC2kdM?t=1m42s)
|
||||||
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
|
- [Pi-hole on Adafruit's blog](https://blog.adafruit.com/2016/03/04/pi-hole-is-a-black-hole-for-internet-ads-piday-raspberrypi-raspberry_pi/)
|
||||||
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
|
- [The Defrag Show - MSDN/Channel 9](https://channel9.msdn.com/Shows/The-Defrag-Show/Defrag-Endoscope-USB-Camera-The-Final-HoloLens-Vote-Adblock-Pi-and-more?WT.mc_id=dlvr_twitter_ch9#time=20m39s)
|
||||||
@@ -58,53 +158,4 @@ reddit: [/r/pihole](https://www.reddit.com/r/pihole/)
|
|||||||
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
- [Foolish Tech Show](https://youtu.be/bYyena0I9yc?t=2m4s)
|
||||||
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
- [Pi-hole on Ubuntu](http://www.boyter.org/2015/12/pi-hole-ubuntu-14-04/)
|
||||||
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
- [Catchpoint: iOS 9 Ad Blocking](http://blog.catchpoint.com/2015/09/14/ad-blocking-apple/)
|
||||||
|
- [Build an Ad-Blocker for less than 10$ with Orange-Pi](http://www.devacron.com/orangepi-zero-as-an-ad-block-server-with-pi-hole/)
|
||||||
## Partnering With Optimal.com
|
|
||||||
|
|
||||||
Pi-hole will be teaming up with [Rob Leathern's subscription service to avoid ads](https://medium.com/@robleathern/block-ads-on-all-home-devices-for-53-18-a5f1ec139693#.gj1xpgr5d). This service is unique and will help content-creators and publishers [still make money from visitors who are using an ad ablocker](http://techcrunch.com/2015/12/17/the-new-optimal/).
|
|
||||||
|
|
||||||
## 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.
|
|
||||||
|
|
||||||
A more detailed explanation of the installation can be found [here](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0).
|
|
||||||
|
|
||||||
## Gravity
|
|
||||||
The [gravity.sh](https://github.com/pi-hole/pi-hole/blob/master/gravity.sh) does most of the magic. The script pulls in ad domains from many sources and compiles them into a single list of [over 1.6 million entries](http://jacobsalmela.com/block-millions-ads-network-wide-with-a-raspberry-pi-hole-2-0) (if you decide to use the [mahakala list](https://github.com/pi-hole/pi-hole/commit/963eacfe0537a7abddf30441c754c67ca1e40965)).
|
|
||||||
|
|
||||||
## Whitelist and blacklist
|
|
||||||
Domains can be whitelisted and blacklisted using two pre-installed scripts. See [the wiki page](https://github.com/pi-hole/pi-hole/wiki/Whitelisting-and-Blacklisting) for more details
|
|
||||||
|
|
||||||
## Web Interface
|
|
||||||
The [Web interface](https://github.com/jacobsalmela/AdminLTE#pi-hole-admin-dashboard) will be installed automatically so you can view stats and change settings. You can find it at:
|
|
||||||
|
|
||||||
`http://192.168.1.x/admin/index.php`
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### API
|
|
||||||
|
|
||||||
A basic read-only API can be accessed at `/admin/api.php`. It returns the following JSON:
|
|
||||||
```JSON
|
|
||||||
{
|
|
||||||
"domains_being_blocked": "136708",
|
|
||||||
"dns_queries_today": "18108",
|
|
||||||
"ads_blocked_today": "14648",
|
|
||||||
"ads_percentage_today": "80.89"
|
|
||||||
}
|
|
||||||
```
|
|
||||||
The same output can be acheived 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).
|
|
||||||

|
|
||||||
|
|
||||||
## Help
|
|
||||||
- See the [Wiki](https://github.com/pi-hole/pi-hole/wiki/Customization) entry for more details
|
|
||||||
- There is also an [FAQ section on pi-hole.net](http://pi-hole.net)
|
|
||||||
|
|
||||||
## Other Operating Systems
|
|
||||||
This script will work for other UNIX-like systems with some slight **modifications**. As long as you can install `dnsmasq` and a Webserver, it should work OK. The automated install is only for a clean install of a Debian based system, such as the Raspberry Pi.
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
## Pi-hole ad-list default sources. Updated 21/02/2016 #########################
|
## Pi-hole ad-list default sources. Updated 29/10/2016 #########################
|
||||||
# #
|
# #
|
||||||
# To make changes to this file: #
|
# To make changes to this file: #
|
||||||
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
# 1. run `cp /etc/pihole/adlists.default /etc/pihole/adlists.list` #
|
||||||
@@ -14,7 +14,6 @@
|
|||||||
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
https://raw.githubusercontent.com/StevenBlack/hosts/master/hosts
|
||||||
|
|
||||||
# Other lists we consider safe:
|
# Other lists we consider safe:
|
||||||
http://adblock.gjtech.net/?format=unix-hosts
|
|
||||||
http://mirror1.malwaredomains.com/files/justdomains
|
http://mirror1.malwaredomains.com/files/justdomains
|
||||||
http://sysctl.org/cameleon/hosts
|
http://sysctl.org/cameleon/hosts
|
||||||
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
https://zeustracker.abuse.ch/blocklist.php?download=domainblocklist
|
||||||
@@ -22,17 +21,17 @@ https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt
|
|||||||
https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt
|
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 list. Updated frequently, but has been known to block legitimate sites.
|
||||||
http://hosts-file.net/ad_servers.txt
|
https://hosts-file.net/ad_servers.txt
|
||||||
|
|
||||||
# Mahakala list. Has been known to block legitimage domains including the entire .com range.
|
# 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.
|
# Warning: Due to the sheer size of this list, the web admin console will be unresponsive.
|
||||||
#http://adblock.mahakala.is/
|
#http://adblock.mahakala.is/
|
||||||
|
|
||||||
# ADZHOSTS list. Has been known to block legitimate domains
|
# ADZHOSTS list. Has been known to block legitimate domains
|
||||||
#http://optimate.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
#http://pilotfiber.dl.sourceforge.net/project/adzhosts/HOSTS.txt
|
||||||
|
|
||||||
# Windows 10 telemetry list
|
# Windows 10 telemetry list
|
||||||
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/hostsBlockWindowsSpy.txt
|
#https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/win10/spy.txt
|
||||||
|
|
||||||
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
# Securemecca.com list - Also blocks "adult" sites (pornography/gambling etc)
|
||||||
#http://securemecca.com/Downloads/hosts.txt
|
#http://securemecca.com/Downloads/hosts.txt
|
||||||
@@ -43,8 +42,12 @@ https://raw.githubusercontent.com/quidsup/notrack/master/trackers.txt
|
|||||||
# Block the BBC News website Breaking News banner
|
# Block the BBC News website Breaking News banner
|
||||||
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
#https://raw.githubusercontent.com/BreakingTheNews/BreakingTheNews.github.io/master/hosts
|
||||||
|
|
||||||
|
|
||||||
# Untested Lists:
|
# Untested Lists:
|
||||||
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
#https://raw.githubusercontent.com/reek/anti-adblock-killer/master/anti-adblock-killer-filters.txt
|
||||||
#http://spam404bl.com/spam404scamlist.txt
|
#https://raw.githubusercontent.com/Dawsey21/Lists/master/main-blacklist.txt
|
||||||
#http://malwaredomains.lehigh.edu/files/domains.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
|
||||||
|
@@ -9,53 +9,36 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# If you want dnsmasq to read another file, as well as /etc/hosts, use
|
###############################################################################
|
||||||
# this.
|
# FILE AUTOMATICALLY POPULATED BY PI-HOLE INSTALL/UPDATE PROCEDURE. #
|
||||||
|
# ANY CHANGES MADE TO THIS FILE AFTER INSTALL WILL BE LOST ON THE NEXT UPDATE #
|
||||||
|
# #
|
||||||
|
# IF YOU WISH TO CHANGE THE UPSTREAM SERVERS, CHANGE THEM IN: #
|
||||||
|
# /etc/pihole/setupVars.conf #
|
||||||
|
# #
|
||||||
|
# ANY OTHER CHANGES SHOULD BE MADE IN A SEPERATE CONFIG FILE #
|
||||||
|
# OR IN /etc/dnsmasq.conf #
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
addn-hosts=/etc/pihole/gravity.list
|
addn-hosts=/etc/pihole/gravity.list
|
||||||
|
addn-hosts=/etc/pihole/local.list
|
||||||
|
|
||||||
# The following two options make you a better netizen, since they
|
|
||||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
|
||||||
# answer, and which load the servers (especially the root servers)
|
|
||||||
# unnecessarily. If you have a dial-on-demand link they also stop
|
|
||||||
# these requests from bringing up the link unnecessarily.
|
|
||||||
|
|
||||||
# Never forward plain names (without a dot or domain part)
|
|
||||||
domain-needed
|
domain-needed
|
||||||
# Never forward addresses in the non-routed address spaces.
|
|
||||||
bogus-priv
|
bogus-priv
|
||||||
|
|
||||||
# If you don't want dnsmasq to read /etc/resolv.conf or any other
|
|
||||||
# file, getting its servers from this file instead (see below), then
|
|
||||||
# uncomment this.
|
|
||||||
no-resolv
|
no-resolv
|
||||||
|
|
||||||
# Add other name servers here, with domain specs if they are for
|
|
||||||
# non-public domains.
|
|
||||||
server=@DNS1@
|
server=@DNS1@
|
||||||
server=@DNS2@
|
server=@DNS2@
|
||||||
|
|
||||||
# If you want dnsmasq to listen for DHCP and DNS requests only on
|
|
||||||
# specified interfaces (and the loopback) give the name of the
|
|
||||||
# interface (eg eth0) here.
|
|
||||||
interface=@INT@
|
interface=@INT@
|
||||||
# Or which to listen on by address (remember to include 127.0.0.1 if
|
|
||||||
# you use this.)
|
|
||||||
listen-address=127.0.0.1
|
|
||||||
|
|
||||||
# Set the cachesize here.
|
|
||||||
cache-size=10000
|
cache-size=10000
|
||||||
|
|
||||||
# For debugging purposes, log each DNS query as it passes through
|
|
||||||
# dnsmasq.
|
|
||||||
log-queries
|
log-queries
|
||||||
log-facility=/var/log/pihole.log
|
log-facility=/var/log/pihole.log
|
||||||
|
|
||||||
# Normally responses which come from /etc/hosts and the DHCP lease
|
|
||||||
# file have Time-To-Live set as zero, which conventionally means
|
|
||||||
# do not cache further. If you are happy to trade lower load on the
|
|
||||||
# server for potentially stale date, you can set a time-to-live (in
|
|
||||||
# seconds) here.
|
|
||||||
local-ttl=300
|
local-ttl=300
|
||||||
|
|
||||||
# This allows it to continue functioning without being blocked by syslog, and allows syslog to use dnsmasq for DNS queries without risking deadlock
|
|
||||||
log-async
|
log-async
|
||||||
|
@@ -1,196 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# 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.
|
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
|
||||||
echo "::: Immediately blacklists one or more domains in the hosts file"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the blacklist"
|
|
||||||
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#globals
|
|
||||||
basename=pihole
|
|
||||||
piholeDir=/etc/$basename
|
|
||||||
adList=$piholeDir/gravity.list
|
|
||||||
blacklist=$piholeDir/blacklist.txt
|
|
||||||
reload=true
|
|
||||||
addmode=true
|
|
||||||
force=false
|
|
||||||
versbose=true
|
|
||||||
|
|
||||||
domList=()
|
|
||||||
domToRemoveList=()
|
|
||||||
|
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
|
||||||
|
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
|
||||||
|
|
||||||
modifyHost=false
|
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
|
||||||
echo "::: Local calibration requested..."
|
|
||||||
. $piholeDir/pihole.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
function HandleOther(){
|
|
||||||
#check validity of domain
|
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
|
||||||
if [ -z "$validDomain" ]; then
|
|
||||||
echo "::: $1 is not a valid argument or domain name"
|
|
||||||
else
|
|
||||||
domList=("${domList[@]}" $validDomain)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function PopBlacklistFile(){
|
|
||||||
#check blacklist file exists, and if not, create it
|
|
||||||
if [[ ! -f $blacklist ]];then
|
|
||||||
touch $blacklist
|
|
||||||
fi
|
|
||||||
for dom in "${domList[@]}"; do
|
|
||||||
if "$addmode"; then
|
|
||||||
AddDomain "$dom"
|
|
||||||
else
|
|
||||||
RemoveDomain "$dom"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function AddDomain(){
|
|
||||||
#| sed 's/\./\\./g'
|
|
||||||
bool=false
|
|
||||||
grep -Ex -q "$1" $blacklist || bool=true
|
|
||||||
if $bool; then
|
|
||||||
#domain not found in the blacklist file, add it!
|
|
||||||
if $versbose; then
|
|
||||||
echo -n "::: Adding $1 to blacklist file..."
|
|
||||||
fi
|
|
||||||
echo "$1" >> $blacklist
|
|
||||||
modifyHost=true
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: $1 already exists in $blacklist! No need to add"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function RemoveDomain(){
|
|
||||||
|
|
||||||
bool=false
|
|
||||||
grep -Ex -q "$1" $blacklist || bool=true
|
|
||||||
if $bool; then
|
|
||||||
#Domain is not in the blacklist file, no need to Remove
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: $1 is NOT blacklisted! No need to remove"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
#Domain is in the blacklist file, add to a temporary array
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: Un-blacklisting $dom..."
|
|
||||||
fi
|
|
||||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
|
||||||
modifyHost=true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function ModifyHostFile(){
|
|
||||||
if $addmode; then
|
|
||||||
#add domains to the hosts file
|
|
||||||
if [[ -r $blacklist ]];then
|
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
|
||||||
echo ":::"
|
|
||||||
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
|
|
||||||
if [[ -n $piholeIPv6 ]];then
|
|
||||||
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
|
||||||
else
|
|
||||||
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo ":::"
|
|
||||||
for dom in "${domToRemoveList[@]}"
|
|
||||||
do
|
|
||||||
#we need to remove the domains from the blacklist file and the host file
|
|
||||||
echo "::: $dom"
|
|
||||||
echo -n "::: removing from HOSTS file..."
|
|
||||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
|
|
||||||
echo " done!"
|
|
||||||
echo -n "::: removing from blackist.txt..."
|
|
||||||
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist
|
|
||||||
echo " done!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function Reload() {
|
|
||||||
# Reload hosts file
|
|
||||||
echo ":::"
|
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
|
||||||
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
|
||||||
# service already running - reload config
|
|
||||||
sudo kill -HUP "$dnsmasqPid"
|
|
||||||
else
|
|
||||||
# service not running, start it up
|
|
||||||
sudo service dnsmasq start
|
|
||||||
fi
|
|
||||||
echo " done!"
|
|
||||||
}
|
|
||||||
|
|
||||||
###################################################
|
|
||||||
|
|
||||||
for var in "$@"
|
|
||||||
do
|
|
||||||
case "$var" in
|
|
||||||
"-nr"| "--noreload" ) reload=false;;
|
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
|
||||||
"-f" | "--force" ) force=true;;
|
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
|
||||||
* ) HandleOther "$var";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
PopBlacklistFile
|
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
|
||||||
ModifyHostFile
|
|
||||||
else
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: No changes need to be made"
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $reload; then
|
|
||||||
Reload
|
|
||||||
fi
|
|
@@ -15,17 +15,15 @@
|
|||||||
piLog="/var/log/pihole.log"
|
piLog="/var/log/pihole.log"
|
||||||
gravity="/etc/pihole/gravity.list"
|
gravity="/etc/pihole/gravity.list"
|
||||||
|
|
||||||
today=$(date "+%b %e")
|
. /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
function CalcBlockedDomains(){
|
CalcBlockedDomains() {
|
||||||
CheckIPv6
|
if [ -e "${gravity}" ]; then
|
||||||
if [ -e "$gravity" ]; then
|
# if BOTH IPV4 and IPV6 are in use, then we need to divide total domains by 2.
|
||||||
#Are we IPV6 or IPV4?
|
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]]; then
|
||||||
if [[ -n $piholeIPv6 ]];then
|
|
||||||
#We are IPV6
|
|
||||||
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
|
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1/2}')
|
||||||
else
|
else
|
||||||
#We are IPV4
|
# only one is set.
|
||||||
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1}')
|
blockedDomainsTotal=$(wc -l /etc/pihole/gravity.list | awk '{print $1}')
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
@@ -33,43 +31,35 @@ function CalcBlockedDomains(){
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcQueriesToday(){
|
CalcQueriesToday() {
|
||||||
if [ -e "$piLog" ];then
|
if [ -e "${piLog}" ]; then
|
||||||
queriesToday=$(cat "$piLog" | grep "$today" | awk '/query/ {print $6}' | wc -l)
|
queriesToday=$(awk '/query\[/ {print $6}' < "${piLog}" | wc -l)
|
||||||
else
|
else
|
||||||
queriesToday="Err."
|
queriesToday="Err."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcblockedToday(){
|
CalcblockedToday() {
|
||||||
if [ -e "$piLog" ] && [ -e "$gravity" ];then
|
if [ -e "${piLog}" ] && [ -e "${gravity}" ];then
|
||||||
blockedToday=$(cat $piLog | awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' | wc -l)
|
blockedToday=$(awk '/\/etc\/pihole\/gravity.list/ && !/address/ {print $6}' < "${piLog}" | wc -l)
|
||||||
else
|
else
|
||||||
blockedToday="Err."
|
blockedToday="Err."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CalcPercentBlockedToday(){
|
CalcPercentBlockedToday() {
|
||||||
if [ "$queriesToday" != "Err." ] && [ "$blockedToday" != "Err." ]; then
|
if [ "${queriesToday}" != "Err." ] && [ "${blockedToday}" != "Err." ]; then
|
||||||
if [ "$queriesToday" != 0 ]; then #Fixes divide by zero error :)
|
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
|
#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=$(echo "scale=4; ${blockedToday}/${queriesToday}*100" | bc)
|
||||||
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "$percentBlockedToday")
|
percentBlockedToday=$(sed 's/.\{2\}$//' <<< "${percentBlockedToday}")
|
||||||
else
|
else
|
||||||
percentBlockedToday=0
|
percentBlockedToday=0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function CheckIPv6(){
|
outputJSON() {
|
||||||
piholeIPv6file="/etc/pihole/.useIPv6"
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function outputJSON(){
|
|
||||||
CalcQueriesToday
|
CalcQueriesToday
|
||||||
CalcblockedToday
|
CalcblockedToday
|
||||||
CalcPercentBlockedToday
|
CalcPercentBlockedToday
|
||||||
@@ -79,13 +69,16 @@ function outputJSON(){
|
|||||||
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
printf '{"domains_being_blocked":"%s","dns_queries_today":"%s","ads_blocked_today":"%s","ads_percentage_today":"%s"}\n' "$blockedDomainsTotal" "$queriesToday" "$blockedToday" "$percentBlockedToday"
|
||||||
}
|
}
|
||||||
|
|
||||||
function normalChrono(){
|
normalChrono() {
|
||||||
for (( ; ; ))
|
for (( ; ; )); do
|
||||||
do
|
|
||||||
clear
|
clear
|
||||||
# Displays a colorful Pi-hole logo
|
# Displays a colorful Pi-hole logo
|
||||||
toilet -f small -F gay Pi-hole
|
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"
|
||||||
echo " $(ifconfig eth0 | awk '/inet addr/ {print $2}' | cut -d':' -f2)"
|
echo "[0;1;31;91m|[0m [0;1;33;93m_[0m [0;1;32;92m(_[0;1;36;96m)_[0;1;34;94m__[0;1;35;95m|[0m [0;1;31;91m|_[0m [0;1;32;92m__[0;1;36;96m_|[0m [0;1;34;94m|[0;1;35;95m__[0;1;31;91m_[0m"
|
||||||
|
echo "[0;1;33;93m|[0m [0;1;32;92m_[0;1;36;96m/[0m [0;1;34;94m|_[0;1;35;95m__[0;1;31;91m|[0m [0;1;33;93m'[0m [0;1;32;92m\/[0m [0;1;36;96m_[0m [0;1;34;94m\[0m [0;1;35;95m/[0m [0;1;31;91m-[0;1;33;93m_)[0m"
|
||||||
|
echo "[0;1;32;92m|_[0;1;36;96m|[0m [0;1;34;94m|_[0;1;35;95m|[0m [0;1;33;93m|_[0;1;32;92m||[0;1;36;96m_\[0;1;34;94m__[0;1;35;95m_/[0;1;31;91m_\[0;1;33;93m__[0;1;32;92m_|[0m"
|
||||||
|
echo ""
|
||||||
|
echo " ${IPV4_ADDRESS}"
|
||||||
echo ""
|
echo ""
|
||||||
uptime | cut -d' ' -f11-
|
uptime | cut -d' ' -f11-
|
||||||
#uptime -p #Doesn't work on all versions of uptime
|
#uptime -p #Doesn't work on all versions of uptime
|
||||||
@@ -107,35 +100,33 @@ function normalChrono(){
|
|||||||
|
|
||||||
CalcBlockedDomains
|
CalcBlockedDomains
|
||||||
|
|
||||||
echo "Blocking: $blockedDomainsTotal"
|
echo "Blocking: ${blockedDomainsTotal}"
|
||||||
#below commented line does not add up to todaysQueryCount
|
echo "Queries: ${queriesToday}" #same total calculation as dashboard
|
||||||
#echo "Queries: $todaysQueryCountV4 / $todaysQueryCountV6"
|
echo "Pi-holed: ${blockedToday} (${percentBlockedToday}%)"
|
||||||
echo "Queries: $queriesToday" #same total calculation as dashboard
|
|
||||||
echo "Pi-holed: $blockedToday ($percentBlockedToday%)"
|
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function displayHelp(){
|
displayHelp() {
|
||||||
echo "::: Displays stats about your piHole!"
|
cat << EOM
|
||||||
echo ":::"
|
::: Displays stats about your piHole!
|
||||||
echo "::: Usage: sudo pihole.sh -c [optional:-j]"
|
:::
|
||||||
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
|
::: Usage: sudo pihole -c [optional:-j]
|
||||||
echo ":::"
|
::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds
|
||||||
echo "::: Options:"
|
:::
|
||||||
echo "::: -j, --json output stats as JSON formatted string"
|
::: Options:
|
||||||
echo "::: -h, --help display this help text"
|
::: -j, --json output stats as JSON formatted string
|
||||||
|
::: -h, --help display this help text
|
||||||
exit 1
|
EOM
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
normalChrono
|
normalChrono
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for var in "$@"
|
for var in "$@"; do
|
||||||
do
|
|
||||||
case "$var" in
|
case "$var" in
|
||||||
"-j" | "--json" ) outputJSON;;
|
"-j" | "--json" ) outputJSON;;
|
||||||
"-h" | "--help" ) displayHelp;;
|
"-h" | "--help" ) displayHelp;;
|
||||||
|
177
advanced/Scripts/list.sh
Executable file
177
advanced/Scripts/list.sh
Executable file
@@ -0,0 +1,177 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
# http://pi-hole.net
|
||||||
|
# Whitelists 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.
|
||||||
|
|
||||||
|
#globals
|
||||||
|
basename=pihole
|
||||||
|
piholeDir=/etc/${basename}
|
||||||
|
whitelist=${piholeDir}/whitelist.txt
|
||||||
|
blacklist=${piholeDir}/blacklist.txt
|
||||||
|
reload=false
|
||||||
|
addmode=true
|
||||||
|
verbose=true
|
||||||
|
|
||||||
|
domList=()
|
||||||
|
domToRemoveList=()
|
||||||
|
|
||||||
|
listMain=""
|
||||||
|
listAlt=""
|
||||||
|
|
||||||
|
helpFunc() {
|
||||||
|
|
||||||
|
if [[ ${listMain} == ${whitelist} ]]; then
|
||||||
|
letter="w"
|
||||||
|
word="white"
|
||||||
|
else
|
||||||
|
letter="b"
|
||||||
|
word="black"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat << EOM
|
||||||
|
::: Immediately ${word}lists one or more domains in the hosts file
|
||||||
|
:::
|
||||||
|
::: 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
|
||||||
|
EOM
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
EscapeRegexp() {
|
||||||
|
# This way we may safely insert an arbitrary
|
||||||
|
# string in our regular expressions
|
||||||
|
echo $* | sed "s/[]\\.|$(){}?+*^]/\\\\&/g" | sed "s/\\//\\\\\//g"
|
||||||
|
}
|
||||||
|
|
||||||
|
HandleOther(){
|
||||||
|
# First, convert everything to lowercase
|
||||||
|
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")
|
||||||
|
if [ -z "${validDomain}" ]; then
|
||||||
|
echo "::: $1 is not a valid argument or domain name"
|
||||||
|
else
|
||||||
|
domList=("${domList[@]}" ${validDomain})
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
PoplistFile() {
|
||||||
|
#check whitelist file exists, and if not, create it
|
||||||
|
if [[ ! -f ${whitelist} ]]; then
|
||||||
|
touch ${whitelist}
|
||||||
|
fi
|
||||||
|
for dom in "${domList[@]}"; do
|
||||||
|
# Logic : If addmode then add to desired list and remove from the other; if delmode then remove from desired list but do not add to the other
|
||||||
|
if ${addmode}; then
|
||||||
|
AddDomain "${dom}" "${listMain}"
|
||||||
|
RemoveDomain "${dom}" "${listAlt}"
|
||||||
|
else
|
||||||
|
RemoveDomain "${dom}" "${listMain}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
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 [[ "${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
|
||||||
|
}
|
||||||
|
|
||||||
|
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!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
Reload() {
|
||||||
|
# Reload hosts file
|
||||||
|
pihole -g -sd
|
||||||
|
}
|
||||||
|
|
||||||
|
Displaylist() {
|
||||||
|
if [[ ${listMain} == ${whitelist} ]]; then
|
||||||
|
string="gravity resistant domains"
|
||||||
|
else
|
||||||
|
string="domains caught in the sinkhole"
|
||||||
|
fi
|
||||||
|
verbose=false
|
||||||
|
echo -e " Displaying $string \n"
|
||||||
|
count=1
|
||||||
|
while IFS= read -r RD; do
|
||||||
|
echo "${count}: ${RD}"
|
||||||
|
count=$((count+1))
|
||||||
|
done < "${listMain}"
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
for var in "$@"; do
|
||||||
|
case "${var}" in
|
||||||
|
"-w" | "whitelist" ) listMain="${whitelist}"; listAlt="${blacklist}";;
|
||||||
|
"-b" | "blacklist" ) listMain="${blacklist}"; listAlt="${whitelist}";;
|
||||||
|
"-nr"| "--noreload" ) reload=false;;
|
||||||
|
"-d" | "--delmode" ) addmode=false;;
|
||||||
|
"-f" | "--force" ) force=true;;
|
||||||
|
"-q" | "--quiet" ) verbose=false;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"-l" | "--list" ) Displaylist;;
|
||||||
|
* ) HandleOther "${var}";;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [[ $# = 0 ]]; then
|
||||||
|
helpFunc
|
||||||
|
fi
|
||||||
|
|
||||||
|
PoplistFile
|
||||||
|
|
||||||
|
if ${reload}; then
|
||||||
|
Reload
|
||||||
|
fi
|
||||||
|
|
@@ -3,307 +3,405 @@
|
|||||||
# (c) 2015, 2016 by Jacob Salmela
|
# (c) 2015, 2016 by Jacob Salmela
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
# http://pi-hole.net
|
# http://pi-hole.net
|
||||||
# Generates pihole_debug.log in /var/log/ to be used for troubleshooting.
|
# Generates pihole_debug.log to be used for troubleshooting.
|
||||||
#
|
#
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
# Pi-hole is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Nate Brandeburg
|
set -o pipefail
|
||||||
# nate@ubiquisoft.com
|
|
||||||
# 3/24/2016
|
|
||||||
|
|
||||||
######## GLOBAL VARS ########
|
######## GLOBAL VARS ########
|
||||||
|
VARSFILE="/etc/pihole/setupVars.conf"
|
||||||
DEBUG_LOG="/var/log/pihole_debug.log"
|
DEBUG_LOG="/var/log/pihole_debug.log"
|
||||||
DNSMASQFILE="/etc/dnsmasq.conf"
|
DNSMASQFILE="/etc/dnsmasq.conf"
|
||||||
PIHOLECONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
DNSMASQCONFFILE="/etc/dnsmasq.d/01-pihole.conf"
|
||||||
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
LIGHTTPDFILE="/etc/lighttpd/lighttpd.conf"
|
||||||
|
LIGHTTPDERRFILE="/var/log/lighttpd/error.log"
|
||||||
GRAVITYFILE="/etc/pihole/gravity.list"
|
GRAVITYFILE="/etc/pihole/gravity.list"
|
||||||
HOSTSFILE="/etc/hosts"
|
|
||||||
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
WHITELISTFILE="/etc/pihole/whitelist.txt"
|
||||||
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
BLACKLISTFILE="/etc/pihole/blacklist.txt"
|
||||||
ADLISTSFILE="/etc/pihole/adlists.list"
|
ADLISTFILE="/etc/pihole/adlists.list"
|
||||||
PIHOLELOG="/var/log/pihole.log"
|
PIHOLELOG="/var/log/pihole.log"
|
||||||
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
WHITELISTMATCHES="/tmp/whitelistmatches.list"
|
||||||
|
|
||||||
|
IPV6_READY=false
|
||||||
######## FIRST CHECK ########
|
TIMEOUT=60
|
||||||
# Must be root to debug
|
# Header info and introduction
|
||||||
if [[ $EUID -eq 0 ]]; then
|
cat << EOM
|
||||||
echo "::: You are root... Beginning debug!"
|
::: Beginning Pi-hole debug at $(date)!
|
||||||
else
|
:::
|
||||||
echo "::: Sudo will be used for debugging."
|
::: This process collects information from your Pi-hole, and optionally uploads
|
||||||
# Check if sudo is actually installed
|
::: it to a unique and random directory on tricorder.pi-hole.net.
|
||||||
if [[ $(dpkg-query -s sudo) ]]; then
|
:::
|
||||||
export SUDO="sudo"
|
::: NOTE: All log files auto-delete after 24 hours and ONLY the Pi-hole developers
|
||||||
else
|
::: can access your data via the given token. We have taken these extra steps to
|
||||||
echo "::: Please install sudo or run this as root."
|
::: secure your data and will work to further reduce any personal information gathered.
|
||||||
exit 1
|
:::
|
||||||
fi
|
::: Please read and note any issues, and follow any directions advised during this process.
|
||||||
fi
|
EOM
|
||||||
|
|
||||||
# Ensure the file exists, create if not, clear if exists.
|
# Ensure the file exists, create if not, clear if exists.
|
||||||
if [ ! -f "$DEBUG_LOG" ]; then
|
truncate --size=0 "${DEBUG_LOG}"
|
||||||
$SUDO touch $DEBUG_LOG
|
chmod 644 ${DEBUG_LOG}
|
||||||
$SUDO chmod 644 $DEBUG_LOG
|
chown "$USER":pihole ${DEBUG_LOG}
|
||||||
$SUDO chown "$USER":root $DEBUG_LOG
|
|
||||||
else
|
source ${VARSFILE}
|
||||||
truncate -s 0 $DEBUG_LOG
|
|
||||||
fi
|
|
||||||
|
|
||||||
### Private functions exist here ###
|
### Private functions exist here ###
|
||||||
function compareWhitelist {
|
log_write() {
|
||||||
if [ ! -f "$WHITELISTMATCHES" ]; then
|
echo "${1}" >> "${DEBUG_LOG}"
|
||||||
$SUDO touch $WHITELISTMATCHES
|
}
|
||||||
$SUDO chmod 644 $WHITELISTMATCHES
|
|
||||||
$SUDO chown "$USER":root $WHITELISTMATCHES
|
log_echo() {
|
||||||
|
case ${1} in
|
||||||
|
-n)
|
||||||
|
echo -n "::: ${2}"
|
||||||
|
log_write "${2}"
|
||||||
|
;;
|
||||||
|
-r)
|
||||||
|
echo "::: ${2}"
|
||||||
|
log_write "${2}"
|
||||||
|
;;
|
||||||
|
-l)
|
||||||
|
echo "${2}"
|
||||||
|
log_write "${2}"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "::: ${1}"
|
||||||
|
log_write "${1}"
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
header_write() {
|
||||||
|
log_echo ""
|
||||||
|
log_echo "${1}"
|
||||||
|
log_write ""
|
||||||
|
}
|
||||||
|
|
||||||
|
file_parse() {
|
||||||
|
while read -r line; do
|
||||||
|
if [ ! -z "${line}" ]; then
|
||||||
|
[[ "${line}" =~ ^#.*$ || ! "${line}" ]] && continue
|
||||||
|
log_write "${line}"
|
||||||
|
fi
|
||||||
|
done < "${1}"
|
||||||
|
log_write ""
|
||||||
|
}
|
||||||
|
|
||||||
|
block_parse() {
|
||||||
|
log_write "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
lsof_parse() {
|
||||||
|
local user
|
||||||
|
local process
|
||||||
|
|
||||||
|
user=$(echo ${1} | cut -f 3 -d ' ' | cut -c 2-)
|
||||||
|
process=$(echo ${1} | cut -f 2 -d ' ' | cut -c 2-)
|
||||||
|
[[ ${2} -eq ${process} ]] \
|
||||||
|
&& echo "::: Correctly configured." \
|
||||||
|
|| log_echo "::: Failure: Incorrectly configured daemon."
|
||||||
|
|
||||||
|
log_write "Found user ${user} with process ${process}"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
version_check() {
|
||||||
|
header_write "Detecting Installed Package Versions:"
|
||||||
|
|
||||||
|
local error_found
|
||||||
|
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)
|
||||||
|
return "${error_found}"
|
||||||
|
}
|
||||||
|
|
||||||
|
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"
|
||||||
|
file_parse "${search_file}"
|
||||||
|
return 0
|
||||||
else
|
else
|
||||||
truncate -s 0 $WHITELISTMATCHES
|
log_echo "${1} not found!"
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
echo ":::"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "######## Whitelist Comparison #########" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
while read -r line; do
|
|
||||||
TMP=$(grep -w ".* $line$" "$GRAVITYFILE")
|
|
||||||
if [ ! -z "$TMP" ]; then
|
|
||||||
echo "$TMP" >> $DEBUG_LOG
|
|
||||||
echo "$TMP" >> $WHITELISTMATCHES
|
|
||||||
fi
|
|
||||||
done < "$WHITELISTFILE"
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function compareBlacklist {
|
source_file() {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
local file_found=$(files_check "${1}") \
|
||||||
echo "######## Blacklist Comparison #########" >> $DEBUG_LOG
|
&& (source "${1}" &> /dev/null && echo "${file_found} and was successfully sourced") \
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|| log_echo -l "${file_found} and could not be sourced"
|
||||||
while read -r line; do
|
|
||||||
if [ ! -z "$line" ]; then
|
|
||||||
grep -w ".* $line$" "$GRAVITYFILE" >> $DEBUG_LOG
|
|
||||||
fi
|
|
||||||
done < "$BLACKLISTFILE"
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testNslookup {
|
distro_check() {
|
||||||
TESTURL="doubleclick.com"
|
local soft_fail
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
header_write "Detecting installed OS Distribution"
|
||||||
echo "############ NSLookup Test ############" >> $DEBUG_LOG
|
soft_fail=0
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
local distro="$(cat /etc/*release)" && block_parse "${distro}" || (log_echo "Distribution details not found." && soft_fail=1)
|
||||||
|
return "${soft_fail}"
|
||||||
|
}
|
||||||
|
|
||||||
|
processor_check() {
|
||||||
|
header_write "Checking processor variety"
|
||||||
|
log_write $(uname -m) && return 0 || return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
port_check() {
|
||||||
|
local lsof_value
|
||||||
|
|
||||||
|
lsof_value=$(lsof -i ${1}:${2} -FcL | tr '\n' ' ') \
|
||||||
|
&& lsof_parse "${lsof_value}" "${3}" \
|
||||||
|
|| log_echo "Failure: IPv${1} Port not in use"
|
||||||
|
}
|
||||||
|
|
||||||
|
daemon_check() {
|
||||||
|
# Check for daemon ${1} on port ${2}
|
||||||
|
header_write "Daemon Process Information"
|
||||||
|
|
||||||
|
echo "::: Checking ${2} port for ${1} listener."
|
||||||
|
|
||||||
|
if [[ ${IPV6_READY} ]]; then
|
||||||
|
port_check 6 "${2}" "${1}"
|
||||||
|
fi
|
||||||
|
lsof_value=$(lsof -i 4:${2} -FcL | tr '\n' ' ') \
|
||||||
|
port_check 4 "${2}" "${1}"
|
||||||
|
}
|
||||||
|
|
||||||
|
testResolver() {
|
||||||
|
header_write "Resolver Functions Check"
|
||||||
|
|
||||||
# Find a blocked url that has not been whitelisted.
|
# Find a blocked url that has not been whitelisted.
|
||||||
if [ -s "$WHITELISTMATCHES" ]; then
|
TESTURL="doubleclick.com"
|
||||||
|
if [ -s "${WHITELISTMATCHES}" ]; then
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
CUTURL=${line#*" "}
|
CUTURL=${line#*" "}
|
||||||
if [ "$CUTURL" != "Pi-Hole.IsWorking.OK" ]; then
|
if [ "${CUTURL}" != "Pi-Hole.IsWorking.OK" ]; then
|
||||||
while read -r line2; do
|
while read -r line2; do
|
||||||
CUTURL2=${line2#*" "}
|
CUTURL2=${line2#*" "}
|
||||||
if [ "$CUTURL" != "$CUTURL2" ]; then
|
if [ "${CUTURL}" != "${CUTURL2}" ]; then
|
||||||
TESTURL="$CUTURL"
|
TESTURL="${CUTURL}"
|
||||||
break 2
|
break 2
|
||||||
fi
|
fi
|
||||||
done < "$WHITELISTMATCHES"
|
done < "${WHITELISTMATCHES}"
|
||||||
fi
|
fi
|
||||||
done < "$GRAVITYFILE"
|
done < "${GRAVITYFILE}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "NSLOOKUP of $TESTURL from PiHole:" >> $DEBUG_LOG
|
log_write "Resolution of ${TESTURL} from Pi-hole:"
|
||||||
nslookup "$TESTURL" >> $DEBUG_LOG
|
LOCALDIG=$(dig "${TESTURL}" @127.0.0.1)
|
||||||
echo >> $DEBUG_LOG
|
if [[ $? = 0 ]]; then
|
||||||
echo "NSLOOKUP of $TESTURL from 8.8.8.8:" >> $DEBUG_LOG
|
log_write "${LOCALDIG}"
|
||||||
nslookup "$TESTURL" 8.8.8.8 >> $DEBUG_LOG
|
else
|
||||||
echo >> $DEBUG_LOG
|
log_write "Failed to resolve ${TESTURL} on Pi-hole"
|
||||||
|
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}"
|
||||||
|
else
|
||||||
|
log_write "Failed to resolve ${TESTURL} on 8.8.8.8"
|
||||||
|
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 ""
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkProcesses {
|
checkProcesses() {
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
header_write "Processes Check"
|
||||||
echo "########### Processes Check ###########" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Logging status of lighttpd and dnsmasq..."
|
echo "::: Logging status of lighttpd and dnsmasq..."
|
||||||
PROCESSES=( lighttpd dnsmasq )
|
PROCESSES=( lighttpd dnsmasq )
|
||||||
for i in "${PROCESSES[@]}"
|
for i in "${PROCESSES[@]}"; do
|
||||||
do
|
log_write ""
|
||||||
echo "" >> $DEBUG_LOG
|
log_write "${i}"
|
||||||
echo -n $i >> "$DEBUG_LOG"
|
log_write " processes status:"
|
||||||
echo " processes status:" >> $DEBUG_LOG
|
systemctl -l status "${i}" >> "${DEBUG_LOG}"
|
||||||
$SUDO systemctl -l status $i >> "$DEBUG_LOG"
|
|
||||||
done
|
done
|
||||||
|
log_write ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
debugLighttpd() {
|
||||||
|
echo "::: Checking for necessary lighttpd files."
|
||||||
|
files_check "${LIGHTTPDFILE}"
|
||||||
|
files_check "${LIGHTTPDERRFILE}"
|
||||||
|
echo ":::"
|
||||||
|
}
|
||||||
|
|
||||||
|
countdown() {
|
||||||
|
tuvix=${TIMEOUT}
|
||||||
|
printf "::: Logging will automatically teminate in ${TIMEOUT} seconds\n"
|
||||||
|
while [ $tuvix -ge 1 ]
|
||||||
|
do
|
||||||
|
printf ":::\t${tuvix} seconds left. \r"
|
||||||
|
sleep 5
|
||||||
|
tuvix=$(( tuvix - 5 ))
|
||||||
|
done
|
||||||
|
}
|
||||||
### END FUNCTIONS ###
|
### END FUNCTIONS ###
|
||||||
|
|
||||||
### Check Pi internet connections ###
|
# Gather version of required packages / repositories
|
||||||
# Log the IP addresses of this Pi
|
version_check || echo "REQUIRED FILES MISSING"
|
||||||
IPADDR=$($SUDO ifconfig | perl -nle 's/dr:(\S+)/print $1/e')
|
# Check for newer setupVars storage file
|
||||||
echo "::: Writing local IPs to debug log"
|
source_file "/etc/pihole/setupVars.conf"
|
||||||
echo "IP Addresses of this Pi:" >> $DEBUG_LOG
|
# Gather information about the running distribution
|
||||||
echo "$IPADDR" >> $DEBUG_LOG
|
distro_check || echo "Distro Check soft fail"
|
||||||
echo >> $DEBUG_LOG
|
# Gather processor type
|
||||||
|
processor_check || echo "Processor Check soft fail"
|
||||||
|
|
||||||
# Check if we can connect to the local gateway
|
ip_check
|
||||||
GATEWAY_CHECK=$(ping -q -w 1 -c 1 "$(ip r | grep default | cut -d ' ' -f 3)" > /dev/null && echo ok || echo error)
|
|
||||||
echo "Gateway check:" >> $DEBUG_LOG
|
|
||||||
echo "$GATEWAY_CHECK" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
|
|
||||||
compareWhitelist
|
daemon_check lighttpd http
|
||||||
compareBlacklist
|
daemon_check dnsmasq domain
|
||||||
testNslookup
|
|
||||||
checkProcesses
|
checkProcesses
|
||||||
|
testResolver
|
||||||
|
debugLighttpd
|
||||||
|
|
||||||
echo "::: Writing dnsmasq.conf to debug log..."
|
files_check "${DNSMASQFILE}"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
files_check "${DNSMASQCONFFILE}"
|
||||||
echo "############### Dnsmasq ###############" >> $DEBUG_LOG
|
files_check "${WHITELISTFILE}"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
files_check "${BLACKLISTFILE}"
|
||||||
if [ -e "$DNSMASQFILE" ]
|
files_check "${ADLISTFILE}"
|
||||||
then
|
|
||||||
#cat $DNSMASQFILE >> $DEBUG_LOG
|
|
||||||
while read -r line; do
|
|
||||||
if [ ! -z "$line" ]; then
|
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
|
||||||
echo "$line" >> $DEBUG_LOG
|
|
||||||
fi
|
|
||||||
done < "$DNSMASQFILE"
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No dnsmasq.conf file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo dnsmasq.conf file found!\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::: Writing 01-pihole.conf to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "########### 01-pihole.conf ############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$PIHOLECONFFILE" ]
|
|
||||||
then
|
|
||||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
|
||||||
while read -r line; do
|
|
||||||
if [ ! -z "$line" ]; then
|
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
|
||||||
echo "$line" >> $DEBUG_LOG
|
|
||||||
fi
|
|
||||||
done < "$PIHOLECONFFILE"
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No 01-pihole.conf file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo 01-pihole.conf file found\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::: Writing lighttpd.conf to debug log..."
|
header_write "Analyzing gravity.list"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "############ lighttpd.conf ############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$LIGHTTPDFILE" ]
|
|
||||||
then
|
|
||||||
#cat "$PIHOLECONFFILE" >> $DEBUG_LOG
|
|
||||||
while read -r line; do
|
|
||||||
if [ ! -z "$line" ]; then
|
|
||||||
[[ "$line" =~ ^#.*$ ]] && continue
|
|
||||||
echo "$line" >> $DEBUG_LOG
|
|
||||||
fi
|
|
||||||
done < "$LIGHTTPDFILE"
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No lighttpd.conf file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo lighttpd.conf file found\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::: Writing size of gravity.list to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "############ gravity.list #############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$GRAVITYFILE" ]
|
|
||||||
then
|
|
||||||
wc -l "$GRAVITYFILE" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No gravity.list file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo gravity.list file found\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Write the hostname output to compare against entries in /etc/hosts, which is logged next
|
|
||||||
echo "Hostname of this pihole is: " >> $DEBUG_LOG
|
|
||||||
hostname >> $DEBUG_LOG
|
|
||||||
|
|
||||||
echo "::: Writing hosts file to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "################ Hosts ################" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$HOSTSFILE" ]
|
|
||||||
then
|
|
||||||
cat "$HOSTSFILE" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No hosts file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo hosts file found!\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
### PiHole application specific logging ###
|
|
||||||
echo "::: Writing whitelist to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "############## Whitelist ##############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$WHITELISTFILE" ]
|
|
||||||
then
|
|
||||||
cat "$WHITELISTFILE" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No whitelist.txt file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo whitelist.txt file found!\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::: Writing blacklist to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "############## Blacklist ##############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$BLACKLISTFILE" ]
|
|
||||||
then
|
|
||||||
cat "$BLACKLISTFILE" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No blacklist.txt file found!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo blacklist.txt file found!\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "::: Writing adlists.list to debug log..."
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
echo "############ adlists.list #############" >> $DEBUG_LOG
|
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
|
||||||
if [ -e "$ADLISTSFILE" ]
|
|
||||||
then
|
|
||||||
cat "$ADLISTSFILE" >> $DEBUG_LOG
|
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
else
|
|
||||||
echo "No adlists.list file found... using adlists.default!" >> $DEBUG_LOG
|
|
||||||
printf ":::\tNo adlists.list file found... using adlists.default!\n"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
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
|
# Continuously append the pihole.log file to the pihole_debug.log file
|
||||||
function dumpPiHoleLog {
|
dumpPiHoleLog() {
|
||||||
trap '{ echo -e "\nFinishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
trap '{ echo -e "\n::: Finishing debug write from interrupt... Quitting!" ; exit 1; }' INT
|
||||||
echo -e "::: Writing current pihole traffic to debug log...\n:::\tTry loading any/all sites that you are having trouble with now... \n:::\t(Press ctrl+C to finish)"
|
echo "::: "
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
echo "::: --= User Action Required =--"
|
||||||
echo "############# pihole.log ##############" >> $DEBUG_LOG
|
echo -e "::: Try loading a site that you are having trouble with now from a client web browser.. \n:::\t(Press CTRL+C to finish logging.)"
|
||||||
echo "#######################################" >> $DEBUG_LOG
|
header_write "pihole.log"
|
||||||
if [ -e "$PIHOLELOG" ]
|
if [ -e "${PIHOLELOG}" ]; then
|
||||||
then
|
# Dummy process to use for flagging down tail to terminate
|
||||||
while true; do
|
countdown &
|
||||||
tail -f "$PIHOLELOG" >> $DEBUG_LOG
|
tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG}
|
||||||
echo >> $DEBUG_LOG
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
echo "No pihole.log file found!" >> $DEBUG_LOG
|
log_write "No pihole.log file found!"
|
||||||
printf ":::\tNo pihole.log file found!\n"
|
printf ":::\tNo pihole.log file found!\n"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Anything to be done after capturing of pihole.log terminates
|
# Anything to be done after capturing of pihole.log terminates
|
||||||
function finalWork {
|
finalWork() {
|
||||||
|
local tricorder
|
||||||
echo "::: Finshed debugging!"
|
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
|
||||||
|
|
||||||
|
# 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 "::: Thank you."
|
||||||
|
else
|
||||||
|
echo "::: There was an error uploading your debug log."
|
||||||
|
echo "::: Please try again or contact the Pi-hole team for assistance."
|
||||||
|
fi
|
||||||
|
echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log"
|
||||||
}
|
}
|
||||||
|
|
||||||
trap finalWork EXIT
|
trap finalWork EXIT
|
||||||
|
|
||||||
### Method calls for additional logging ###
|
### Method calls for additional logging ###
|
||||||
|
@@ -11,5 +11,5 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
echo -n "::: Flushing /var/log/pihole.log ..."
|
echo -n "::: Flushing /var/log/pihole.log ..."
|
||||||
truncate -s 0 /var/log/pihole.log
|
echo " " > /var/log/pihole.log
|
||||||
echo "... done!"
|
echo "... done!"
|
||||||
|
@@ -11,21 +11,6 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
############ FUNCTIONS ###########
|
############ FUNCTIONS ###########
|
||||||
# Run this script as root or under sudo
|
|
||||||
echo ":::"
|
|
||||||
if [[ $EUID -eq 0 ]];then
|
|
||||||
echo "::: You are root."
|
|
||||||
else
|
|
||||||
echo "::: sudo will be used."
|
|
||||||
# Check if it is actually installed
|
|
||||||
# If it isn't, exit because the install cannot complete
|
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
|
||||||
export SUDO="sudo"
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this script as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
|
# Borrowed from adafruit-pitft-helper < borrowed from raspi-config
|
||||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L324-L334
|
||||||
@@ -44,12 +29,12 @@ getInitSys() {
|
|||||||
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
# https://github.com/adafruit/Adafruit-PiTFT-Helper/blob/master/adafruit-pitft-helper#L274-L285
|
||||||
autoLoginPiToConsole() {
|
autoLoginPiToConsole() {
|
||||||
if [ -e /etc/init.d/lightdm ]; then
|
if [ -e /etc/init.d/lightdm ]; then
|
||||||
if [ $SYSTEMD -eq 1 ]; then
|
if [ ${SYSTEMD} -eq 1 ]; then
|
||||||
$SUDO systemctl set-default multi-user.target
|
systemctl set-default multi-user.target
|
||||||
$SUDO ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
ln -fs /etc/systemd/system/autologin@.service /etc/systemd/system/getty.target.wants/getty@tty1.service
|
||||||
else
|
else
|
||||||
$SUDO update-rc.d lightdm disable 2
|
update-rc.d lightdm disable 2
|
||||||
$SUDO sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/"
|
sed /etc/inittab -i -e "s/1:2345:respawn:\/sbin\/getty --noclear 38400 tty1/1:2345:respawn:\/bin\/login -f pi tty1 <\/dev\/tty1 >\/dev\/tty1 2>&1/"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -66,23 +51,23 @@ echo /usr/local/bin/chronometer.sh >> /home/pi/.bashrc
|
|||||||
|
|
||||||
# Set up the LCD screen based on Adafruits instuctions:
|
# Set up the LCD screen based on Adafruits instuctions:
|
||||||
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
|
# https://learn.adafruit.com/adafruit-pitft-28-inch-resistive-touchscreen-display-raspberry-pi/easy-install
|
||||||
curl -SLs https://apt.adafruit.com/add-pin | $SUDO bash
|
curl -SLs https://apt.adafruit.com/add-pin | bash
|
||||||
$SUDO apt-get -y install raspberrypi-bootloader
|
apt-get -y install raspberrypi-bootloader
|
||||||
$SUDO apt-get -y install adafruit-pitft-helper
|
apt-get -y install adafruit-pitft-helper
|
||||||
$SUDO adafruit-pitft-helper -t 28r
|
adafruit-pitft-helper -t 28r
|
||||||
|
|
||||||
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
|
# Download the cmdline.txt file that prevents the screen from going blank after a period of time
|
||||||
$SUDO mv /boot/cmdline.txt /boot/cmdline.orig
|
mv /boot/cmdline.txt /boot/cmdline.orig
|
||||||
$SUDO curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
|
curl -o /boot/cmdline.txt https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/cmdline.txt
|
||||||
|
|
||||||
# Back up the original file and download the new one
|
# Back up the original file and download the new one
|
||||||
$SUDO mv /etc/default/console-setup /etc/default/console-setup.orig
|
mv /etc/default/console-setup /etc/default/console-setup.orig
|
||||||
$SUDO curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
|
curl -o /etc/default/console-setup https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/console-setup
|
||||||
|
|
||||||
# Instantly apply the font change to the LCD screen
|
# Instantly apply the font change to the LCD screen
|
||||||
$SUDO setupcon
|
setupcon
|
||||||
|
|
||||||
$SUDO reboot
|
reboot
|
||||||
|
|
||||||
# Start showing the stats on the screen by running the command on another tty:
|
# Start showing the stats on the screen by running the command on another tty:
|
||||||
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
|
# http://unix.stackexchange.com/questions/170063/start-a-process-on-a-different-tty
|
||||||
|
166
advanced/Scripts/update.sh
Normal file
166
advanced/Scripts/update.sh
Normal file
@@ -0,0 +1,166 @@
|
|||||||
|
#!/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
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# Variables
|
||||||
|
|
||||||
|
readonly ADMIN_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
||||||
|
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}"
|
||||||
|
|
||||||
|
git -C "${directory}" status --short &> /dev/null
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
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}" > /dev/null)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
update_repo() {
|
||||||
|
local directory="${1}"
|
||||||
|
local retVal=0
|
||||||
|
# Pull the latest commits
|
||||||
|
|
||||||
|
# Stash all files not tracked for later retrieval
|
||||||
|
git -C "${directory}" stash --all --quiet &> /dev/null || ${retVal}=1
|
||||||
|
# Force a clean working directory for cloning
|
||||||
|
git -C "${directory}" clean --force -d &> /dev/null || ${retVal}=1
|
||||||
|
# Fetch latest changes and apply
|
||||||
|
git -C "${directory}" pull --quiet &> /dev/null || ${retVal}=1
|
||||||
|
return ${retVal}
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local pihole_version_current
|
||||||
|
local pihole_version_latest
|
||||||
|
local web_version_current
|
||||||
|
local web_version_latest
|
||||||
|
|
||||||
|
if ! is_repo "${PI_HOLE_FILES_DIR}" || ! is_repo "${ADMIN_INTERFACE_DIR}" ; then #This is unlikely
|
||||||
|
echo "::: Critical Error: One or more Pi-Hole repos are missing from system!"
|
||||||
|
echo "::: Please re-run install script from https://github.com/pi-hole/pi-hole"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "::: Checking for updates..."
|
||||||
|
# Checks Pi-hole version string in format vX.X.X
|
||||||
|
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
|
||||||
|
pihole_version_latest="$(/usr/local/bin/pihole version --pihole --latest)"
|
||||||
|
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
||||||
|
web_version_latest="$(/usr/local/bin/pihole version --admin --latest)"
|
||||||
|
|
||||||
|
if [[ "${pihole_version_latest}" == "-1" || "${web_version_latest}" == "-1" ]]; then
|
||||||
|
echo "*** Unable to contact GitHub for latest version. Please try again later, contact support if this continues."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Logic
|
||||||
|
# If latest versions are blank - we've probably hit Github rate limit (stop running `pihole -up so often!):
|
||||||
|
# Update anyway
|
||||||
|
# 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 [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Pi-hole version is $pihole_version_current"
|
||||||
|
echo "::: Web Admin version is $web_version_current"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Everything is up to date!"
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
elif [[ "${pihole_version_current}" == "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Pi-hole Web Admin files out of date"
|
||||||
|
getGitFiles "${ADMIN_INTERFACE_DIR}" "${ADMIN_INTERFACE_GIT_URL}"
|
||||||
|
|
||||||
|
web_updated=true
|
||||||
|
|
||||||
|
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" == "${web_version_latest}" ]]; then
|
||||||
|
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
|
||||||
|
core_updated=true
|
||||||
|
|
||||||
|
elif [[ "${pihole_version_current}" < "${pihole_version_latest}" ]] && [[ "${web_version_current}" < "${web_version_latest}" ]]; then
|
||||||
|
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
|
||||||
|
web_updated=true
|
||||||
|
core_updated=true
|
||||||
|
else
|
||||||
|
echo "*** Update script has malfunctioned, fallthrough reached. Please contact support"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${web_updated}" == true ]]; then
|
||||||
|
web_version_current="$(/usr/local/bin/pihole version --admin --current)"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Web Admin version is now at ${web_version_current}"
|
||||||
|
echo "::: If you had made any changes in '/var/www/html/admin/', they have been stashed using 'git stash'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "${core_updated}" == true ]]; then
|
||||||
|
pihole_version_current="$(/usr/local/bin/pihole version --pihole --current)"
|
||||||
|
echo ":::"
|
||||||
|
echo "::: Pi-hole version is now at ${pihole_version_current}"
|
||||||
|
echo "::: If you had made any changes in '/etc/.pihole/', they have been stashed using 'git stash'"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
@@ -1,69 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# Updates the Pi-hole web interface
|
|
||||||
#
|
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
WEB_INTERFACE_GIT_URL="https://github.com/pi-hole/AdminLTE.git"
|
|
||||||
WEB_INTERFACE_DIR="/var/www/html/admin"
|
|
||||||
|
|
||||||
main() {
|
|
||||||
prerequisites
|
|
||||||
if ! is_repo; then
|
|
||||||
make_repo
|
|
||||||
fi
|
|
||||||
update_repo
|
|
||||||
}
|
|
||||||
|
|
||||||
prerequisites() {
|
|
||||||
|
|
||||||
# must be root to update
|
|
||||||
if [[ $EUID -ne 0 ]]; then
|
|
||||||
sudo bash "$0" "$@"
|
|
||||||
exit $?
|
|
||||||
fi
|
|
||||||
|
|
||||||
# web interface must already exist. this is a (lazy)
|
|
||||||
# check to make sure pihole is actually installed.
|
|
||||||
if [ ! -d "$WEB_INTERFACE_DIR" ]; then
|
|
||||||
echo "$WEB_INTERFACE_DIR not found. Exiting."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! type "git" > /dev/null; then
|
|
||||||
apt-get -y install git
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
is_repo() {
|
|
||||||
# if the web interface directory does not have a .git folder
|
|
||||||
# it means its using the master.zip archive from the install
|
|
||||||
# script.
|
|
||||||
if [ ! -d "$WEB_INTERFACE_DIR/.git" ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
# removes the web interface installed from the master.zip archive and
|
|
||||||
# replaces it with the current master branch from github
|
|
||||||
make_repo() {
|
|
||||||
# remove the non-repod interface and clone the interface
|
|
||||||
rm -rf $WEB_INTERFACE_DIR
|
|
||||||
git clone "$WEB_INTERFACE_GIT_URL" "$WEB_INTERFACE_DIR"
|
|
||||||
}
|
|
||||||
|
|
||||||
# pulls the latest master branch from github
|
|
||||||
update_repo() {
|
|
||||||
# pull the latest commits
|
|
||||||
cd "$WEB_INTERFACE_DIR"
|
|
||||||
git pull
|
|
||||||
}
|
|
||||||
|
|
||||||
main
|
|
102
advanced/Scripts/version.sh
Normal file
102
advanced/Scripts/version.sh
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
#!/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
|
||||||
|
# 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
|
||||||
|
|
||||||
|
DEFAULT="-1"
|
||||||
|
|
||||||
|
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}})"
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
helpFunc() {
|
||||||
|
cat << EOM
|
||||||
|
:::
|
||||||
|
::: Show Pi-hole/Web Admin versions
|
||||||
|
:::
|
||||||
|
::: Usage: pihole -v [ -a | -p ] [ -l | -c ]
|
||||||
|
:::
|
||||||
|
::: Options:
|
||||||
|
::: -a, --admin Show both current and latest versions of web admin
|
||||||
|
::: -p, --pihole Show both current and latest versions of Pi-hole core files
|
||||||
|
::: -l, --latest (Only after -a | -p) Return only latest version
|
||||||
|
::: -c, --current (Only after -a | -p) Return only current version
|
||||||
|
::: -h, --help Show this help dialog
|
||||||
|
:::
|
||||||
|
EOM
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
257
advanced/Scripts/webpage.sh
Executable file
257
advanced/Scripts/webpage.sh
Executable file
@@ -0,0 +1,257 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Pi-hole: A black hole for Internet advertisements
|
||||||
|
# Network-wide ad blocking via your Raspberry Pi
|
||||||
|
# http://pi-hole.net
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
args=("$@")
|
||||||
|
|
||||||
|
helpFunc() {
|
||||||
|
cat << EOM
|
||||||
|
::: Set admin options for the web interface of pihole
|
||||||
|
:::
|
||||||
|
::: Usage: pihole -a [options]
|
||||||
|
:::
|
||||||
|
::: Options:
|
||||||
|
::: -p, password Set web interface password, an empty input will remove any previously set password
|
||||||
|
::: -c, celsius Set Celsius temperature unit
|
||||||
|
::: -f, fahrenheit Set Fahrenheit temperature unit
|
||||||
|
::: -k, kelvin Set Kelvin temperature unit
|
||||||
|
::: -h, --help Show this help dialog
|
||||||
|
EOM
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
SetTemperatureUnit(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/TEMPERATUREUNIT/d' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "TEMPERATUREUNIT=${unit}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWebPassword(){
|
||||||
|
|
||||||
|
if [ "${SUDO_USER}" == "www-data" ]; then
|
||||||
|
echo "Security measure: user www-data is not allowed to change webUI password!"
|
||||||
|
echo "Exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${SUDO_USER}" == "lighttpd" ]; then
|
||||||
|
echo "Security measure: user lighttpd is not allowed to change webUI password!"
|
||||||
|
echo "Exiting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove password from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/WEBPASSWORD/d' /etc/pihole/setupVars.conf
|
||||||
|
# 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.*$//')
|
||||||
|
# Save hash to file
|
||||||
|
echo "WEBPASSWORD=${hash}" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "New password set"
|
||||||
|
else
|
||||||
|
echo "Password removed"
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDNSServers(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/PIHOLE_DNS_1/d;/PIHOLE_DNS_2/d;/DNS_FQDN_REQUIRED/d;/DNS_BOGUS_PRIV/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "PIHOLE_DNS_1=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
if [[ "${args[3]}" != "none" ]]; then
|
||||||
|
echo "PIHOLE_DNS_2=${args[3]}" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
echo "PIHOLE_DNS_2=" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Replace within actual dnsmasq config file
|
||||||
|
sed -i '/server=/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "server=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
if [[ "${args[3]}" != "none" ]]; then
|
||||||
|
echo "server=${args[3]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove domain-needed entry
|
||||||
|
sed -i '/domain-needed/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Readd it if required
|
||||||
|
if [[ "${args[4]}" == "domain-needed" ]]; then
|
||||||
|
echo "domain-needed" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "DNS_FQDN_REQUIRED=true" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
# Leave it deleted if not wanted
|
||||||
|
echo "DNS_FQDN_REQUIRED=false" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Remove bogus-priv entry
|
||||||
|
sed -i '/bogus-priv/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Readd it if required
|
||||||
|
if [[ "${args[5]}" == "bogus-priv" ]]; then
|
||||||
|
echo "bogus-priv" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "DNS_BOGUS_PRIV=true" >> /etc/pihole/setupVars.conf
|
||||||
|
else
|
||||||
|
# Leave it deleted if not wanted
|
||||||
|
echo "DNS_BOGUS_PRIV=false" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart dnsmasq to load new configuration
|
||||||
|
RestartDNS
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetExcludeDomains(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_EXCLUDE_DOMAINS/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_EXCLUDE_DOMAINS=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
SetExcludeClients(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_EXCLUDE_CLIENTS/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_EXCLUDE_CLIENTS=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
Reboot(){
|
||||||
|
|
||||||
|
nohup bash -c "sleep 5; reboot" &> /dev/null </dev/null &
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
RestartDNS(){
|
||||||
|
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq &> /dev/null
|
||||||
|
else
|
||||||
|
service dnsmasq restart &> /dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetQueryLogOptions(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/API_QUERY_LOG_SHOW/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "API_QUERY_LOG_SHOW=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
|
||||||
|
EnableDHCP(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/DHCP_/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ACTIVE=true" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_START=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_END=${args[3]}" >> /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ROUTER=${args[4]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Remove setting from file
|
||||||
|
sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "dhcp-range=${args[2]},${args[3]},infinite" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "dhcp-option=option:router,${args[4]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Changes the behaviour from strict RFC compliance so that DHCP requests on unknown leases from unknown hosts are not ignored. This allows new hosts to get a lease without a tedious timeout under all circumstances. It also allows dnsmasq to rebuild its lease database without each client needing to reacquire a lease, if the database is lost.
|
||||||
|
echo "dhcp-authoritative" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Use the specified file to store DHCP lease information
|
||||||
|
echo "dhcp-leasefile=/etc/pihole/dhcp.leases" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
# Suppress logging of the routine operation of these protocols. Errors and problems will still be logged, though.
|
||||||
|
echo "quiet-dhcp" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "quiet-dhcp6" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
RestartDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableDHCP(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/DHCP_ACTIVE/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "DHCP_ACTIVE=false" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Remove setting from file
|
||||||
|
sed -i '/dhcp-/d;/quiet-dhcp/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
RestartDNS
|
||||||
|
}
|
||||||
|
|
||||||
|
SetWebUILayout(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/WEBUIBOXEDLAYOUT/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "WEBUIBOXEDLAYOUT=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
SetDNSDomainName(){
|
||||||
|
|
||||||
|
# Remove setting from file (create backup setupVars.conf.bak)
|
||||||
|
sed -i.bak '/PIHOLE_DOMAIN/d;' /etc/pihole/setupVars.conf
|
||||||
|
# Save setting to file
|
||||||
|
echo "PIHOLE_DOMAIN=${args[2]}" >> /etc/pihole/setupVars.conf
|
||||||
|
|
||||||
|
# Replace within actual dnsmasq config file
|
||||||
|
sed -i '/domain=/d;' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "domain=${args[2]}" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
|
||||||
|
# Restart dnsmasq to load new configuration
|
||||||
|
RestartDNS
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ResolutionSettings() {
|
||||||
|
|
||||||
|
typ=${args[2]}
|
||||||
|
state=${args[3]}
|
||||||
|
|
||||||
|
if [[ "${typ}" == "forward" ]]; then
|
||||||
|
sed -i.bak '/API_GET_UPSTREAM_DNS_HOSTNAME/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "API_GET_UPSTREAM_DNS_HOSTNAME=${state}" >> /etc/pihole/setupVars.conf
|
||||||
|
elif [[ "${typ}" == "clients" ]]; then
|
||||||
|
sed -i.bak '/API_GET_CLIENT_HOSTNAME/d;' /etc/pihole/setupVars.conf
|
||||||
|
echo "API_GET_CLIENT_HOSTNAME=${state}" >> /etc/pihole/setupVars.conf
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "${args[1]}" in
|
||||||
|
"-p" | "password" ) SetWebPassword;;
|
||||||
|
"-c" | "celsius" ) unit="C"; SetTemperatureUnit;;
|
||||||
|
"-f" | "fahrenheit" ) unit="F"; SetTemperatureUnit;;
|
||||||
|
"-k" | "kelvin" ) unit="K"; SetTemperatureUnit;;
|
||||||
|
"setdns" ) SetDNSServers;;
|
||||||
|
"setexcludedomains" ) SetExcludeDomains;;
|
||||||
|
"setexcludeclients" ) SetExcludeClients;;
|
||||||
|
"reboot" ) Reboot;;
|
||||||
|
"restartdns" ) RestartDNS;;
|
||||||
|
"setquerylog" ) SetQueryLogOptions;;
|
||||||
|
"enabledhcp" ) EnableDHCP;;
|
||||||
|
"disabledhcp" ) DisableDHCP;;
|
||||||
|
"layout" ) SetWebUILayout;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"domainname" ) SetDNSDomainName;;
|
||||||
|
"resolve" ) ResolutionSettings;;
|
||||||
|
* ) helpFunc;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
|
||||||
|
if [[ $# = 0 ]]; then
|
||||||
|
helpFunc
|
||||||
|
fi
|
||||||
|
|
@@ -1,210 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
# Pi-hole: A black hole for Internet advertisements
|
|
||||||
# (c) 2015, 2016 by Jacob Salmela
|
|
||||||
# Network-wide ad blocking via your Raspberry Pi
|
|
||||||
# http://pi-hole.net
|
|
||||||
# Whitelists domains
|
|
||||||
#
|
|
||||||
# Pi-hole is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
|
||||||
echo "::: Immediately whitelists one or more domains in the hosts file"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]"
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Options:"
|
|
||||||
echo "::: -d, --delmode Remove domains from the whitelist"
|
|
||||||
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
|
|
||||||
echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
|
|
||||||
echo "::: -q, --quiet output is less verbose"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
#globals
|
|
||||||
basename=pihole
|
|
||||||
piholeDir=/etc/$basename
|
|
||||||
adList=$piholeDir/gravity.list
|
|
||||||
whitelist=$piholeDir/whitelist.txt
|
|
||||||
reload=true
|
|
||||||
addmode=true
|
|
||||||
force=false
|
|
||||||
versbose=true
|
|
||||||
|
|
||||||
domList=()
|
|
||||||
domToRemoveList=()
|
|
||||||
|
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
|
||||||
|
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
|
||||||
|
|
||||||
modifyHost=false
|
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
|
||||||
echo "::: Local calibration requested..."
|
|
||||||
. $piholeDir/pihole.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
function HandleOther(){
|
|
||||||
#check validity of domain
|
|
||||||
validDomain=$(echo "$1" | perl -ne'print if /\b((?=[a-z0-9-]{1,63}\.)(xn--)?[a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,63}\b/')
|
|
||||||
if [ -z "$validDomain" ]; then
|
|
||||||
echo "::: $1 is not a valid argument or domain name"
|
|
||||||
else
|
|
||||||
domList=("${domList[@]}" $validDomain)
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function PopWhitelistFile(){
|
|
||||||
#check whitelist file exists, and if not, create it
|
|
||||||
if [[ ! -f $whitelist ]];then
|
|
||||||
touch $whitelist
|
|
||||||
fi
|
|
||||||
for dom in "${domList[@]}"
|
|
||||||
do
|
|
||||||
if $addmode; then
|
|
||||||
AddDomain "$dom"
|
|
||||||
else
|
|
||||||
RemoveDomain "$dom"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function AddDomain(){
|
|
||||||
#| sed 's/\./\\./g'
|
|
||||||
bool=false
|
|
||||||
|
|
||||||
grep -Ex -q "$1" $whitelist || bool=true
|
|
||||||
if $bool; then
|
|
||||||
#domain not found in the whitelist file, add it!
|
|
||||||
if $versbose; then
|
|
||||||
echo -n "::: Adding $1 to $whitelist..."
|
|
||||||
fi
|
|
||||||
echo "$1" >> $whitelist
|
|
||||||
modifyHost=true
|
|
||||||
if $versbose; then
|
|
||||||
echo " done!"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: $1 already exists in $whitelist, no need to add!"
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function RemoveDomain(){
|
|
||||||
|
|
||||||
bool=false
|
|
||||||
grep -Ex -q "$1" $whitelist || bool=true
|
|
||||||
if $bool; then
|
|
||||||
#Domain is not in the whitelist file, no need to Remove
|
|
||||||
if $versbose; then
|
|
||||||
echo "::: $1 is NOT whitelisted! No need to remove"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
#Domain is in the whitelist file, add to a temporary array and remove from whitelist file
|
|
||||||
#if $versbose; then
|
|
||||||
#echo "::: Un-whitelisting $dom..."
|
|
||||||
#fi
|
|
||||||
domToRemoveList=("${domToRemoveList[@]}" $1)
|
|
||||||
modifyHost=true
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function ModifyHostFile(){
|
|
||||||
if $addmode; then
|
|
||||||
#remove domains in from hosts file
|
|
||||||
if [[ -r $whitelist ]];then
|
|
||||||
# Remove whitelist entries
|
|
||||||
numberOf=$(cat $whitelist | sed '/^\s*$/d' | wc -l)
|
|
||||||
plural=; [[ "$numberOf" != "1" ]] && plural=s
|
|
||||||
echo ":::"
|
|
||||||
echo -n "::: Modifying HOSTS file to whitelist $numberOf domain${plural}..."
|
|
||||||
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIP $line"; done > /etc/pihole/whitelist.tmp
|
|
||||||
awk -F':' '{print $1}' $whitelist | while read -r line; do echo "$piholeIPv6 $line"; done >> /etc/pihole/whitelist.tmp
|
|
||||||
echo "l" >> /etc/pihole/whitelist.tmp
|
|
||||||
grep -F -x -v -f $piholeDir/whitelist.tmp $adList > $piholeDir/gravity.tmp
|
|
||||||
rm $adList
|
|
||||||
mv $piholeDir/gravity.tmp $adList
|
|
||||||
rm $piholeDir/whitelist.tmp
|
|
||||||
echo " done!"
|
|
||||||
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
#we need to add the removed domains to the hosts file
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Modifying HOSTS file to un-whitelist domains..."
|
|
||||||
for rdom in "${domToRemoveList[@]}"
|
|
||||||
do
|
|
||||||
if [[ -n $piholeIPv6 ]];then
|
|
||||||
echo -n "::: Un-whitelisting $rdom on IPv4 and IPv6..."
|
|
||||||
echo "$rdom" | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
|
|
||||||
echo " done!"
|
|
||||||
else
|
|
||||||
echo -n "::: Un-whitelisting $rdom on IPv4"
|
|
||||||
echo "$rdom" | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
|
|
||||||
echo " done!"
|
|
||||||
fi
|
|
||||||
echo -n "::: Removing $rdom from $whitelist..."
|
|
||||||
echo "$rdom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $whitelist
|
|
||||||
echo " done!"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function Reload() {
|
|
||||||
# Reload hosts file
|
|
||||||
echo ":::"
|
|
||||||
echo -n "::: Refresh lists in dnsmasq..."
|
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
|
||||||
# service already running - reload config
|
|
||||||
sudo kill -HUP "$dnsmasqPid"
|
|
||||||
else
|
|
||||||
# service not running, start it up
|
|
||||||
sudo service dnsmasq start
|
|
||||||
fi
|
|
||||||
echo " done!"
|
|
||||||
}
|
|
||||||
|
|
||||||
###################################################
|
|
||||||
|
|
||||||
for var in "$@"
|
|
||||||
do
|
|
||||||
case "$var" in
|
|
||||||
"-nr"| "--noreload" ) reload=false;;
|
|
||||||
"-d" | "--delmode" ) addmode=false;;
|
|
||||||
"-f" | "--force" ) force=true;;
|
|
||||||
"-q" | "--quiet" ) versbose=false;;
|
|
||||||
* ) HandleOther "$var";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
PopWhitelistFile
|
|
||||||
|
|
||||||
if $modifyHost || $force; then
|
|
||||||
ModifyHostFile
|
|
||||||
else
|
|
||||||
if $versbose; then
|
|
||||||
echo ":::"
|
|
||||||
echo "::: No changes need to be made"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if $reload; then
|
|
||||||
Reload
|
|
||||||
fi
|
|
@@ -1,10 +1,9 @@
|
|||||||
_pihole()
|
_pihole() {
|
||||||
{
|
|
||||||
local cur prev opts
|
local cur prev opts
|
||||||
COMPREPLY=()
|
COMPREPLY=()
|
||||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer uninstall help"
|
opts="admin blacklist chronometer debug disable enable flush help logging query reconfigure restartdns setupLCD status tail uninstall updateGravity updatePihole version whitelist"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
|
||||||
return 0
|
return 0
|
||||||
|
@@ -1,4 +1,7 @@
|
|||||||
<html>
|
<html>
|
||||||
|
<head>
|
||||||
|
<script>window.close();</script>
|
||||||
|
</head>
|
||||||
<body>
|
<body>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@@ -12,6 +12,7 @@
|
|||||||
server.modules = (
|
server.modules = (
|
||||||
"mod_access",
|
"mod_access",
|
||||||
"mod_accesslog",
|
"mod_accesslog",
|
||||||
|
"mod_auth",
|
||||||
"mod_expire",
|
"mod_expire",
|
||||||
"mod_compress",
|
"mod_compress",
|
||||||
"mod_redirect",
|
"mod_redirect",
|
||||||
@@ -46,13 +47,20 @@ include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
|||||||
# If the URL starts with /admin, it is the Web interface
|
# If the URL starts with /admin, it is the Web interface
|
||||||
$HTTP["url"] =~ "^/admin/" {
|
$HTTP["url"] =~ "^/admin/" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
setenv.add-response-header = (
|
||||||
|
"X-Pi-hole" => "The Pi-hole Web interface is working!",
|
||||||
|
"X-Frame-Options" => "DENY"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Rewite js requests, must be out of $HTTP block due to bug #2526
|
||||||
|
url.rewrite = ( "^(?!/admin/).*\.js$" => "pihole/index.js" )
|
||||||
|
|
||||||
# If the URL does not start with /admin, then it is a query for an ad domain
|
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||||
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||||
# Create a response header for debugging using curl -I
|
# Create a response header for debugging using curl -I
|
||||||
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||||
# rewrite only js requests
|
|
||||||
url.rewrite = ("(.*).js" => "pihole/index.js")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add user chosen options held in external file
|
||||||
|
include_shell "cat external.conf 2>/dev/null"
|
83
advanced/lighttpd.conf.fedora
Normal file
83
advanced/lighttpd.conf.fedora
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
# 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
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
server.modules = (
|
||||||
|
"mod_access",
|
||||||
|
"mod_auth",
|
||||||
|
"mod_fastcgi",
|
||||||
|
"mod_accesslog",
|
||||||
|
"mod_expire",
|
||||||
|
"mod_compress",
|
||||||
|
"mod_redirect",
|
||||||
|
"mod_setenv",
|
||||||
|
"mod_rewrite"
|
||||||
|
)
|
||||||
|
|
||||||
|
server.document-root = "/var/www/html"
|
||||||
|
server.error-handler-404 = "pihole/index.html"
|
||||||
|
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"
|
||||||
|
|
||||||
|
|
||||||
|
index-file.names = ( "index.php", "index.html", "index.lighttpd.html" )
|
||||||
|
url.access-deny = ( "~", ".inc" )
|
||||||
|
static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )
|
||||||
|
|
||||||
|
compress.cache-dir = "/var/cache/lighttpd/compress/"
|
||||||
|
compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" )
|
||||||
|
|
||||||
|
mimetype.assign = ( ".png" => "image/png",
|
||||||
|
".jpg" => "image/jpeg",
|
||||||
|
".jpeg" => "image/jpeg",
|
||||||
|
".html" => "text/html",
|
||||||
|
".css" => "text/css; charset=utf-8",
|
||||||
|
".js" => "application/javascript",
|
||||||
|
".json" => "application/json",
|
||||||
|
".txt" => "text/plain",
|
||||||
|
".svg" => "image/svg+xml" )
|
||||||
|
|
||||||
|
# default listening port for IPv6 falls back to the IPv4 port
|
||||||
|
#include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port
|
||||||
|
#include_shell "/usr/share/lighttpd/create-mime.assign.pl"
|
||||||
|
#include_shell "/usr/share/lighttpd/include-conf-enabled.pl"
|
||||||
|
|
||||||
|
fastcgi.server = ( ".php" =>
|
||||||
|
( "localhost" =>
|
||||||
|
(
|
||||||
|
"socket" => "/tmp/php-fastcgi.socket",
|
||||||
|
"bin-path" => "/usr/bin/php-cgi"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
# If the URL starts with /admin, it is the Web interface
|
||||||
|
$HTTP["url"] =~ "^/admin/" {
|
||||||
|
# Create a response header for debugging using curl -I
|
||||||
|
setenv.add-response-header = ( "X-Pi-hole" => "The Pi-hole Web interface is working!" )
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rewite js requests, must be out of $HTTP block due to bug #2526
|
||||||
|
url.rewrite = ( "^(?!/admin/).*\.js$" => "pihole/index.js" )
|
||||||
|
|
||||||
|
# If the URL does not start with /admin, then it is a query for an ad domain
|
||||||
|
$HTTP["url"] =~ "^(?!/admin)/.*" {
|
||||||
|
# Create a response header for debugging using curl -I
|
||||||
|
setenv.add-response-header = ( "X-Pi-hole" => "A black hole for Internet advertisements." )
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add user chosen options held in external file
|
||||||
|
include_shell "cat external.conf 2>/dev/null"
|
@@ -8,19 +8,20 @@
|
|||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
# is updated or re-installed. Please make any changes to the appropriate crontab
|
||||||
|
# or other cron file snippets.
|
||||||
|
PATH="$PATH:/usr/local/bin/"
|
||||||
|
|
||||||
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
# Pi-hole: Update the ad sources once a week on Sunday at 01:59
|
||||||
# Download any updates from the adlists
|
# Download any updates from the adlists
|
||||||
59 1 * * 7 root /usr/local/bin/gravity.sh
|
59 1 * * 7 root pihole updateGravity
|
||||||
|
|
||||||
# Pi-hole: Update the Web interface shortly after gravity runs
|
# Pi-hole: Update Pi-hole! Uncomment to enable auto update
|
||||||
# This should also update the version number if it is changed in the dashboard repo
|
#30 2 * * 7 root pihole updatePihole
|
||||||
30 2 * * 7 root /usr/local/bin/updateDashboard.sh
|
|
||||||
|
|
||||||
# Pi-hole: Parse the log file before it is flushed and save the stats to a database
|
# Pi-hole: Flush the log daily at 00:00 so it doesn't get out of control
|
||||||
# This will be used for a historical view of your Pi-hole's performance
|
|
||||||
#50 23 * * * root /usr/local/bin/dailyLog.sh
|
|
||||||
|
|
||||||
# Pi-hole: Flush the log daily at 11:58 so it doesn't get out of control
|
|
||||||
# Stats will be viewable in the Web interface thanks to the cron job above
|
# Stats will be viewable in the Web interface thanks to the cron job above
|
||||||
58 23 * * * root /usr/local/bin/piholeLogFlush.sh
|
00 00 * * * root pihole flush
|
||||||
|
11
advanced/pihole.sudo
Normal file
11
advanced/pihole.sudo
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# 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
|
||||||
|
# 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.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@@ -11,13 +11,13 @@
|
|||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
# Must be root to uninstall
|
# Must be root to uninstall
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ ${EUID} -eq 0 ]]; then
|
||||||
echo "::: You are root."
|
echo "::: You are root."
|
||||||
else
|
else
|
||||||
echo "::: Sudo will be used for the uninstall."
|
echo "::: Sudo will be used for the uninstall."
|
||||||
# Check if it is actually installed
|
# Check if it is actually installed
|
||||||
# If it isn't, exit because the unnstall cannot complete
|
# If it isn't, exit because the unnstall cannot complete
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
if [ -x "$(command -v sudo)" ]; then
|
||||||
export SUDO="sudo"
|
export SUDO="sudo"
|
||||||
else
|
else
|
||||||
echo "::: Please install sudo or run this as root."
|
echo "::: Please install sudo or run this as root."
|
||||||
@@ -25,67 +25,96 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
spinner()
|
# Compatability
|
||||||
{
|
if [ -x "$(command -v rpm)" ]; then
|
||||||
|
# Fedora Family
|
||||||
|
if [ -x "$(command -v dnf)" ]; then
|
||||||
|
PKG_MANAGER="dnf"
|
||||||
|
else
|
||||||
|
PKG_MANAGER="yum"
|
||||||
|
fi
|
||||||
|
PKG_REMOVE="${PKG_MANAGER} remove -y"
|
||||||
|
PIHOLE_DEPS=( bind-utils bc dnsmasq lighttpd lighttpd-fastcgi php-common git curl unzip wget findutils )
|
||||||
|
package_check() {
|
||||||
|
rpm -qa | grep ^$1- > /dev/null
|
||||||
|
}
|
||||||
|
package_cleanup() {
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
|
}
|
||||||
|
elif [ -x "$(command -v apt-get)" ]; then
|
||||||
|
# Debian Family
|
||||||
|
PKG_MANAGER="apt-get"
|
||||||
|
PKG_REMOVE="${PKG_MANAGER} -y remove --purge"
|
||||||
|
PIHOLE_DEPS=( dnsutils bc dnsmasq lighttpd php5-common git curl unzip wget )
|
||||||
|
package_check() {
|
||||||
|
dpkg-query -W -f='${Status}' "$1" 2>/dev/null | grep -c "ok installed"
|
||||||
|
}
|
||||||
|
package_cleanup() {
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoremove
|
||||||
|
${SUDO} ${PKG_MANAGER} -y autoclean
|
||||||
|
}
|
||||||
|
else
|
||||||
|
echo "OS distribution not supported"
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
spinner() {
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local delay=0.50
|
local delay=0.50
|
||||||
local spinstr='/-\|'
|
local spinstr='/-\|'
|
||||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
while [ "$(ps a | awk '{print $1}' | grep "${pid}")" ]; do
|
||||||
local temp=${spinstr#?}
|
local temp=${spinstr#?}
|
||||||
printf " [%c] " "$spinstr"
|
printf " [%c] " "${spinstr}"
|
||||||
local spinstr=$temp${spinstr%"$temp"}
|
local spinstr=${temp}${spinstr%"$temp}"}
|
||||||
sleep $delay
|
sleep ${delay}
|
||||||
printf "\b\b\b\b\b\b"
|
printf "\b\b\b\b\b\b"
|
||||||
done
|
done
|
||||||
printf " \b\b\b\b"
|
printf " \b\b\b\b"
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeAndPurge {
|
removeAndPurge() {
|
||||||
# Purge dependencies
|
# Purge dependencies
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Nate 3/28/2016 - Removed `php5-cgi` and `php5` as they are removed with php5-common
|
for i in "${PIHOLE_DEPS[@]}"; do
|
||||||
dependencies=( dnsutils bc toilet figlet dnsmasq lighttpd php5-common git curl unzip wget )
|
package_check ${i} > /dev/null
|
||||||
for i in "${dependencies[@]}"; do
|
if [ $? -eq 0 ]; then
|
||||||
if [ "$(dpkg-query -W --showformat='${Status}\n' "$i" 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
|
||||||
while true; do
|
while true; do
|
||||||
read -rp "::: Do you wish to remove $i from your system? [y/n]: " yn
|
read -rp "::: Do you wish to remove ${i} from your system? [y/n]: " yn
|
||||||
case $yn in
|
case ${yn} in
|
||||||
[Yy]* ) printf ":::\tRemoving %s..." "$i"; $SUDO apt-get -y remove --purge "$i" &> /dev/null & spinner $!; printf "done!\n"; break;;
|
[Yy]* ) printf ":::\tRemoving %s..." "${i}"; ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null & spinner $!; printf "done!\n"; break;;
|
||||||
[Nn]* ) printf ":::\tSkipping %s" "$i\n"; break;;
|
[Nn]* ) printf ":::\tSkipping %s\n" "${i}"; break;;
|
||||||
* ) printf "::: You must answer yes or no!\n";;
|
* ) printf "::: You must answer yes or no!\n";;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
printf ":::\tPackage %s not installed... Not removing.\n" "$i"
|
printf ":::\tPackage %s not installed... Not removing.\n" "${i}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove dependency config files
|
# Remove dependency config files
|
||||||
echo "::: Removing dnsmasq config files..."
|
echo "::: Removing dnsmasq config files..."
|
||||||
$SUDO rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.conf /etc/dnsmasq.conf.orig /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
|
|
||||||
# Take care of any additional package cleaning
|
# Take care of any additional package cleaning
|
||||||
printf "::: Auto removing remaining dependencies..."
|
printf "::: Auto removing & cleaning remaining dependencies..."
|
||||||
$SUDO apt-get -y autoremove &> /dev/null & spinner $!; printf "done!\n";
|
package_cleanup &> /dev/null & spinner $!; printf "done!\n";
|
||||||
printf "::: Auto cleaning remaining dependencies..."
|
|
||||||
$SUDO apt-get -y autoclean &> /dev/null & spinner $!; printf "done!\n";
|
|
||||||
|
|
||||||
# Call removeNoPurge to remove PiHole specific files
|
# Call removeNoPurge to remove PiHole specific files
|
||||||
removeNoPurge
|
removeNoPurge
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeNoPurge {
|
removeNoPurge() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Only web directories/files that are created by pihole should be removed.
|
# Only web directories/files that are created by pihole should be removed.
|
||||||
echo "::: Removing the Pi-hole Web server files..."
|
echo "::: Removing the Pi-hole Web server files..."
|
||||||
$SUDO rm -rf /var/www/html/admin &> /dev/null
|
${SUDO} rm -rf /var/www/html/admin &> /dev/null
|
||||||
$SUDO rm -rf /var/www/html/pihole &> /dev/null
|
${SUDO} rm -rf /var/www/html/pihole &> /dev/null
|
||||||
$SUDO rm /var/www/html/index.lighttpd.orig &> /dev/null
|
${SUDO} rm /var/www/html/index.lighttpd.orig &> /dev/null
|
||||||
|
|
||||||
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
# If the web directory is empty after removing these files, then the parent html folder can be removed.
|
||||||
if [ -d "/var/www/html" ]; then
|
if [ -d "/var/www/html" ]; then
|
||||||
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
if [[ ! "$(ls -A /var/www/html)" ]]; then
|
||||||
$SUDO rm -rf /var/www/html &> /dev/null
|
${SUDO} rm -rf /var/www/html &> /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -95,34 +124,42 @@ function removeNoPurge {
|
|||||||
# preserved.
|
# preserved.
|
||||||
if [[ -f /etc/crontab.orig ]]; then
|
if [[ -f /etc/crontab.orig ]]; then
|
||||||
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
echo "::: Initial Pi-hole cron detected. Restoring the default system cron..."
|
||||||
$SUDO mv /etc/crontab /etc/crontab.pihole
|
${SUDO} mv /etc/crontab /etc/crontab.pihole
|
||||||
$SUDO mv /etc/crontab.orig /etc/crontab
|
${SUDO} mv /etc/crontab.orig /etc/crontab
|
||||||
$SUDO service cron restart
|
${SUDO} service cron restart
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Attempt to preserve backwards compatibility with older versions
|
# Attempt to preserve backwards compatibility with older versions
|
||||||
if [[ -f /etc/cron.d/pihole ]];then
|
if [[ -f /etc/cron.d/pihole ]];then
|
||||||
echo "::: Removing cron.d/pihole..."
|
echo "::: Removing cron.d/pihole..."
|
||||||
$SUDO rm /etc/cron.d/pihole &> /dev/null
|
${SUDO} rm /etc/cron.d/pihole &> /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "::: Removing config files and scripts..."
|
echo "::: Removing config files and scripts..."
|
||||||
if [ ! "$(dpkg-query -W --showformat='${Status}\n' lighttpd 2> /dev/null | grep -c "ok installed")" -eq 1 ]; then
|
package_check lighttpd > /dev/null
|
||||||
$SUDO rm -rf /etc/lighttpd/ &> /dev/null
|
if [ $? -eq 1 ]; then
|
||||||
|
${SUDO} rm -rf /etc/lighttpd/ &> /dev/null
|
||||||
else
|
else
|
||||||
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
if [ -f /etc/lighttpd/lighttpd.conf.orig ]; then
|
||||||
$SUDO mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
${SUDO} mv /etc/lighttpd/lighttpd.conf.orig /etc/lighttpd/lighttpd.conf
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
$SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.d/adList.conf &> /dev/null
|
||||||
$SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
${SUDO} rm /etc/dnsmasq.d/01-pihole.conf &> /dev/null
|
||||||
$SUDO rm -rf /var/log/*pihole* &> /dev/null
|
${SUDO} rm -rf /var/log/*pihole* &> /dev/null
|
||||||
$SUDO rm -rf /etc/pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/pihole/ &> /dev/null
|
||||||
$SUDO rm -rf /etc/.pihole/ &> /dev/null
|
${SUDO} rm -rf /etc/.pihole/ &> /dev/null
|
||||||
$SUDO rm -rf /opt/pihole/ &> /dev/null
|
${SUDO} rm -rf /opt/pihole/ &> /dev/null
|
||||||
$SUDO rm /usr/local/bin/pihole &> /dev/null
|
${SUDO} rm /usr/local/bin/pihole &> /dev/null
|
||||||
$SUDO rm /etc/bash_completion.d/pihole
|
${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..."
|
||||||
|
${SUDO} userdel -r pihole
|
||||||
|
fi
|
||||||
|
|
||||||
echo ":::"
|
echo ":::"
|
||||||
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
printf "::: Finished removing PiHole from your system. Sorry to see you go!\n"
|
||||||
@@ -136,11 +173,9 @@ echo "::: Preparing to remove packages, be sure that each may be safely removed
|
|||||||
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
echo "::: (SAFE TO REMOVE ALL ON RASPBIAN)"
|
||||||
while true; do
|
while true; do
|
||||||
read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn
|
read -rp "::: Do you wish to purge PiHole's dependencies from your OS? (You will be prompted for each package) [y/n]: " yn
|
||||||
case $yn in
|
case ${yn} in
|
||||||
[Yy]* ) removeAndPurge; break;;
|
[Yy]* ) removeAndPurge; break;;
|
||||||
|
|
||||||
[Nn]* ) removeNoPurge; break;;
|
[Nn]* ) removeNoPurge; break;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
386
gravity.sh
386
gravity.sh
@@ -12,97 +12,78 @@
|
|||||||
|
|
||||||
# Run this script as root or under sudo
|
# Run this script as root or under sudo
|
||||||
echo ":::"
|
echo ":::"
|
||||||
if [[ $EUID -eq 0 ]];then
|
|
||||||
echo "::: You are root."
|
|
||||||
else
|
|
||||||
echo "::: sudo will be used."
|
|
||||||
# Check if it is actually installed
|
|
||||||
# If it isn't, exit because the install cannot complete
|
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
|
||||||
export SUDO="sudo"
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this script as root."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
piholeIPfile=/tmp/piholeIP
|
helpFunc() {
|
||||||
piholeIPv6file=/etc/pihole/.useIPv6
|
cat << EOM
|
||||||
|
::: Pull in domains from adlists
|
||||||
|
:::
|
||||||
|
::: Usage: pihole -g
|
||||||
|
:::
|
||||||
|
::: Options:
|
||||||
|
::: -f, --force Force lists to be downloaded, even if they don't need updating.
|
||||||
|
::: -h, --help Show this help dialog
|
||||||
|
EOM
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
adListFile=/etc/pihole/adlists.list
|
adListFile=/etc/pihole/adlists.list
|
||||||
adListDefault=/etc/pihole/adlists.default
|
adListDefault=/etc/pihole/adlists.default
|
||||||
whitelistScript=/opt/pihole/whitelist.sh
|
whitelistScript="pihole -w"
|
||||||
blacklistScript=/opt/pihole/blacklist.sh
|
whitelistFile=/etc/pihole/whitelist.txt
|
||||||
|
blacklistFile=/etc/pihole/blacklist.txt
|
||||||
|
|
||||||
if [[ -f $piholeIPfile ]];then
|
#Source the setupVars from install script for the IP
|
||||||
# If the file exists, it means it was exported from the installation script and we should use that value instead of detecting it in this script
|
setupVars=/etc/pihole/setupVars.conf
|
||||||
piholeIP=$(cat $piholeIPfile)
|
if [[ -f ${setupVars} ]];then
|
||||||
rm $piholeIPfile
|
. /etc/pihole/setupVars.conf
|
||||||
else
|
else
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
echo "::: WARNING: /etc/pihole/setupVars.conf missing. Possible installation failure."
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
echo "::: Please run 'pihole -r', and choose the 'reconfigure' option to reconfigure."
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev" | awk '{print $4}' | awk 'END {print}')
|
exit 1
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f $piholeIPv6file ]];then
|
#Remove the /* from the end of the IPv4addr.
|
||||||
# If the file exists, then the user previously chose to use IPv6 in the automated installer
|
IPV4_ADDRESS=${IPV4_ADDRESS%/*}
|
||||||
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F " " '{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
|
IPV6_ADDRESS=${IPV6_ADDRESS}
|
||||||
fi
|
|
||||||
|
|
||||||
# Variables for various stages of downloading and formatting the list
|
# Variables for various stages of downloading and formatting the list
|
||||||
## Nate 3/26/2016 - Commented unused variables
|
|
||||||
basename=pihole
|
basename=pihole
|
||||||
piholeDir=/etc/$basename
|
piholeDir=/etc/${basename}
|
||||||
adList=$piholeDir/gravity.list
|
adList=${piholeDir}/gravity.list
|
||||||
#blacklist=$piholeDir/blacklist.txt
|
localList=${piholeDir}/local.list
|
||||||
#whitelist=$piholeDir/whitelist.txt
|
|
||||||
#latentWhitelist=$piholeDir/latentWhitelist.txt
|
|
||||||
justDomainsExtension=domains
|
justDomainsExtension=domains
|
||||||
matterandlight=$basename.0.matterandlight.txt
|
matterAndLight=${basename}.0.matterandlight.txt
|
||||||
supernova=$basename.1.supernova.txt
|
supernova=${basename}.1.supernova.txt
|
||||||
eventHorizon=$basename.2.eventHorizon.txt
|
preEventHorizon=list.preEventHorizon
|
||||||
accretionDisc=$basename.3.accretionDisc.txt
|
eventHorizon=${basename}.2.supernova.txt
|
||||||
#eyeOfTheNeedle=$basename.4.wormhole.txt
|
accretionDisc=${basename}.3.accretionDisc.txt
|
||||||
|
|
||||||
# After setting defaults, check if there's local overrides
|
skipDownload=false
|
||||||
if [[ -r $piholeDir/pihole.conf ]];then
|
|
||||||
echo "::: Local calibration requested..."
|
# Warn users still using pihole.conf that it no longer has any effect (I imagine about 2 people use it)
|
||||||
. $piholeDir/pihole.conf
|
if [[ -r ${piholeDir}/pihole.conf ]]; then
|
||||||
|
echo "::: pihole.conf file no longer supported. Over-rides in this file are ignored."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
spinner() {
|
|
||||||
local pid=$1
|
|
||||||
local delay=0.50
|
|
||||||
local spinstr='/-|'
|
|
||||||
while [ "$(ps a | awk '{print $1}' | grep "$pid")" ]; do
|
|
||||||
local temp=${spinstr#?}
|
|
||||||
printf " [%c] " "$spinstr"
|
|
||||||
local spinstr=$temp${spinstr%"$temp"}
|
|
||||||
sleep $delay
|
|
||||||
printf "\b\b\b\b\b\b"
|
|
||||||
done
|
|
||||||
printf " \b\b\b\b"
|
|
||||||
}
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# collapse - begin formation of pihole
|
# collapse - begin formation of pihole
|
||||||
function gravity_collapse() {
|
gravity_collapse() {
|
||||||
echo "::: Neutrino emissions detected..."
|
echo "::: Neutrino emissions detected..."
|
||||||
echo ":::"
|
echo ":::"
|
||||||
#Decide if we're using a custom ad block list, or defaults.
|
#Decide if we're using a custom ad block list, or defaults.
|
||||||
if [ -f $adListFile ]; then
|
if [ -f ${adListFile} ]; then
|
||||||
#custom file found, use this instead of default
|
#custom file found, use this instead of default
|
||||||
echo -n "::: Custom adList file detected. Reading..."
|
echo -n "::: Custom adList file detected. Reading..."
|
||||||
sources=()
|
sources=()
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
else
|
else
|
||||||
sources+=($line)
|
sources+=(${line})
|
||||||
fi
|
fi
|
||||||
done < $adListFile
|
done < ${adListFile}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
else
|
else
|
||||||
#no custom file found, use defaults!
|
#no custom file found, use defaults!
|
||||||
@@ -110,48 +91,48 @@ function gravity_collapse() {
|
|||||||
sources=()
|
sources=()
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
#Do not read commented out or blank lines
|
#Do not read commented out or blank lines
|
||||||
if [[ $line = \#* ]] || [[ ! $line ]]; then
|
if [[ ${line} = \#* ]] || [[ ! ${line} ]]; then
|
||||||
echo "" > /dev/null
|
echo "" > /dev/null
|
||||||
else
|
else
|
||||||
sources+=($line)
|
sources+=(${line})
|
||||||
fi
|
fi
|
||||||
done < $adListDefault
|
done < ${adListDefault}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create the pihole resource directory if it doesn't exist. Future files will be stored here
|
|
||||||
if [[ -d $piholeDir ]];then
|
|
||||||
# Temporary hack to allow non-root access to pihole directory
|
|
||||||
# Will update later, needed for existing installs, new installs should
|
|
||||||
# create this directory as non-root
|
|
||||||
$SUDO chmod 777 $piholeDir
|
|
||||||
echo ":::"
|
|
||||||
echo "::: Existing pihole directory found"
|
|
||||||
else
|
|
||||||
echo "::: Creating pihole directory..."
|
|
||||||
mkdir $piholeDir
|
|
||||||
$SUDO chmod 777 $piholeDir
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# patternCheck - check to see if curl downloaded any new files.
|
# patternCheck - check to see if curl downloaded any new files.
|
||||||
function gravity_patternCheck() {
|
gravity_patternCheck() {
|
||||||
patternBuffer=$1
|
patternBuffer=$1
|
||||||
|
success=$2
|
||||||
|
error=$3
|
||||||
|
if [ $success = true ]; then
|
||||||
|
# check if download was successful but list has not been modified
|
||||||
|
if [ "${error}" == "304" ]; then
|
||||||
|
echo "::: No changes detected, transport skipped!"
|
||||||
# check if the patternbuffer is a non-zero length file
|
# check if the patternbuffer is a non-zero length file
|
||||||
if [[ -s "$patternBuffer" ]];then
|
elif [[ -s "${patternBuffer}" ]]; then
|
||||||
# Some of the blocklists are copyright, they need to be downloaded
|
# Some of the blocklists are copyright, they need to be downloaded
|
||||||
# and stored as is. They can be processed for content after they
|
# and stored as is. They can be processed for content after they
|
||||||
# have been saved.
|
# have been saved.
|
||||||
cp "$patternBuffer" "$saveLocation"
|
mv "${patternBuffer}" "${saveLocation}"
|
||||||
echo " List updated, transport successful!"
|
echo "::: List updated, transport successful!"
|
||||||
else
|
else
|
||||||
# curl didn't download any host files, probably because of the date check
|
# Empty file -> use previously downloaded list
|
||||||
echo " No changes detected, transport skipped!"
|
echo "::: Received empty file, using cached one (list not updated!)"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# check if cached list exists
|
||||||
|
if [[ -r "${saveLocation}" ]]; then
|
||||||
|
echo "::: List download failed, using cached list (list not updated!)"
|
||||||
|
else
|
||||||
|
echo "::: Download failed and no cached list available (list will not be considered)"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# transport - curl the specified url with any needed command extentions
|
# transport - curl the specified url with any needed command extentions
|
||||||
function gravity_transport() {
|
gravity_transport() {
|
||||||
url=$1
|
url=$1
|
||||||
cmd_ext=$2
|
cmd_ext=$2
|
||||||
agent=$3
|
agent=$3
|
||||||
@@ -159,42 +140,55 @@ function gravity_transport() {
|
|||||||
# tmp file, so we don't have to store the (long!) lists in RAM
|
# tmp file, so we don't have to store the (long!) lists in RAM
|
||||||
patternBuffer=$(mktemp)
|
patternBuffer=$(mktemp)
|
||||||
heisenbergCompensator=""
|
heisenbergCompensator=""
|
||||||
if [[ -r $saveLocation ]]; then
|
if [[ -r ${saveLocation} ]]; then
|
||||||
# if domain has been saved, add file for date check to only download newer
|
# if domain has been saved, add file for date check to only download newer
|
||||||
heisenbergCompensator="-z $saveLocation"
|
heisenbergCompensator="-z ${saveLocation}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Silently curl url
|
# Silently curl url
|
||||||
curl -s $cmd_ext $heisenbergCompensator -A "$agent" $url > $patternBuffer
|
err=$(curl -s -L ${cmd_ext} ${heisenbergCompensator} -w %{http_code} -A "${agent}" ${url} -o ${patternBuffer})
|
||||||
# Check for list updates
|
|
||||||
gravity_patternCheck "$patternBuffer"
|
echo " done"
|
||||||
# Cleanup
|
# Analyze http response
|
||||||
rm -f "$patternBuffer"
|
echo -n "::: Status: "
|
||||||
|
case "$err" in
|
||||||
|
"200" ) echo "Success (OK)"; success=true;;
|
||||||
|
"304" ) echo "Not modified"; success=true;;
|
||||||
|
"403" ) echo "Forbidden"; success=false;;
|
||||||
|
"404" ) echo "Not found"; success=false;;
|
||||||
|
"408" ) echo "Time-out"; success=false;;
|
||||||
|
"451" ) echo "Unavailable For Legal Reasons"; success=false;;
|
||||||
|
"521" ) echo "Web Server Is Down (Cloudflare)"; success=false;;
|
||||||
|
"522" ) echo "Connection Timed Out (Cloudflare)"; success=false;;
|
||||||
|
"500" ) echo "Internal Server Error"; success=false;;
|
||||||
|
* ) echo "Status $err"; success=false;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# Process result
|
||||||
|
gravity_patternCheck "${patternBuffer}" ${success} "${err}"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# spinup - main gravity function
|
# spinup - main gravity function
|
||||||
function gravity_spinup() {
|
gravity_spinup() {
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
# Loop through domain list. Download each one and remove commented lines (lines beginning with '# 'or '/') and # blank lines
|
||||||
for ((i = 0; i < "${#sources[@]}"; i++))
|
for ((i = 0; i < "${#sources[@]}"; i++)); do
|
||||||
do
|
|
||||||
url=${sources[$i]}
|
url=${sources[$i]}
|
||||||
# Get just the domain from the URL
|
# Get just the domain from the URL
|
||||||
domain=$(echo "$url" | cut -d'/' -f3)
|
domain=$(echo "${url}" | cut -d'/' -f3)
|
||||||
|
|
||||||
# Save the file as list.#.domain
|
# Save the file as list.#.domain
|
||||||
saveLocation=$piholeDir/list.$i.$domain.$justDomainsExtension
|
saveLocation=${piholeDir}/list.${i}.${domain}.${justDomainsExtension}
|
||||||
activeDomains[$i]=$saveLocation
|
activeDomains[$i]=${saveLocation}
|
||||||
|
|
||||||
agent="Mozilla/10.0"
|
agent="Mozilla/10.0"
|
||||||
|
|
||||||
echo -n "::: Getting $domain list..."
|
|
||||||
|
|
||||||
# Use a case statement to download lists that need special cURL commands
|
# Use a case statement to download lists that need special cURL commands
|
||||||
# to complete properly and reset the user agent when required
|
# to complete properly and reset the user agent when required
|
||||||
case "$domain" in
|
case "${domain}" in
|
||||||
"adblock.mahakala.is")
|
"adblock.mahakala.is")
|
||||||
agent='Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0'
|
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/"
|
cmd_ext="-e http://forum.xda-developers.com/"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
@@ -205,117 +199,164 @@ function gravity_spinup() {
|
|||||||
# Default is a simple request
|
# Default is a simple request
|
||||||
*) cmd_ext=""
|
*) cmd_ext=""
|
||||||
esac
|
esac
|
||||||
|
if [[ "${skipDownload}" == false ]]; then
|
||||||
|
echo -n "::: Getting $domain list..."
|
||||||
gravity_transport "$url" "$cmd_ext" "$agent"
|
gravity_transport "$url" "$cmd_ext" "$agent"
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
# Schwarzchild - aggregate domains to one list and add blacklisted domains
|
||||||
function gravity_Schwarzchild() {
|
gravity_Schwarzchild() {
|
||||||
echo "::: "
|
echo "::: "
|
||||||
# Find all active domains and compile them into one file and remove CRs
|
# Find all active domains and compile them into one file and remove CRs
|
||||||
echo -n "::: Aggregating list of domains..."
|
echo -n "::: Aggregating list of domains..."
|
||||||
truncate -s 0 $piholeDir/$matterandlight & spinner $!
|
truncate -s 0 ${piholeDir}/${matterAndLight}
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"; do
|
||||||
do
|
# Only assimilate list if it is available (download might have faild permanently)
|
||||||
cat "$i" | tr -d '\r' >> $piholeDir/$matterandlight
|
if [[ -r "${i}" ]]; then
|
||||||
|
cat "${i}" | tr -d '\r' >> ${piholeDir}/${matterAndLight}
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_Blacklist(){
|
gravity_Blacklist() {
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries to eventHorizon if they exist
|
||||||
echo -n "::: Running blacklist script to update HOSTS file...."
|
if [[ -f "${blacklistFile}" ]]; then
|
||||||
$blacklistScript -f -nr -q > /dev/null & spinner $!
|
numBlacklisted=$(wc -l < "${blacklistFile}")
|
||||||
|
|
||||||
numBlacklisted=$(wc -l < "/etc/pihole/blacklist.txt")
|
|
||||||
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
plural=; [[ "$numBlacklisted" != "1" ]] && plural=s
|
||||||
echo " $numBlacklisted domain${plural} blacklisted!"
|
echo -n "::: Blacklisting $numBlacklisted domain${plural}..."
|
||||||
|
cat ${blacklistFile} >> ${piholeDir}/${eventHorizon}
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo "::: Nothing to blacklist!"
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_Whitelist() {
|
gravity_Whitelist() {
|
||||||
|
#${piholeDir}/${eventHorizon})
|
||||||
echo ":::"
|
echo ":::"
|
||||||
# Prevent our sources from being pulled into the hole
|
# Prevent our sources from being pulled into the hole
|
||||||
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
plural=; [[ "${sources[@]}" != "1" ]] && plural=s
|
||||||
echo -n "::: Adding ${#sources[@]} adlist source${plural} to the whitelist..."
|
echo -n "::: Adding adlist source${plural} to the whitelist..."
|
||||||
|
|
||||||
urls=()
|
urls=()
|
||||||
for url in "${sources[@]}"
|
for url in "${sources[@]}"; do
|
||||||
do
|
tmp=$(echo "${url}" | awk -F '/' '{print $3}')
|
||||||
tmp=$(echo "$url" | awk -F '/' '{print $3}')
|
urls=("${urls[@]}" ${tmp})
|
||||||
urls=("${urls[@]}" $tmp)
|
|
||||||
done
|
done
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
echo -n "::: Running whitelist script to update HOSTS file...."
|
# Ensure adlist domains are in whitelist.txt
|
||||||
$whitelistScript -f -nr -q "${urls[@]}" > /dev/null & spinner $!
|
${whitelistScript} -nr -q "${urls[@]}" > /dev/null
|
||||||
numWhitelisted=$(wc -l < "/etc/pihole/whitelist.txt")
|
|
||||||
|
# Check whitelist.txt exists.
|
||||||
|
if [[ -f "${whitelistFile}" ]]; then
|
||||||
|
# Remove anything in whitelist.txt from the Event Horizon
|
||||||
|
numWhitelisted=$(wc -l < "${whitelistFile}")
|
||||||
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
plural=; [[ "$numWhitelisted" != "1" ]] && plural=s
|
||||||
echo " $numWhitelisted domain${plural} whitelisted!"
|
echo -n "::: Whitelisting $numWhitelisted domain${plural}..."
|
||||||
|
#print everything from preEventHorizon into eventHorizon EXCEPT domains in whitelist.txt
|
||||||
|
grep -F -x -v -f ${whitelistFile} ${piholeDir}/${preEventHorizon} > ${piholeDir}/${eventHorizon}
|
||||||
|
echo " done!"
|
||||||
|
else
|
||||||
|
echo "::: Nothing to whitelist!"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_unique() {
|
gravity_unique() {
|
||||||
# Sort and remove duplicates
|
# Sort and remove duplicates
|
||||||
echo -n "::: Removing duplicate domains...."
|
echo -n "::: Removing duplicate domains...."
|
||||||
sort -u $piholeDir/$supernova > $piholeDir/$eventHorizon & spinner $!
|
sort -u ${piholeDir}/${supernova} > ${piholeDir}/${preEventHorizon}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
numberOf=$(wc -l < $piholeDir/$eventHorizon)
|
numberOf=$(wc -l < ${piholeDir}/${preEventHorizon})
|
||||||
echo "::: $numberOf unique domains trapped in the event horizon."
|
echo "::: $numberOf unique domains trapped in the event horizon."
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_hostFormat() {
|
gravity_hostFormat() {
|
||||||
# Format domain list as "192.168.x.x domain.com"
|
# Format domain list as "192.168.x.x domain.com"
|
||||||
echo "::: Formatting domains into a HOSTS file..."
|
echo -n "::: Formatting domains into a HOSTS file..."
|
||||||
|
|
||||||
|
if [[ -f /etc/hostname ]]; then
|
||||||
hostname=$(</etc/hostname)
|
hostname=$(</etc/hostname)
|
||||||
# If there is a value in the $piholeIPv6, then IPv6 will be used, so the awk command modified to create a line for both protocols
|
elif [ -x "$(command -v hostname)" ]; then
|
||||||
if [[ -n $piholeIPv6 ]];then
|
hostname=$(hostname -f)
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
|
||||||
echo -e "$piholeIP $hostname\n$piholeIPv6 $hostname\n$piholeIP pi.hole\n$piholeIPv6 pi.hole" > $piholeDir/$accretionDisc
|
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $piholeDir/$accretionDisc
|
|
||||||
else
|
else
|
||||||
# Otherwise, just create gravity.list as normal using IPv4
|
echo "::: Error: Unable to determine fully qualified domain name of host"
|
||||||
# Add hostname and dummy domain to the top of gravity.list to make ping result return a friendlier looking domain! Also allows for an easy way to access the Pi-hole admin console (pi.hole/admin)
|
fi
|
||||||
echo -e "$piholeIP $hostname\n$piholeIP pi.hole" > $piholeDir/$accretionDisc
|
# Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both.
|
||||||
cat $piholeDir/$eventHorizon | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >> $piholeDir/$accretionDisc
|
if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV4_ADDRESS} ${hostname}\n${IPV6_ADDRESS} ${hostname}\n${IPV4_ADDRESS} pi.hole\n${IPV6_ADDRESS} pi.hole" > ${localList}
|
||||||
|
# Both IPv4 and IPv6
|
||||||
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
|
elif [[ -n "${IPV4_ADDRESS}" && -z "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV4_ADDRESS} ${hostname}\n${IPV4_ADDRESS} pi.hole" > ${localList}
|
||||||
|
# Only IPv4
|
||||||
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv4addr="$IPV4_ADDRESS" '{sub(/\r$/,""); print ipv4addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
|
elif [[ -z "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then
|
||||||
|
|
||||||
|
echo -e "${IPV6_ADDRESS} ${hostname}\n${IPV6_ADDRESS} pi.hole" > ${localList}
|
||||||
|
# Only IPv6
|
||||||
|
cat ${piholeDir}/${eventHorizon} | awk -v ipv6addr="$IPV6_ADDRESS" '{sub(/\r$/,""); print ipv6addr" "$0}' >> ${piholeDir}/${accretionDisc}
|
||||||
|
|
||||||
|
elif [[ -z "${IPV4_ADDRESS}" && -z "${IPV6_ADDRESS}" ]];then
|
||||||
|
echo "::: No IP Values found! Please run 'pihole -r' and choose reconfigure to restore values"
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
# Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it
|
||||||
cp $piholeDir/$accretionDisc $adList
|
cp ${piholeDir}/${accretionDisc} ${adList}
|
||||||
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
function gravity_blackbody() {
|
gravity_blackbody() {
|
||||||
# Loop through list files
|
# Loop through list files
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in ${piholeDir}/*.${justDomainsExtension}; do
|
||||||
do
|
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
if [[ " ${activeDomains[@]} " =~ ${file} ]]; then
|
||||||
:
|
:
|
||||||
else
|
else
|
||||||
rm -f "$file"
|
rm -f "${file}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_advanced() {
|
gravity_advanced() {
|
||||||
# Remove comments and print only the domain name
|
# Remove comments and print only the domain name
|
||||||
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
# Most of the lists downloaded are already in hosts file format but the spacing/formating is not contigious
|
||||||
# This helps with that and makes it easier to read
|
# This helps with that and makes it easier to read
|
||||||
# It also helps with debugging so each stage of the script can be researched more in depth
|
# It also helps with debugging so each stage of the script can be researched more in depth
|
||||||
echo -n "::: Formatting list of domains to remove comments...."
|
echo -n "::: Formatting list of domains to remove comments...."
|
||||||
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' $piholeDir/$matterandlight | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > $piholeDir/$supernova & spinner $!
|
#awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' ${piholeDir}/${matterAndLight} | sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
|
||||||
|
#Above line does not correctly grab domains where comment is on the same line (e.g 'addomain.com #comment')
|
||||||
|
#Awk -F splits on given IFS, we grab the right hand side (chops trailing #coments and /'s to grab the domain only.
|
||||||
|
#Last awk command takes non-commented lines and if they have 2 fields, take the left field (the domain) and leave
|
||||||
|
#+ the right (IP address), otherwise grab the single field.
|
||||||
|
cat ${piholeDir}/${matterAndLight} | \
|
||||||
|
awk -F '#' '{print $1}' | \
|
||||||
|
awk -F '/' '{print $1}' | \
|
||||||
|
awk '($1 !~ /^#/) { if (NF>1) {print $2} else {print $1}}' | \
|
||||||
|
sed -nr -e 's/\.{2,}/./g' -e '/\./p' > ${piholeDir}/${supernova}
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
numberOf=$(wc -l < $piholeDir/$supernova)
|
numberOf=$(wc -l < ${piholeDir}/${supernova})
|
||||||
echo "::: $numberOf domains being pulled in by gravity..."
|
echo "::: ${numberOf} domains being pulled in by gravity..."
|
||||||
|
|
||||||
gravity_unique
|
gravity_unique
|
||||||
}
|
}
|
||||||
|
|
||||||
function gravity_reload() {
|
gravity_reload() {
|
||||||
#Clear no longer needed files...
|
#Clear no longer needed files...
|
||||||
echo ":::"
|
echo ":::"
|
||||||
echo -n "::: Cleaning up un-needed files..."
|
echo -n "::: Cleaning up un-needed files..."
|
||||||
$SUDO rm $piholeDir/pihole.*.txt
|
rm ${piholeDir}/pihole.*.txt
|
||||||
echo " done!"
|
echo " done!"
|
||||||
|
|
||||||
# Reload hosts file
|
# Reload hosts file
|
||||||
@@ -326,28 +367,43 @@ function gravity_reload() {
|
|||||||
#First escape forward slashes in the path:
|
#First escape forward slashes in the path:
|
||||||
adList=${adList//\//\\\/}
|
adList=${adList//\//\\\/}
|
||||||
#Now replace the line in dnsmasq file
|
#Now replace the line in dnsmasq file
|
||||||
$SUDO sed -i "s/^addn-hosts.*/addn-hosts=$adlist/" /etc/dnsmasq.d/01-pihole.conf
|
# sed -i "s/^addn-hosts.*/addn-hosts=$adList/" /etc/dnsmasq.d/01-pihole.conf
|
||||||
dnsmasqPid=$(pidof dnsmasq)
|
|
||||||
|
|
||||||
find "$piholeDir" -type f -exec $SUDO chmod 666 {} \; & spinner $!
|
pihole restartdns
|
||||||
|
|
||||||
if [[ $dnsmasqPid ]]; then
|
|
||||||
# service already running - reload config
|
|
||||||
$SUDO kill -HUP "$dnsmasqPid" & spinner $!
|
|
||||||
else
|
|
||||||
# service not running, start it up
|
|
||||||
$SUDO service dnsmasq start & spinner $!
|
|
||||||
fi
|
|
||||||
echo " done!"
|
echo " done!"
|
||||||
}
|
}
|
||||||
|
|
||||||
$SUDO cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
for var in "$@"; do
|
||||||
|
case "${var}" in
|
||||||
|
"-f" | "--force" ) forceGrav=true;;
|
||||||
|
"-h" | "--help" ) helpFunc;;
|
||||||
|
"-sd" | "--skip-download" ) skipDownload=true;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ "${forceGrav}" == true ]]; then
|
||||||
|
echo -n "::: Deleting exising list cache..."
|
||||||
|
rm /etc/pihole/list.*
|
||||||
|
echo " done!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#Overwrite adlists.default from /etc/.pihole in case any changes have been made. Changes should be saved in /etc/adlists.list
|
||||||
|
#cp /etc/.pihole/adlists.default /etc/pihole/adlists.default
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
|
if [[ "${skipDownload}" == false ]]; then
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
gravity_advanced
|
gravity_advanced
|
||||||
gravity_hostFormat
|
else
|
||||||
gravity_blackbody
|
echo "::: Using cached Event Horizon list..."
|
||||||
|
numberOf=$(wc -l < ${piholeDir}/${preEventHorizon})
|
||||||
|
echo "::: $numberOf unique domains trapped in the event horizon."
|
||||||
|
fi
|
||||||
gravity_Whitelist
|
gravity_Whitelist
|
||||||
gravity_Blacklist
|
gravity_Blacklist
|
||||||
|
|
||||||
|
gravity_hostFormat
|
||||||
|
gravity_blackbody
|
||||||
|
|
||||||
gravity_reload
|
gravity_reload
|
||||||
|
pihole status
|
||||||
|
294
pihole
294
pihole
@@ -10,87 +10,247 @@
|
|||||||
# the Free Software Foundation, either version 2 of the License, or
|
# the Free Software Foundation, either version 2 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
|
|
||||||
|
PI_HOLE_SCRIPT_DIR="/opt/pihole"
|
||||||
# Must be root to use this tool
|
# Must be root to use this tool
|
||||||
if [[ $EUID -eq 0 ]];then
|
if [[ ! $EUID -eq 0 ]];then
|
||||||
echo "::: You are root."
|
if [ -x "$(command -v sudo)" ];then
|
||||||
|
exec sudo bash "$0" "$@"
|
||||||
|
exit $?
|
||||||
else
|
else
|
||||||
echo "::: Sudo will be used for this tool."
|
echo "::: sudo is needed to run pihole commands. Please run this script as root or install sudo."
|
||||||
# Check if it is actually installed
|
|
||||||
# If it isn't, exit because the pihole cannot be invoked without privileges.
|
|
||||||
if [[ $(dpkg-query -s sudo) ]];then
|
|
||||||
export SUDO="sudo"
|
|
||||||
else
|
|
||||||
echo "::: Please install sudo or run this as root."
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function whitelistFunc {
|
webpageFunc() {
|
||||||
|
/opt/pihole/webpage.sh "$@"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
whitelistFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
blacklistFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/list.sh "$@"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
debugFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/piholeDebug.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
flushFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/piholeLogFlush.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
updatePiholeFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/update.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
reconfigurePiholeFunc() {
|
||||||
|
/etc/.pihole/automated\ install/basic-install.sh --reconfigure
|
||||||
|
exit 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGravityFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/gravity.sh "$@"
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
setupLCDFunction() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/setupLCD.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
scanList(){
|
||||||
|
domain="${1}"
|
||||||
|
list="${2}"
|
||||||
|
method="${3}"
|
||||||
|
if [[ ${method} == "-exact" ]] ; then
|
||||||
|
grep -i -E "(^|\s)${domain}($|\s)" "${list}"
|
||||||
|
else
|
||||||
|
grep -i "${domain}" "${list}"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
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}"
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
done
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
chronometerFunc() {
|
||||||
shift
|
shift
|
||||||
$SUDO /opt/pihole/whitelist.sh "$@"
|
"${PI_HOLE_SCRIPT_DIR}"/chronometer.sh "$@"
|
||||||
exit 1
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function blacklistFunc {
|
|
||||||
|
uninstallFunc() {
|
||||||
|
"${PI_HOLE_SCRIPT_DIR}"/uninstall.sh
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
|
||||||
|
versionFunc() {
|
||||||
shift
|
shift
|
||||||
$SUDO /opt/pihole/blacklist.sh "$@"
|
"${PI_HOLE_SCRIPT_DIR}"/version.sh "$@"
|
||||||
exit 1
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function debugFunc {
|
restartDNS() {
|
||||||
$SUDO /opt/pihole/piholeDebug.sh
|
dnsmasqPid=$(pidof dnsmasq)
|
||||||
exit 1
|
if [[ ${dnsmasqPid} ]]; then
|
||||||
|
# service already running - reload config
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl restart dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq restart
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# service not running, start it up
|
||||||
|
if [ -x "$(command -v systemctl)" ]; then
|
||||||
|
systemctl start dnsmasq
|
||||||
|
else
|
||||||
|
service dnsmasq start
|
||||||
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function flushFunc {
|
piholeEnable() {
|
||||||
$SUDO /opt/pihole/piholeLogFlush.sh
|
if [[ "${1}" == "0" ]] ; then
|
||||||
exit 1
|
#Disable Pihole
|
||||||
|
sed -i 's/^addn-hosts=\/etc\/pihole\/gravity.list/#addn-hosts=\/etc\/pihole\/gravity.list/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
echo "::: Blocking has been disabled!"
|
||||||
|
if [[ $# > 1 ]] ; then
|
||||||
|
if [[ ${2} == *"s"* ]] ; then
|
||||||
|
tt=${2%"s"}
|
||||||
|
echo "::: Blocking will be re-enabled in ${tt} seconds"
|
||||||
|
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
||||||
|
elif [[ ${2} == *"m"* ]] ; then
|
||||||
|
tt=${2%"m"}
|
||||||
|
echo "::: Blocking will be re-enabled in ${tt} minutes"
|
||||||
|
tt=$((${tt}*60))
|
||||||
|
nohup bash -c "sleep ${tt}; pihole enable" </dev/null &>/dev/null &
|
||||||
|
else
|
||||||
|
echo "::: Unknown format for delayed reactivation of the blocking!"
|
||||||
|
echo "::: Example:"
|
||||||
|
echo "::: pihole disable 5s - will disable blocking for 5 seconds"
|
||||||
|
echo "::: pihole disable 7m - will disable blocking for 7 minutes"
|
||||||
|
echo "::: Blocking will not automatically be re-enabled!"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
#Enable pihole
|
||||||
|
echo "::: Blocking has been enabled!"
|
||||||
|
sed -i 's/^#addn-hosts/addn-hosts/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
fi
|
||||||
|
restartDNS
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateDashboardFunc {
|
piholeLogging() {
|
||||||
$SUDO /opt/pihole/updateDashboard.sh
|
shift
|
||||||
|
|
||||||
|
if [[ "${1}" == "off" ]] ; then
|
||||||
|
#Disable Logging
|
||||||
|
sed -i 's/^log-queries/#log-queries/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
sed -i 's/^QUERY_LOGGING=true/QUERY_LOGGING=false/' /etc/pihole/setupVars.conf
|
||||||
|
pihole -f
|
||||||
|
echo "::: Logging has been disabled!"
|
||||||
|
elif [[ "${1}" == "on" ]] ; then
|
||||||
|
#Enable logging
|
||||||
|
sed -i 's/^#log-queries/log-queries/' /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
sed -i 's/^QUERY_LOGGING=false/QUERY_LOGGING=true/' /etc/pihole/setupVars.conf
|
||||||
|
echo "::: Logging has been enabled!"
|
||||||
|
else
|
||||||
|
echo "::: Invalid option passed, please pass 'on' or 'off'"
|
||||||
exit 1
|
exit 1
|
||||||
|
fi
|
||||||
|
restartDNS
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateGravityFunc {
|
piholeStatus() {
|
||||||
$SUDO /opt/pihole/gravity.sh
|
if [[ $(grep -i "^#addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf) ]] ; then
|
||||||
exit 1
|
#list is commented out
|
||||||
|
if [[ "${1}" == "web" ]] ; then
|
||||||
|
echo 0;
|
||||||
|
else
|
||||||
|
echo "::: Pi-hole blocking is Disabled";
|
||||||
|
fi
|
||||||
|
elif [[ $(grep -i "^addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf) ]] ; then
|
||||||
|
#list set
|
||||||
|
if [[ "${1}" == "web" ]] ; then
|
||||||
|
echo 1;
|
||||||
|
else
|
||||||
|
echo "::: Pi-hole blocking is Enabled";
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
#addn-host not found
|
||||||
|
if [[ "${1}" == "web" ]] ; then
|
||||||
|
echo 99
|
||||||
|
else
|
||||||
|
echo "::: No hosts file linked to dnsmasq, adding it in enabled state"
|
||||||
|
fi
|
||||||
|
#add addn-host= to dnsmasq
|
||||||
|
echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf
|
||||||
|
restartDNS
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function setupLCDFunction {
|
tailFunc() {
|
||||||
$SUDO /opt/pihole/setupLCD.sh
|
echo "Press Ctrl-C to exit"
|
||||||
exit 1
|
tail -F /var/log/pihole.log
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function chronometerFunc {
|
helpFunc() {
|
||||||
$SUDO /opt/pihole/chronometer.sh
|
cat << EOM
|
||||||
exit 1
|
::: Control all PiHole specific functions!
|
||||||
}
|
:::
|
||||||
|
::: Usage: pihole [options]
|
||||||
|
::: Add -h after -w (whitelist), -b (blacklist), -c (chronometer), or -a (admin) for more information on usage
|
||||||
function uninstallFunc {
|
:::
|
||||||
$SUDO /opt/pihole/uninstall.sh
|
::: Options:
|
||||||
exit 1
|
::: -w, whitelist Whitelist domains
|
||||||
}
|
::: -b, blacklist Blacklist domains
|
||||||
|
::: -d, debug Start a debugging session if having trouble
|
||||||
function helpFunc {
|
::: -f, flush Flush the pihole.log file
|
||||||
echo "::: Control all PiHole specific functions!"
|
::: -t, tail Output the last lines of the pihole.log file. Lines are appended as the file grows
|
||||||
echo ":::"
|
::: -up, updatePihole Update Pi-hole
|
||||||
echo "::: Usage: pihole.sh [options]"
|
::: -r, reconfigure Reconfigure or Repair Pi-hole
|
||||||
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
|
::: -g, updateGravity Update the list of ad-serving domains
|
||||||
echo ":::"
|
::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it
|
||||||
echo "::: Options:"
|
::: -c, chronometer Calculates stats and displays to an LCD
|
||||||
echo "::: -w, whitelist Whitelist domains"
|
::: -h, help Show this help dialog
|
||||||
echo "::: -b, blacklist Blacklist domains"
|
::: -v, version Show current versions
|
||||||
echo "::: -d, debug Start a debugging session if having trouble"
|
::: -q, query Query the adlists for a specific domain
|
||||||
echo "::: -f, flush Flush the pihole.log file"
|
::: Use pihole -q domain -exact if you want to see exact matches only
|
||||||
echo "::: -u, updateDashboard Update the web dashboard manually"
|
::: -l, logging Enable or Disable logging (pass 'on' or 'off')
|
||||||
echo "::: -g, updateGravity Update the list of ad-serving domains"
|
::: -a, admin Admin webpage options
|
||||||
echo "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
|
::: uninstall Uninstall Pi-Hole from your system :(!
|
||||||
echo "::: -c, chronometer Calculates stats and displays to an LCD"
|
::: status Is Pi-Hole Enabled or Disabled
|
||||||
echo "::: -h, help Show this help dialog"
|
::: enable Enable Pi-Hole DNS Blocking
|
||||||
echo "::: uninstall Uninstall Pi-Hole from your system!"
|
::: disable Disable Pi-Hole DNS Blocking
|
||||||
exit 1
|
::: Blocking can also be disabled only temporarily, e.g.,
|
||||||
|
::: pihole disable 5m - will disable blocking for 5 minutes
|
||||||
|
::: restartdns Restart dnsmasq
|
||||||
|
EOM
|
||||||
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $# = 0 ]]; then
|
if [[ $# = 0 ]]; then
|
||||||
@@ -98,16 +258,26 @@ if [[ $# = 0 ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Handle redirecting to specific functions based on arguments
|
# Handle redirecting to specific functions based on arguments
|
||||||
case "$1" in
|
case "${1}" in
|
||||||
"-w" | "whitelist" ) whitelistFunc "$@";;
|
"-w" | "whitelist" ) whitelistFunc "$@";;
|
||||||
"-b" | "blacklist" ) blacklistFunc "$@";;
|
"-b" | "blacklist" ) blacklistFunc "$@";;
|
||||||
"-d" | "debug" ) debugFunc;;
|
"-d" | "debug" ) debugFunc;;
|
||||||
"-f" | "flush" ) flushFunc;;
|
"-f" | "flush" ) flushFunc;;
|
||||||
"-u" | "updateDashboard" ) updateDashboardFunc;;
|
"-up" | "updatePihole" ) updatePiholeFunc;;
|
||||||
"-g" | "updateGravity" ) updateGravityFunc;;
|
"-r" | "reconfigure" ) reconfigurePiholeFunc;;
|
||||||
|
"-g" | "updateGravity" ) updateGravityFunc "$@";;
|
||||||
"-s" | "setupLCD" ) setupLCDFunction;;
|
"-s" | "setupLCD" ) setupLCDFunction;;
|
||||||
"-c" | "chronometer" ) chronometerFunc;;
|
"-c" | "chronometer" ) chronometerFunc "$@";;
|
||||||
"-h" | "help" ) helpFunc;;
|
"-h" | "help" ) helpFunc;;
|
||||||
|
"-v" | "version" ) versionFunc "$@";;
|
||||||
|
"-q" | "query" ) queryFunc "$@";;
|
||||||
|
"-l" | "logging" ) piholeLogging "$@";;
|
||||||
"uninstall" ) uninstallFunc;;
|
"uninstall" ) uninstallFunc;;
|
||||||
|
"enable" ) piholeEnable 1;;
|
||||||
|
"disable" ) piholeEnable 0 $2;;
|
||||||
|
"status" ) piholeStatus "$2";;
|
||||||
|
"restartdns" ) restartDNS;;
|
||||||
|
"-a" | "admin" ) webpageFunc "$@";;
|
||||||
|
"-t" | "tail" ) tailFunc;;
|
||||||
* ) helpFunc;;
|
* ) helpFunc;;
|
||||||
esac
|
esac
|
||||||
|
5
requirements.txt
Normal file
5
requirements.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
docker-compose
|
||||||
|
pytest
|
||||||
|
pytest-xdist
|
||||||
|
pytest-cov
|
||||||
|
testinfra
|
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
16
test/centos.Dockerfile
Normal file
16
test/centos.Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM centos:7
|
||||||
|
|
||||||
|
ENV GITDIR /etc/.pihole
|
||||||
|
ENV SCRIPTDIR /opt/pihole
|
||||||
|
|
||||||
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
|
ADD . $GITDIR
|
||||||
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
||||||
|
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
|
RUN true && \
|
||||||
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
|
ENV PH_TEST true
|
||||||
|
|
||||||
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
61
test/conftest.py
Normal file
61
test/conftest.py
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import pytest
|
||||||
|
import testinfra
|
||||||
|
|
||||||
|
check_output = testinfra.get_backend(
|
||||||
|
"local://"
|
||||||
|
).get_module("Command").check_output
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def Pihole(Docker):
|
||||||
|
''' used to contain some script stubbing, now pretty much an alias.
|
||||||
|
Also provides bash as the default run function shell '''
|
||||||
|
def run_bash(self, command, *args, **kwargs):
|
||||||
|
cmd = self.get_command(command, *args)
|
||||||
|
if self.user is not None:
|
||||||
|
out = self.run_local(
|
||||||
|
"docker exec -u %s %s /bin/bash -c %s",
|
||||||
|
self.user, self.name, cmd)
|
||||||
|
else:
|
||||||
|
out = self.run_local(
|
||||||
|
"docker exec %s /bin/bash -c %s", self.name, cmd)
|
||||||
|
out.command = self.encode(cmd)
|
||||||
|
return out
|
||||||
|
|
||||||
|
funcType = type(Docker.run)
|
||||||
|
Docker.run = funcType(run_bash, Docker, testinfra.backend.docker.DockerBackend)
|
||||||
|
return Docker
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def Docker(request, args, image, cmd):
|
||||||
|
''' combine our fixtures into a docker run command and setup finalizer to cleanup '''
|
||||||
|
assert 'docker' in check_output('id'), "Are you in the docker group?"
|
||||||
|
docker_run = "docker run {} {} {}".format(args, image, cmd)
|
||||||
|
docker_id = check_output(docker_run)
|
||||||
|
|
||||||
|
def teardown():
|
||||||
|
check_output("docker rm -f %s", docker_id)
|
||||||
|
request.addfinalizer(teardown)
|
||||||
|
|
||||||
|
docker_container = testinfra.get_backend("docker://" + docker_id)
|
||||||
|
docker_container.id = docker_id
|
||||||
|
return docker_container
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def args(request):
|
||||||
|
''' -t became required when tput began being used '''
|
||||||
|
return '-t -d'
|
||||||
|
|
||||||
|
@pytest.fixture(params=['debian', 'centos'])
|
||||||
|
def tag(request):
|
||||||
|
''' consumed by image to make the test matrix '''
|
||||||
|
return request.param
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def image(request, tag):
|
||||||
|
''' built by test_000_build_containers.py '''
|
||||||
|
return 'pytest_pihole:{}'.format(tag)
|
||||||
|
|
||||||
|
@pytest.fixture()
|
||||||
|
def cmd(request):
|
||||||
|
''' default to doing nothing by tailing null, but don't exit '''
|
||||||
|
return 'tail -f /dev/null'
|
16
test/debian.Dockerfile
Normal file
16
test/debian.Dockerfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
FROM debian:jessie
|
||||||
|
|
||||||
|
ENV GITDIR /etc/.pihole
|
||||||
|
ENV SCRIPTDIR /opt/pihole
|
||||||
|
|
||||||
|
RUN mkdir -p $GITDIR $SCRIPTDIR /etc/pihole
|
||||||
|
ADD . $GITDIR
|
||||||
|
RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/
|
||||||
|
ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR
|
||||||
|
|
||||||
|
RUN true && \
|
||||||
|
chmod +x $SCRIPTDIR/*
|
||||||
|
|
||||||
|
ENV PH_TEST true
|
||||||
|
|
||||||
|
#sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \
|
18
test/test_000_build_containers.py
Normal file
18
test/test_000_build_containers.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
''' This file starts with 000 to make it run first '''
|
||||||
|
import pytest
|
||||||
|
import testinfra
|
||||||
|
|
||||||
|
run_local = testinfra.get_backend(
|
||||||
|
"local://"
|
||||||
|
).get_module("Command").run
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("image,tag", [
|
||||||
|
( 'test/debian.Dockerfile', 'pytest_pihole:debian' ),
|
||||||
|
( 'test/centos.Dockerfile', 'pytest_pihole:centos' ),
|
||||||
|
])
|
||||||
|
def test_build_pihole_image(image, tag):
|
||||||
|
build_cmd = run_local('docker build -f {} -t {} .'.format(image, tag))
|
||||||
|
if build_cmd.rc != 0:
|
||||||
|
print build_cmd.stdout
|
||||||
|
print build_cmd.stderr
|
||||||
|
assert build_cmd.rc == 0
|
102
test/test_automated_install.py
Normal file
102
test/test_automated_install.py
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import pytest
|
||||||
|
from textwrap import dedent
|
||||||
|
|
||||||
|
SETUPVARS = {
|
||||||
|
'PIHOLE_INTERFACE' : 'eth99',
|
||||||
|
'IPV4_ADDRESS' : '1.1.1.1',
|
||||||
|
'IPV6_ADDRESS' : 'FE80::240:D0FF:FE48:4672',
|
||||||
|
'PIHOLE_DNS_1' : '4.2.2.1',
|
||||||
|
'PIHOLE_DNS_2' : '4.2.2.2'
|
||||||
|
}
|
||||||
|
|
||||||
|
def test_setupVars_are_sourced_to_global_scope(Pihole):
|
||||||
|
''' currently update_dialogs sources setupVars with a dot,
|
||||||
|
then various other functions use the variables.
|
||||||
|
This confirms the sourced variables are in scope between functions '''
|
||||||
|
setup_var_file = 'cat <<EOF> /etc/pihole/setupVars.conf\n'
|
||||||
|
for k,v in SETUPVARS.iteritems():
|
||||||
|
setup_var_file += "{}={}\n".format(k, v)
|
||||||
|
setup_var_file += "EOF\n"
|
||||||
|
Pihole.run(setup_var_file)
|
||||||
|
|
||||||
|
script = dedent('''\
|
||||||
|
set -e
|
||||||
|
printSetupVars() {
|
||||||
|
# Currently debug test function only
|
||||||
|
echo "Outputting sourced variables"
|
||||||
|
echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}"
|
||||||
|
echo "IPV4_ADDRESS=${IPV4_ADDRESS}"
|
||||||
|
echo "IPV6_ADDRESS=${IPV6_ADDRESS}"
|
||||||
|
echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}"
|
||||||
|
echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}"
|
||||||
|
}
|
||||||
|
update_dialogs() {
|
||||||
|
. /etc/pihole/setupVars.conf
|
||||||
|
}
|
||||||
|
update_dialogs
|
||||||
|
printSetupVars
|
||||||
|
''')
|
||||||
|
|
||||||
|
output = run_script(Pihole, script).stdout
|
||||||
|
|
||||||
|
for k,v in SETUPVARS.iteritems():
|
||||||
|
assert "{}={}".format(k, v) in output
|
||||||
|
|
||||||
|
def test_setupVars_saved_to_file(Pihole):
|
||||||
|
''' confirm saved settings are written to a file for future updates to re-use '''
|
||||||
|
set_setup_vars = '\n' # dedent works better with this and padding matching script below
|
||||||
|
for k,v in SETUPVARS.iteritems():
|
||||||
|
set_setup_vars += " {}={}\n".format(k, v)
|
||||||
|
Pihole.run(set_setup_vars).stdout
|
||||||
|
|
||||||
|
script = dedent('''\
|
||||||
|
set -e
|
||||||
|
echo start
|
||||||
|
TERM=xterm
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
{}
|
||||||
|
finalExports
|
||||||
|
cat /etc/pihole/setupVars.conf
|
||||||
|
'''.format(set_setup_vars))
|
||||||
|
|
||||||
|
output = run_script(Pihole, script).stdout
|
||||||
|
|
||||||
|
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)
|
||||||
|
configureFirewall = Pihole.run('''
|
||||||
|
source /opt/pihole/basic-install.sh
|
||||||
|
configureFirewall
|
||||||
|
''')
|
||||||
|
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' in firewall_calls
|
||||||
|
assert 'firewall-cmd --permanent --add-port=53/tcp' in firewall_calls
|
||||||
|
assert 'firewall-cmd --permanent --add-port=53/udp' in firewall_calls
|
||||||
|
assert 'firewall-cmd --reload' in firewall_calls
|
||||||
|
|
||||||
|
|
||||||
|
# Helper functions
|
||||||
|
def mock_command(script, result, 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))
|
||||||
|
container.run('''
|
||||||
|
cat <<EOF> {script}\n{content}\nEOF
|
||||||
|
chmod +x {script}
|
||||||
|
'''.format(script=full_script_path, content=mock_script))
|
||||||
|
|
||||||
|
def run_script(Pihole, script):
|
||||||
|
result = Pihole.run(script)
|
||||||
|
assert result.rc == 0
|
||||||
|
return result
|
13
test/test_shellcheck.py
Normal file
13
test/test_shellcheck.py
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import pytest
|
||||||
|
import testinfra
|
||||||
|
|
||||||
|
run_local = testinfra.get_backend(
|
||||||
|
"local://"
|
||||||
|
).get_module("Command").run
|
||||||
|
|
||||||
|
def test_scripts_pass_shellcheck():
|
||||||
|
''' Make sure shellcheck does not find anything wrong with our shell scripts '''
|
||||||
|
shellcheck = "find . -type f \( -name 'update.sh' -o -name 'piholeDebug.sh' \) | while read file; do shellcheck \"$file\"; done;"
|
||||||
|
results = run_local(shellcheck)
|
||||||
|
print results.stdout
|
||||||
|
assert '' == results.stdout
|
Reference in New Issue
Block a user