It is not a good idea to ask for an admin password just to get the
command documentation.
"pihole -h" should return the arguments documentation with no need to
enter a password.
Without the patch I get:
$ ./pihole -h
Password:
It is easy to reproduce by invalidating the sudo password using
"sudo -k" before running pihole again.
Signed-off-by: Ludovic Rousseau <ludovic.rousseau@free.fr>
If stdout was not a terminal (the `-t 1` check), `restartDNS` would
return code 1 in the success case. This caused the API to fail whenever
it tried to restart the DNS server.
Signed-off-by: Mcat12 <newtoncat12@yahoo.com>
* Validate modified code using Shellcheck & Strict Bash
* Added and/or elaborated more comments
* scanlist() should exit if /etc/pihole is not available
* Add `export LC_CTYPE=C` to prevent extreme grep slowdown
* Consider "domain.com#comment" an exact match
* Add specialised wildcard searching grep
* Optimise and simplify queryFunc() for readability
* Replace IDN `python` parsing with `idn2`, as `python` is not guaranteed to be available
* Use ${COL_BOLD} when printing filenames
* Make colfile readonly, and use path of PI_HOLE_SCRIPT_DIR
* Rename piholeStatus function to statusFunc for function name consistency
* Replace superseded netstat command with nc
* Perform addn-hosts check using a single grep subshell
* Fix queryFunc if adlists URLs have been removed
* Allow for -adlists command line switch (where the "s" is a typo)
* Add error message when unable to find associated adlists URL
* Provide PR fix on current dev version
* Add blResult variable for white/black match
* Supporting Block Page queryFunc fixes
* Re-add unmerged lines
* Only attempt to install FTL if branch was found
* ~~corebranches~~ webbranches (web branches now actually listed)
Signed-off-by: Adam Warner <adamw@rner.email>
* User-friendly queryFunc() output
* Silence grep errors
* Provide 'pihole -q -h' help output
* Rewrite option handling
* Loop through grep stdout to make query output user friendly
* Add -adlist option to show block list URL instead of internal file name
* Limit general searches to 10 matches per block list
* Add -all option to override 10 match limit
* Fixed 'pihole -h' wording
* Further query optimisations
* Optimised scanList() output by switching folder
* Re-added processWildcards() function
* Added "-bp" exact matching option for use with block page
* Standardised query output
* Separated wildcard search from blacklist/whitelist search
* Optimised sorting by sorting glob output and not scanList() output
* Fixed result skipping
* Add text for wildcard result on exact query
* Fix wildcard result output
* Multiple wildcard matches on exact query could cause unexpected output
* Remove unnecessary replacement
* Make grep only output matching text
* HOSTS format lists will also output the IP address
* That substitution was necessary
* Remove IP address from HOSTS format lists
* Filter unwanted content
* Add /dev/null to grep, to always print file name (even when searching only one block list)
* Use three seds to remove unwanted content from block lists
* Merge with development
* Simplify queryFunc code
* Colourise tailFunc
* Strip month, day number and dnsmasq[PID]
* Blocked domains show as light red
* Queries show as standard colour
* Everything else as dark gray
* Change tailFunc highlighted lines
* Highlight Blocked/Blacklist/Wildcard lines as red
* Make DHCP lines default colour
* Make sure tailFunc doesn't match on domain names
* Define colours within COL_TABLE
* Do not output colours for non-terminal instances
* Removed ":::"
* Fixed indenting & spacing
* Made output consistent throughout project
* Reworded text to fit on standard 80 char wide Terminal screen
* Made 'sudo raspi-config' warning (insufficient disk space) only show on RPi
* Make "Installation/Update Complete" the final msg
* Remove redundant messages
* Simplify update available message
* Confirm user would like to begin uninstall
* If "git pull" string says "Already up-to-date.", place [i] before it
* Colour Temp/Interface output
* Made `pihole disable 5z` invalid
* Added error fallback if invalid argument (not s/m) is detected
* Quoted "$2" for consistency
* Updated help text
* L185/286: Replaced echo with redirect
* User agents for adblock.mahakala.is/adaway.org unnecessary
* Print newline on confirmation of repository reset
* Add output to admin-related dnsmasq restarts
* Return error message for "pihole -q"
* Imply default checkout behaviour with y/N
* Fix uninstall failing to remove pihole user
* Print checkout 'git remote show origin' STDERR on new line
* Replaced checkout "AdminLTE" wording with "Web Admin"
* Check to see if Tricorder is being called directly
* Provide opt-out for insecure transmission of debug log
* Remove mention of internal function from help menu
* File consistency
* Tabs to 2 spaces
* Corrected indenting
* Double braced conditionals
* Quoted variables within conditionals
* Standardise core help text
* Added help text for disable command
* Added help text for logging command
* Clean up
* Fixed certain new lines and spaces
* Sync with development branch
* Formatting consistency
* Tabs to 2 spaces
* Corrected indenting
* Double braced conditionals
* Quoted variables within conditionals
* Fixed certain newlines and spaces
* Admin help text
* Added help text for interface command
* Sync with development branch
* Formatting consistency
* Tabs to 2 spaces
* Fixed some wording
* Fixed certain spaces
* Formatting consistency
* Minor wording changes
* Tabs to 2 spaces
* Corrected indenting
* Double braced conditionals
* Quoted variables within conditionals
* Fixed certain newlines and spaces
* Blacklist help text
* Formatting consistency
* Tabs to 2 spaces
* Corrected indenting
* Cronometer help text
* Formatting consistency
* Fixed certain newlines and spaces
* Corrected indenting
* Checkout warning alteration
* Add checkout help text
* Corrected help output
If there is a match in Whitelist/Blacklist/Wildcards, `[ ! -t 1 ]` will cause the search to end if the terminal is closed when the script is called. This has the intended effect of allowing a user to search for a W/B/W domain (as well as all the adlists it's found in) using `pihole -q` via Terminal, but the script will stop searching after a W/B/W match when called by the block page.
* Allow scanList() to search files using a wildcard by removing quotes wrapped around `${list}`
* scanList() will not provide a domain ouput on each string if exact is specified (`grep -l`)
* Remove unused processWildcards() function
* Return a message if no domain is specified
* IDN domains are converted to punycode when running a `pihole -q` search if the `python` package is available, otherwise will revert to current behaviour
* Scan Blacklist & Wildcards first, exiting from search if a match is found (Fixes#1330)
* Use one `grep` subshell to search for all "*.domains" lists at once (opposed to looping to get every matching file name, and then spawning a `grep` instance for every matching file)
* queryFunc() will not return "(0 results)" output from files where no match is found
* Sort results based off list number
* Return a message if no results are found