From d47fbbbe964fc6c1f8f8f96d44f11fe227c10b53 Mon Sep 17 00:00:00 2001 From: nate Date: Sat, 2 Apr 2016 17:58:10 -0500 Subject: [PATCH] Mcat12 requests. Added bash-completion support --- advanced/bash-completion/pihole | 12 ++++++++++ automated install/basic-install.sh | 3 ++- automated install/uninstall.sh | 11 ++------- pihole.sh => pihole | 38 +++++++++++++++--------------- 4 files changed, 35 insertions(+), 29 deletions(-) create mode 100644 advanced/bash-completion/pihole rename pihole.sh => pihole (60%) diff --git a/advanced/bash-completion/pihole b/advanced/bash-completion/pihole new file mode 100644 index 00000000..026f008f --- /dev/null +++ b/advanced/bash-completion/pihole @@ -0,0 +1,12 @@ +_pihole() +{ + local cur prev opts + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="whitelist blacklist debug flush updateDashboard updateGravity setupLCD chronometer help" + + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 +} +complete -F _pihole pihole \ No newline at end of file diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index ff306d45..4c5afd86 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -483,7 +483,8 @@ installScripts() { $SUDO cp /etc/.pihole/automated\ install/uninstall.sh /opt/pihole/uninstall.sh $SUDO cp /etc/.pihole/advanced/Scripts/setupLCD.sh /opt/pihole/setupLCD.sh $SUDO chmod 755 /opt/pihole/{gravity,chronometer,whitelist,blacklist,piholeLogFlush,updateDashboard,uninstall,setupLCD}.sh - $SUDO cp /etc/.pihole/pihole.sh /usr/local/bin/pihole.sh + $SUDO cp /etc/.pihole/pihole /usr/local/bin/pihole + $SUDO cp /etc/.pihole/advanced/bash-completion/pihole /etc/bash-completion.d/pihole $SUDO echo " done." } diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index 146d5dae..3577e8d6 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -115,21 +115,14 @@ function removeNoPurge { fi fi - $SUDO rm /usr/local/bin/gravity.sh &> /dev/null - $SUDO rm /usr/local/bin/chronometer.sh &> /dev/null - $SUDO rm /usr/local/bin/whitelist.sh &> /dev/null - $SUDO rm /usr/local/bin/blacklist.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeLogFlush.sh &> /dev/null - $SUDO rm /usr/local/bin/piholeDebug.sh &> /dev/null - $SUDO rm /usr/local/bin/updateDashboard.sh &> /dev/null - $SUDO rm /usr/local/bin/uninstall.sh &> /dev/null $SUDO rm /etc/dnsmasq.d/adList.conf &> /dev/null $SUDO rm /etc/dnsmasq.d/01-pihole.conf &> /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 /opt/pihole/ &> /dev/null - $SUDO rm /usr/local/bin/pihole.sh &> /dev/null + $SUDO rm /usr/local/bin/pihole &> /dev/null + $SUDO rm /etc/bash-completion.d/pihole echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" diff --git a/pihole.sh b/pihole similarity index 60% rename from pihole.sh rename to pihole index f730c210..9944c0fa 100755 --- a/pihole.sh +++ b/pihole @@ -16,7 +16,7 @@ if [[ $EUID -eq 0 ]];then else echo "::: Sudo will be used for this tool." # Check if it is actually installed - # If it isn't, exit because the unnstall cannot complete + # If it isn't, exit because the pihole cannot be invoked without privileges. if [[ $(dpkg-query -s sudo) ]];then export SUDO="sudo" else @@ -70,18 +70,18 @@ function helpFunc { echo "::: Control all PiHole specific functions!" echo ":::" echo "::: Usage: pihole.sh [options]" - printf ":::\tAdd -h after -w, -b, or -c 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 "::: Options:" - echo "::: -w, --whitelist Whitelist domains" - echo "::: -b, --blacklist Blacklist domains" - echo "::: -d, --debug Start a debugging session if having trouble" - echo "::: -f, --flush Flush the pihole.log file" - echo "::: -u, --updateDashboard Update the web dashboard manually" - 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 "::: -c, --chronometer Calculates stats and displays to an LCD" - echo "::: -h, --help Show this help dialog" + echo "::: -w, whitelist Whitelist domains" + echo "::: -b, blacklist Blacklist domains" + echo "::: -d, debug Start a debugging session if having trouble" + echo "::: -f, flush Flush the pihole.log file" + echo "::: -u, updateDashboard Update the web dashboard manually" + 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 "::: -c, chronometer Calculates stats and displays to an LCD" + echo "::: -h, help Show this help dialog" exit 1 } @@ -91,13 +91,13 @@ fi # Handle redirecting to specific functions based on arguments case "$1" in -"-w" | "--whitelist" ) whitelistFunc "$@";; -"-b" | "--blacklist" ) blacklistFunc "$@";; -"-d" | "--debug" ) debugFunc;; -"-f" | "--flush" ) flushFunc;; -"-u" | "--updateDashboard" ) updateDashboardFunc;; -"-s" | "--setupLCD" ) setupLCDFunction;; -"-c" | "--chronometer" ) chronometerFunc;; -"-h" | "--help" ) helpFunc;; +"-w" | "whitelist" ) whitelistFunc "$@";; +"-b" | "blacklist" ) blacklistFunc "$@";; +"-d" | "debug" ) debugFunc;; +"-f" | "flush" ) flushFunc;; +"-u" | "-updateDashboard" ) updateDashboardFunc;; +"-s" | "setupLCD" ) setupLCDFunction;; +"-c" | "chronometer" ) chronometerFunc;; +"-h" | "help" ) helpFunc;; * ) helpFunc;; esac