mirror of
https://github.com/pi-hole/pi-hole
synced 2024-12-23 07:18:07 +00:00
commit
f5e573371c
@ -25,10 +25,9 @@ r=$(( rows / 2 ))
|
|||||||
c=$(( columns / 2 ))
|
c=$(( columns / 2 ))
|
||||||
|
|
||||||
# Find IP used to route to outside world
|
# Find IP used to route to outside world
|
||||||
IPv4info=$(ip route get 8.8.8.8)
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{for(i=1;i<=NF;i++)if($i~/dev/)print $(i+1)}')
|
||||||
IPv4dev=$(echo $IPv4info| awk '{print $5}')
|
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}' | awk 'END {print}')
|
||||||
IPv4addr=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
|
IPv4gw=$(ip route get 8.8.8.8 | awk '{print $3}')
|
||||||
IPv4gw=$(echo $IPv4info | awk '{print $3}')
|
|
||||||
|
|
||||||
# IPv6 support to be added later
|
# IPv6 support to be added later
|
||||||
#IPv6eui64=$(ip addr show | awk '/scope\ global/ && /ff:fe/ {print $2}' | cut -d'/' -f1)
|
#IPv6eui64=$(ip addr show | awk '/scope\ global/ && /ff:fe/ {print $2}' | cut -d'/' -f1)
|
||||||
@ -93,7 +92,6 @@ cmd=(whiptail --separate-output --checklist "Select Protocols" $r $c 2)
|
|||||||
options=(IPv4 "Block ads over IPv4" on
|
options=(IPv4 "Block ads over IPv4" on
|
||||||
IPv6 "Block ads over IPv4" off)
|
IPv6 "Block ads over IPv4" off)
|
||||||
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
||||||
clear
|
|
||||||
for choice in $choices
|
for choice in $choices
|
||||||
do
|
do
|
||||||
case $choice in
|
case $choice in
|
||||||
@ -172,15 +170,23 @@ done
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setDHCPCD(){
|
||||||
setStaticIPv4()
|
# Append these lines to dhcpcd.conf to enable a static IP
|
||||||
{
|
|
||||||
# Append these lines to /etc/dhcpcd.conf to enable a static IP
|
|
||||||
echo "interface $piholeInterface
|
echo "interface $piholeInterface
|
||||||
static ip_address=$IPv4addr
|
static ip_address=$IPv4addr
|
||||||
static routers=$IPv4gw
|
static routers=$IPv4gw
|
||||||
static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null
|
static domain_name_servers=$IPv4gw" | sudo tee -a $dhcpcdFile >/dev/null
|
||||||
sudo ip addr replace dev $piholeInterface $IPv4addr
|
}
|
||||||
|
|
||||||
|
setStaticIPv4(){
|
||||||
|
if grep -q $IPv4addr $dhcpcdFile; then
|
||||||
|
# address already set, noop
|
||||||
|
:
|
||||||
|
else
|
||||||
|
setDHCPCD
|
||||||
|
sudo ip addr replace dev $piholeInterface $IPv4addr
|
||||||
|
echo "Setting IP to $IPv4addr. You may need to restart after the install is complete."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
installScripts(){
|
installScripts(){
|
||||||
@ -230,11 +236,6 @@ sudo mv /etc/crontab /etc/crontab.orig
|
|||||||
sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
|
sudo curl -o /etc/crontab https://raw.githubusercontent.com/jacobsalmela/pi-hole/master/advanced/pihole.cron
|
||||||
}
|
}
|
||||||
|
|
||||||
installPiLog(){
|
|
||||||
sudo touch /var/log/pihole.log
|
|
||||||
sudo chmod 644 /var/log/pihole.log
|
|
||||||
sudo chown dnsmasq:root /var/log/pihole.log
|
|
||||||
}
|
|
||||||
installPihole()
|
installPihole()
|
||||||
{
|
{
|
||||||
installDependencies
|
installDependencies
|
||||||
@ -248,7 +249,6 @@ installConfigs
|
|||||||
installWebAdmin
|
installWebAdmin
|
||||||
installPiholeWeb
|
installPiholeWeb
|
||||||
installCron
|
installCron
|
||||||
installPiLog
|
|
||||||
sudo /usr/local/bin/gravity.sh
|
sudo /usr/local/bin/gravity.sh
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
gravity.sh
24
gravity.sh
@ -13,8 +13,8 @@ if [[ -f $piholeIPfile ]];then
|
|||||||
else
|
else
|
||||||
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
# Otherwise, the IP address can be taken directly from the machine, which will happen when the script is run by the user and not the installation script
|
||||||
IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}')
|
IPv4dev=$(ip route get 8.8.8.8 | awk '{print $5}')
|
||||||
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}')
|
piholeIPCIDR=$(ip -o -f inet addr show dev $IPv4dev | awk '{print $4}') | awk 'END {print}')
|
||||||
piholeIP=${piholeIPCIDR%/*}
|
piholeIP=${piholeIPCIDR%/*}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Ad-list sources--one per line in single quotes
|
# Ad-list sources--one per line in single quotes
|
||||||
@ -89,7 +89,7 @@ function gravity_transport() {
|
|||||||
url=$1
|
url=$1
|
||||||
cmd_ext=$2
|
cmd_ext=$2
|
||||||
agent=$3
|
agent=$3
|
||||||
|
|
||||||
# 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=""
|
||||||
@ -140,7 +140,7 @@ function gravity_spinup() {
|
|||||||
# Default is a simple request
|
# Default is a simple request
|
||||||
*) cmd_ext=""
|
*) cmd_ext=""
|
||||||
esac
|
esac
|
||||||
gravity_transport $url $cmd_ext $agent
|
gravity_transport $url $cmd_ext $agent
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,14 +151,14 @@ function gravity_Schwarzchild() {
|
|||||||
echo "** Aggregating list of domains..."
|
echo "** Aggregating list of domains..."
|
||||||
truncate -s 0 $piholeDir/$matter
|
truncate -s 0 $piholeDir/$matter
|
||||||
for i in "${activeDomains[@]}"
|
for i in "${activeDomains[@]}"
|
||||||
do
|
do
|
||||||
cat $i |tr -d '\r' >> $piholeDir/$matter
|
cat $i |tr -d '\r' >> $piholeDir/$matter
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Pulsar - White/blacklist application
|
# Pulsar - White/blacklist application
|
||||||
function gravity_pulsar() {
|
function gravity_pulsar() {
|
||||||
|
|
||||||
# Append blacklist entries if they exist
|
# Append blacklist entries if they exist
|
||||||
if [[ -r $blacklist ]];then
|
if [[ -r $blacklist ]];then
|
||||||
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
|
||||||
@ -178,11 +178,11 @@ function gravity_pulsar() {
|
|||||||
# regexp so it can be parsed out with grep -x
|
# regexp so it can be parsed out with grep -x
|
||||||
awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist
|
awk -F '[# \t]' 'NF>0&&$1!="" {print "^"$1"$"}' $whitelist | sed 's/\./\\./g' > $latentWhitelist
|
||||||
else
|
else
|
||||||
rm $latentWhitelist
|
rm $latentWhitelist >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 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 "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
echo "** Whitelisting ${#sources[@]} ad list source${plural}..."
|
||||||
for url in ${sources[@]}
|
for url in ${sources[@]}
|
||||||
do
|
do
|
||||||
@ -210,7 +210,7 @@ function gravity_hostFormat() {
|
|||||||
|
|
||||||
# blackbody - remove any remnant files from script processes
|
# blackbody - remove any remnant files from script processes
|
||||||
function gravity_blackbody() {
|
function gravity_blackbody() {
|
||||||
# Loop through list files
|
# Loop through list files
|
||||||
for file in $piholeDir/*.$justDomainsExtension
|
for file in $piholeDir/*.$justDomainsExtension
|
||||||
do
|
do
|
||||||
# If list is in active array then leave it (noop) else rm the list
|
# If list is in active array then leave it (noop) else rm the list
|
||||||
@ -234,14 +234,14 @@ function gravity_advanced() {
|
|||||||
echo "** $numberOf domains being pulled in by gravity..."
|
echo "** $numberOf domains being pulled in by gravity..."
|
||||||
|
|
||||||
gravity_unique
|
gravity_unique
|
||||||
|
|
||||||
sudo kill -HUP $(pidof dnsmasq)
|
sudo kill -s -HUP $(pidof dnsmasq)
|
||||||
}
|
}
|
||||||
|
|
||||||
gravity_collapse
|
gravity_collapse
|
||||||
gravity_spinup
|
gravity_spinup
|
||||||
gravity_Schwarzchild
|
gravity_Schwarzchild
|
||||||
gravity_pulsar
|
gravity_pulsar
|
||||||
gravity_hostFormat
|
|
||||||
gravity_advanced
|
gravity_advanced
|
||||||
|
gravity_hostFormat
|
||||||
gravity_blackbody
|
gravity_blackbody
|
||||||
|
Loading…
Reference in New Issue
Block a user