You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+3-1
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,11 @@
1
1
# Automated Install
2
-
##### Designed For Raspberry Pi A+, B, B+, 2, and Zero (with an Ethernet/Wi-Fi adapter)
2
+
##### Designed For Raspberry Pi A+, B, B+, 2, Zero, and 3B (with an Ethernet/Wi-Fi adapter) (Works on most Debian distributions!)
3
+
3
4
4
5
[](https://gitter.im/pi-hole/pi-hole?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
echo"::: -d, --delmode Remove domains from the blacklist"
20
+
echo"::: -nr, --noreload Update blacklist without refreshing dnsmasq"
21
+
echo"::: -f, --force Force updating of the hosts files, even if there are no changes"
22
+
echo"::: -q, --quiet output is less verbose"
23
23
exit 1
24
24
fi
25
25
26
26
#globals
27
-
blacklist=/etc/pihole/blacklist.txt
28
-
adList=/etc/pihole/gravity.list
27
+
basename=pihole
28
+
piholeDir=/etc/$basename
29
+
adList=$piholeDir/gravity.list
30
+
blacklist=$piholeDir/blacklist.txt
29
31
reload=true
30
32
addmode=true
31
33
force=false
32
34
versbose=true
35
+
33
36
domList=()
34
37
domToRemoveList=()
35
38
36
-
37
-
piholeIPfile=/tmp/piholeIP
38
39
piholeIPv6file=/etc/pihole/.useIPv6
39
40
40
41
# 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
41
42
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
42
-
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev| awk '{print $4}'| awk 'END {print}')
43
+
piholeIPCIDR=$(ip -o -f inet addr show dev "$IPv4dev"| awk '{print $4}'| awk 'END {print}')
43
44
piholeIP=${piholeIPCIDR%/*}
44
45
45
46
modifyHost=false
46
47
48
+
# After setting defaults, check if there's local overrides
49
+
if [[ -r$piholeDir/pihole.conf ]];then
50
+
echo"::: Local calibration requested..."
51
+
.$piholeDir/pihole.conf
52
+
fi
53
+
47
54
48
55
if [[ -f$piholeIPv6file ]];then
49
56
# If the file exists, then the user previously chose to use IPv6 in the automated installer
50
57
piholeIPv6=$(ip -6 route get 2001:4860:4860::8888 | awk -F ""'{ for(i=1;i<=NF;i++) if ($i == "src") print $(i+1) }')
51
58
fi
52
59
53
60
54
-
functionHandleOther(){
61
+
functionHandleOther(){
55
62
#check validity of domain
56
-
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/')
57
-
63
+
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/')
58
64
if [ -z"$validDomain" ];then
59
-
echo$1 is not a valid argument or domain name
65
+
echo"::: $1 is not a valid argument or domain name"
60
66
else
61
67
domList=("${domList[@]}"$validDomain)
62
68
fi
@@ -66,13 +72,12 @@ function PopBlacklistFile(){
66
72
#check blacklist file exists, and if not, create it
67
73
if [[ !-f$blacklist ]];then
68
74
touch $blacklist
69
-
fi
70
-
fordomin"${domList[@]}"
71
-
do
72
-
if$addmode;then
73
-
AddDomain $dom
75
+
fi
76
+
fordomin"${domList[@]}";do
77
+
if"$addmode";then
78
+
AddDomain "$dom"
74
79
else
75
-
RemoveDomain $dom
80
+
RemoveDomain "$dom"
76
81
fi
77
82
done
78
83
}
@@ -86,18 +91,18 @@ function AddDomain(){
86
91
if$versbose;then
87
92
echo -n "::: Adding $1 to blacklist file..."
88
93
fi
89
-
echo$1>>$blacklist
94
+
echo"$1">>$blacklist
90
95
modifyHost=true
91
96
echo" done!"
92
97
else
93
98
if$versbose;then
94
-
echo"::: $1 already exists in blacklist.txt! No need to add"
99
+
echo"::: $1 already exists in $blacklist! No need to add"
95
100
fi
96
101
fi
97
102
}
98
103
99
104
functionRemoveDomain(){
100
-
105
+
101
106
bool=false
102
107
grep -Ex -q "$1"$blacklist|| bool=true
103
108
if$bool;then
@@ -110,12 +115,12 @@ function RemoveDomain(){
110
115
if$versbose;then
111
116
echo"::: Un-blacklisting $dom..."
112
117
fi
113
-
domToRemoveList=("${domToRemoveList[@]}"$1)
114
-
modifyHost=true
115
-
fi
118
+
domToRemoveList=("${domToRemoveList[@]}"$1)
119
+
modifyHost=true
120
+
fi
116
121
}
117
122
118
-
functionModifyHostFile(){
123
+
functionModifyHostFile(){
119
124
if$addmode;then
120
125
#add domains to the hosts file
121
126
if [[ -r$blacklist ]];then
@@ -124,28 +129,25 @@ function ModifyHostFile(){
124
129
echo":::"
125
130
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
0 commit comments