diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 23e67795..4a9c585a 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -1,33 +1,37 @@ -**In raising this issue, I confirm the following (please check boxes, eg [X]) Failure to fill the template will close your issue:** +**In raising this issue, I confirm the following:** `{please fill the checkboxes, e.g: [X]}` - [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). -- [] The issue I am reporting can be *replicated* +- [] The issue I am reporting can be *replicated*. - [] The issue I am reporting isn't a duplicate (see [FAQs](https://github.com/pi-hole/pi-hole/wiki/FAQs), [closed issues](https://github.com/pi-hole/pi-hole/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20), and [open issues](https://github.com/pi-hole/pi-hole/issues)). -**How familiar are you with the codebase?:** +**How familiar are you with the the source code relevant to this issue?:** -_{replace this text with a number from 1 to 10, with 1 being not familiar, and 10 being very familiar}_ +`{Replace this with a number from 1 to 10. 1 being not familiar, and 10 being very familiar}` --- -**[BUG REPORT | OTHER]:** +**Expected behaviour:** -Please [submit your feature request here](https://discourse.pi-hole.net/c/feature-requests), so it is votable by the community. It's also easier for us to track. +`{A detailed description of what you expect to see}` -**[BUG | ISSUE] Expected Behaviour:** +**Actual behaviour:** +`{A detailed description and/or screenshots of what you do see}` -**[BUG | ISSUE] Actual Behaviour:** +**Steps to reproduce:** +`{Detailed steps of how we can reproduce this}` -**[BUG | ISSUE] Steps to reproduce:** +**Debug token provided by [uploading `pihole -d` log](https://discourse.pi-hole.net/t/the-pihole-command-with-examples/738#debug):** -- -- -- -- +`{Alphanumeric token}` -**(Optional) Debug token generated by `pihole -d`:** +**Troubleshooting undertaken, and/or other relevant information:** -`` +`{Steps of what you have done to fix this}` -_This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ +> * `{Please delete this quoted section when opening your issue}` +> * You must follow the template instructions. Failure to do so will result in your issue being closed. +> * Please [submit any feature requests here](https://discourse.pi-hole.net/c/feature-requests), so it is votable and trackable by the community. +> * Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. +> * Detail helps us understand and resolve an issue quicker, but please ensure it's relevant. +> * _This template was created based on the work of [`udemy-dl`](https://github.com/nishad/udemy-dl/blob/master/LICENSE)._ diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 8583806b..96ce4ba5 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,19 +1,32 @@ -**By submitting this pull request, I confirm the following (please check boxes, eg [X]) _Failure to fill the template will close your PR_:** +**By submitting this pull request, I confirm the following:** `{please fill any appropriate checkboxes, e.g: [X]}` -***Please submit all pull requests against the `development` branch. Failure to do so will delay or deny your request*** +`{Please ensure that your pull request is for the 'development' branch!}` -- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md). -- [] I have written tests and verified that they fail without my change. -- [] I have squashed any insignificant commits. -- [] This change has comments for package types, values, functions, and non-obvious lines of code. +- [] I have read and understood the [contributors guide](https://github.com/pi-hole/pi-hole/blob/master/CONTRIBUTING.md), as well as this entire template. +- [] I have made only one major change in my proposed changes. +- [] I have commented my proposed changes within the code. +- [] I have tested my proposed changes, and have included unit tests where possible. - [] I am willing to help maintain this change if there are issues with it later. -- [] I give this submission freely and claim no ownership. It is compatible with the EUPL 1.2 license. -- [] I have Signed Off all commits. (`git commit --signoff`) +- [] I give this submission freely and claim no ownership. +- [] It is compatible with the [EUPL 1.2 license](https://opensource.org/licenses/EUPL-1.1) +- [] I have squashed any insignificant commits. ([`git rebase`](http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html)) +- [] I have Signed Off all commits. ([`git commit --signoff`](https://git-scm.com/docs/git-commit#git-commit---signoff)) -***Please explain what you have done and wish to accomplish with this Pull Request*** +--- -1. What does this change do, exactly? +**What does this PR aim to accomplish?:** -2. Please link to the relevant issues. +`{A detailed description, screenshots (if necessary), as well as links to any relevant GitHub issues}` -3. Which documentation changes (if any) need to be made because of this PR? +**How does this PR accomplish the above?:** + +`{A detailed description (such as a changelog) and screenshots (if necessary) of the implemented fix}` + +**What documentation changes (if any) are needed to support this PR?:** + +`{A detailed list of any necessary changes}` + +> * `{Please delete this quoted section when opening your pull request}` +> * You must follow the template instructions. Failure to do so will result in your issue being closed. +> * Please respect that Pi-hole is developed by volunteers, who can only reply in their spare time. +> * Detail helps us understand an issue quicker, but please ensure it's relevant. diff --git a/pihole b/pihole index 61ed6cd6..ded79f71 100755 --- a/pihole +++ b/pihole @@ -1,4 +1,5 @@ #!/bin/bash + # Pi-hole: A black hole for Internet advertisements # (c) 2017 Pi-hole, LLC (https://pi-hole.net) # Network-wide ad blocking via your own hardware. @@ -8,11 +9,11 @@ # This file is copyright under the latest version of the EUPL. # Please see LICENSE file for your rights under this license. -colfile="/opt/pihole/COL_TABLE" -source ${colfile} - readonly PI_HOLE_SCRIPT_DIR="/opt/pihole" readonly wildcardlist="/etc/dnsmasq.d/03-pihole-wildcard.conf" +readonly colfile="${PI_HOLE_SCRIPT_DIR}/COL_TABLE" + +source ${colfile} # Must be root to use this tool if [[ ! $EUID -eq 0 ]];then @@ -481,41 +482,43 @@ Options: echo -e "${OVER} ${TICK} ${str}" } -piholeStatus() { - if [[ "$(netstat -plnt | grep -c ':53 ')" -gt "0" ]]; then +statusFunc() { + local addnConfigs + + # Determine if service is running on port 53 (Cr: https://superuser.com/a/806331) + if (echo > /dev/tcp/localhost/53) >/dev/null 2>&1; then if [[ "${1}" != "web" ]]; then echo -e " ${TICK} DNS service is running" fi else - if [[ "${1}" == "web" ]]; then - echo "-1"; - else - echo -e " ${CROSS} DNS service is NOT running" - fi - return + case "${1}" in + "web") echo "-1";; + *) echo -e " ${CROSS} DNS service is NOT running";; + esac + return 0 fi - if [[ "$(grep -i "^#addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf)" ]]; then - # List is commented out - if [[ "${1}" == "web" ]]; then - echo 0; - else - echo -e " ${CROSS} Pi-hole blocking is Disabled"; - fi - elif [[ "$(grep -i "^addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf)" ]]; then - # List set - if [[ "${1}" == "web" ]]; then - echo 1; - else - echo -e " ${TICK} Pi-hole blocking is Enabled"; - fi + # Determine if Pi-hole's addn-hosts configs are commented out + addnConfigs=$(grep -i "addn-hosts=/" /etc/dnsmasq.d/01-pihole.conf) + + if [[ "${addnConfigs}" =~ "#" ]]; then + # A config is commented out + case "${1}" in + "web") echo 0;; + *) echo -e " ${CROSS} Pi-hole blocking is Disabled";; + esac + elif [[ -n "${addnConfigs}" ]]; then + # Configs are set + case "${1}" in + "web") echo 1;; + *) echo -e " ${TICK} Pi-hole blocking is Enabled";; + esac else - # Addn-host not found - if [[ "${1}" == "web" ]]; then - echo 99 - else - echo -e " ${INFO} No hosts file linked to dnsmasq, adding it in enabled state" - fi + # No configs were found + case "${1}" in + "web") echo 99;; + *) echo -e " ${INFO} No hosts file linked to dnsmasq, adding it in enabled state";; + esac # Add addn-host= to dnsmasq echo "addn-hosts=/etc/pihole/gravity.list" >> /etc/dnsmasq.d/01-pihole.conf restartDNS @@ -561,7 +564,7 @@ tricorderFunc() { exit 1 fi - if ! timeout 2 nc -z tricorder.pi-hole.net 9998 &> /dev/null; then + if ! (echo > /dev/tcp/tricorder.pi-hole.net/9998) >/dev/null 2>&1; then echo -e " ${CROSS} Unable to connect to Pi-hole's Tricorder server" exit 1 fi @@ -651,7 +654,7 @@ case "${1}" in "uninstall" ) uninstallFunc;; "enable" ) piholeEnable 1;; "disable" ) piholeEnable 0 "$2";; - "status" ) piholeStatus "$2";; + "status" ) statusFunc "$2";; "restartdns" ) restartDNS;; "-a" | "admin" ) webpageFunc "$@";; "-t" | "tail" ) tailFunc;;