Add "pihole -g -b" to *only* update black.list (saves a bunch of time when adding/changing only blacklisted files - won'tdownload lal lists, but only processes the blacklist and restars dnsmasq)

This commit is contained in:
DL6ER 2017-06-17 13:57:27 +02:00
parent 0283a1ab74
commit 0a9c234127
No known key found for this signature in database
GPG key ID: 00135ACBD90B28DD

View file

@ -317,9 +317,8 @@ gravity_doHostFormat() {
fi fi
} }
gravity_hostFormat() { gravity_hostFormatLocal() {
# Format domain list as "192.168.x.x domain.com" # Format domain list as "192.168.x.x domain.com"
echo -n "::: Formatting domains into a HOSTS file..."
if [[ -f /etc/hostname ]]; then if [[ -f /etc/hostname ]]; then
hostname=$(</etc/hostname) hostname=$(</etc/hostname)
@ -333,19 +332,24 @@ gravity_hostFormat() {
# Copy the file over as /etc/pihole/local.list so dnsmasq can use it # Copy the file over as /etc/pihole/local.list so dnsmasq can use it
gravity_doHostFormat "${localList}.tmp" "${localList}" gravity_doHostFormat "${localList}.tmp" "${localList}"
rm "${localList}.tmp" rm "${localList}.tmp"
}
gravity_hostFormatGravity() {
# Format domain list as "192.168.x.x domain.com"
echo "" > "${piholeDir}/${accretionDisc}" echo "" > "${piholeDir}/${accretionDisc}"
gravity_doHostFormat "${piholeDir}/${eventHorizon}" "${piholeDir}/${accretionDisc}" gravity_doHostFormat "${piholeDir}/${eventHorizon}" "${piholeDir}/${accretionDisc}"
# 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}"
rm "${piholeDir}/${accretionDisc}" rm "${piholeDir}/${accretionDisc}"
}
gravity_hostFormatBlack() {
# Format domain list as "192.168.x.x domain.com"
echo -e "" > "${blackList}.tmp" echo -e "" > "${blackList}.tmp"
gravity_doHostFormat "${blackList}.tmp" "${blackList}" gravity_doHostFormat "${blackList}.tmp" "${blackList}"
# Copy the file over as /etc/pihole/black.list so dnsmasq can use it # Copy the file over as /etc/pihole/black.list so dnsmasq can use it
cp "${blackList}.tmp" "${blackList}" cp "${blackList}.tmp" "${blackList}"
rm "${blackList}.tmp" rm "${blackList}.tmp"
echo " done!"
} }
# blackbody - remove any remnant files from script processes # blackbody - remove any remnant files from script processes
@ -386,11 +390,6 @@ gravity_advanced() {
} }
gravity_reload() { gravity_reload() {
#Clear no longer needed files...
echo ":::"
echo -n "::: Cleaning up un-needed files..."
rm ${piholeDir}/pihole.*.txt
echo " done!"
# Reload hosts file # Reload hosts file
echo ":::" echo ":::"
@ -411,6 +410,7 @@ for var in "$@"; do
"-f" | "--force" ) forceGrav=true;; "-f" | "--force" ) forceGrav=true;;
"-h" | "--help" ) helpFunc;; "-h" | "--help" ) helpFunc;;
"-sd" | "--skip-download" ) skipDownload=true;; "-sd" | "--skip-download" ) skipDownload=true;;
"-b" | "--blacklist-only" ) blackListOnly=true;;
esac esac
done done
@ -420,6 +420,7 @@ if [[ "${forceGrav}" == true ]]; then
echo " done!" echo " done!"
fi fi
if [[ ! "${blackListOnly}" == true ]]; then
gravity_collapse gravity_collapse
gravity_spinup gravity_spinup
if [[ "${skipDownload}" == false ]]; then if [[ "${skipDownload}" == false ]]; then
@ -431,11 +432,27 @@ else
echo "::: $numberOf unique domains trapped in the event horizon." echo "::: $numberOf unique domains trapped in the event horizon."
fi fi
gravity_Whitelist gravity_Whitelist
fi
gravity_Blacklist gravity_Blacklist
gravity_Wildcard gravity_Wildcard
gravity_hostFormat echo -n "::: Formatting domains into a HOSTS file..."
if [[ ! "${blackListOnly}" == true ]]; then
gravity_hostFormatLocal
gravity_hostFormatGravity
fi
gravity_hostFormatBlack
echo " done!"
gravity_blackbody gravity_blackbody
if [[ ! "${blackListOnly}" == true ]]; then
#Clear no longer needed files...
echo ":::"
echo -n "::: Cleaning up un-needed files..."
rm ${piholeDir}/pihole.*.txt
echo " done!"
fi
gravity_reload gravity_reload
"${PIHOLE_COMMAND}" status "${PIHOLE_COMMAND}" status