Merge pull request #456 from pi-hole/BigFix453

Fixes issue #453
This commit is contained in:
Adam Warner 2016-04-10 21:20:46 +01:00
commit 31ea3a2757
4 changed files with 31 additions and 31 deletions

View file

@ -53,15 +53,15 @@ function helpFunc()
{ {
echo "::: Immediately blacklists one or more domains in the hosts file" echo "::: Immediately blacklists one or more domains in the hosts file"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -b domain1 [domain2 ...]" echo "::: Usage: sudo pihole -b domain1 [domain2 ...]"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -d, --delmode Remove domains from the blacklist" echo "::: -d, --delmode Remove domains from the blacklist"
echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq" echo "::: -nr, --noreload Update blacklist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose" echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog" echo "::: -h, --help Show this help dialog"
echo "::: -l, --list Display your blacklisted domains" echo "::: -l, --list Display your blacklisted domains"
exit 1 exit 1
} }
@ -70,7 +70,7 @@ function HandleOther(){
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/') 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 if [ -z "$validDomain" ]; then
echo "::: $1 is not a valid argument or domain name" echo "::: $1 is not a valid argument or domain name"
else else
domList=("${domList[@]}" $validDomain) domList=("${domList[@]}" $validDomain)
fi fi
} }
@ -134,12 +134,12 @@ function ModifyHostFile(){
numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l) numberOf=$(cat $blacklist | sed '/^\s*$/d' | wc -l)
plural=; [[ "$numberOf" != "1" ]] && plural=s plural=; [[ "$numberOf" != "1" ]] && plural=s
echo ":::" echo ":::"
echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..." echo -n "::: Modifying HOSTS file to blacklist $numberOf domain${plural}..."
if [[ -n $piholeIPv6 ]];then if [[ -n $piholeIPv6 ]];then
cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList cat $blacklist | awk -v ipv4addr="$piholeIP" -v ipv6addr="$piholeIPv6" '{sub(/\r$/,""); print ipv4addr" "$0"\n"ipv6addr" "$0}' >> $adList
else else
cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList cat $blacklist | awk -v ipv4addr="$piholeIP" '{sub(/\r$/,""); print ipv4addr" "$0}' >>$adList
fi fi
fi fi
else else
echo ":::" echo ":::"
@ -148,7 +148,7 @@ function ModifyHostFile(){
#we need to remove the domains from the blacklist file and the host file #we need to remove the domains from the blacklist file and the host file
echo "::: $dom" echo "::: $dom"
echo -n "::: removing from HOSTS file..." echo -n "::: removing from HOSTS file..."
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /[^.]'{}'(?!.)/;' $adList
echo " done!" echo " done!"
echo -n "::: removing from blackist.txt..." echo -n "::: removing from blackist.txt..."
echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist echo "$dom" | sed 's/\./\\./g' | xargs -I {} perl -i -ne'print unless /'{}'(?!.)/;' $blacklist

View file

@ -120,7 +120,7 @@ function normalChrono(){
function displayHelp(){ function displayHelp(){
echo "::: Displays stats about your piHole!" echo "::: Displays stats about your piHole!"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -c [optional:-j]" echo "::: Usage: sudo pihole -c [optional:-j]"
echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds" echo "::: Note: If no option is passed, then stats are displayed on screen, updated every 5 seconds"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"

View file

@ -52,15 +52,15 @@ function helpFunc()
{ {
echo "::: Immediately whitelists one or more domains in the hosts file" echo "::: Immediately whitelists one or more domains in the hosts file"
echo ":::" echo ":::"
echo "::: Usage: sudo pihole.sh -w domain1 [domain2 ...]" echo "::: Usage: sudo pihole -w domain1 [domain2 ...]"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -d, --delmode Remove domains from the whitelist" echo "::: -d, --delmode Remove domains from the whitelist"
echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq" echo "::: -nr, --noreload Update Whitelist without refreshing dnsmasq"
echo "::: -f, --force Force updating of the hosts files, even if there are no changes" echo "::: -f, --force Force updating of the hosts files, even if there are no changes"
echo "::: -q, --quiet output is less verbose" echo "::: -q, --quiet output is less verbose"
echo "::: -h, --help Show this help dialog" echo "::: -h, --help Show this help dialog"
echo "::: -l, --list Display your whitelisted domains" echo "::: -l, --list Display your whitelisted domains"
exit 1 exit 1
} }
@ -220,7 +220,7 @@ if $modifyHost || $force; then
else else
if $verbose; then if $verbose; then
echo ":::" echo ":::"
echo "::: No changes need to be made" echo "::: No changes need to be made"
fi fi
exit 1 exit 1
fi fi

22
pihole
View file

@ -77,20 +77,20 @@ function uninstallFunc {
function helpFunc { function helpFunc {
echo "::: Control all PiHole specific functions!" echo "::: Control all PiHole specific functions!"
echo ":::" echo ":::"
echo "::: Usage: pihole.sh [options]" echo "::: Usage: pihole [options]"
printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n" printf ":::\tAdd -h after -w (whitelist), -b (blacklist), or -c (chronometer) for more information on usage\n"
echo ":::" echo ":::"
echo "::: Options:" echo "::: Options:"
echo "::: -w, whitelist Whitelist domains" echo "::: -w, whitelist Whitelist domains"
echo "::: -b, blacklist Blacklist domains" echo "::: -b, blacklist Blacklist domains"
echo "::: -d, debug Start a debugging session if having trouble" echo "::: -d, debug Start a debugging session if having trouble"
echo "::: -f, flush Flush the pihole.log file" echo "::: -f, flush Flush the pihole.log file"
echo "::: -u, updateDashboard Update the web dashboard manually" echo "::: -u, updateDashboard Update the web dashboard manually"
echo "::: -g, updateGravity Update the list of ad-serving domains" echo "::: -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 "::: -s, setupLCD Automatically configures the Pi to use the 2.8 LCD screen to display stats on it"
echo "::: -c, chronometer Calculates stats and displays to an LCD" echo "::: -c, chronometer Calculates stats and displays to an LCD"
echo "::: -h, help Show this help dialog" echo "::: -h, help Show this help dialog"
echo "::: uninstall Uninstall Pi-Hole from your system!" echo "::: uninstall Uninstall Pi-Hole from your system!"
exit 1 exit 1
} }