Mcat12 requests. Added bash-completion support

pull/416/head
nate 8 years ago
parent 767b72fbfa
commit d47fbbbe96

@ -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

@ -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."
}

@ -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"

@ -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
Loading…
Cancel
Save