From 633095aee1704cc6cced1dc78ea897dac32417f2 Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 2 Nov 2016 22:13:05 -0500 Subject: [PATCH 01/23] switch to consistent style --- automated install/basic-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 14d271ef..534b194d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1149,6 +1149,6 @@ main() { echo "::: The install log is located at: /etc/pihole/install.log" } -if [[ -z "$PHTEST" ]] ; then +if [[ "${PHTEST}" != "TRUE" ]] ; then main "$@" fi From 0d7e06a141ac0bde23f478f878be21e8b7d6cebd Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 2 Nov 2016 22:13:39 -0500 Subject: [PATCH 02/23] remove old pytest output file --- test/shellcheck_failing_output.txt | 76 ------------------------------ 1 file changed, 76 deletions(-) delete mode 100644 test/shellcheck_failing_output.txt diff --git a/test/shellcheck_failing_output.txt b/test/shellcheck_failing_output.txt deleted file mode 100644 index c741a8e9..00000000 --- a/test/shellcheck_failing_output.txt +++ /dev/null @@ -1,76 +0,0 @@ -============================= test session starts ============================== -platform linux2 -- Python 2.7.6, pytest-2.9.2, py-1.4.31, pluggy-0.3.1 -- /usr/bin/python -cachedir: .cache -rootdir: /home/a/opensource/pi-hole, inifile: -plugins: cov-2.3.0, bdd-2.17.0, xdist-1.14, testinfra-1.4.0 -collecting ... collected 7 items - -test/test_000_build_containers.py::test_build_pihole_image[test/debian.Dockerfile-pytest_pihole:debian] PASSED -test/test_000_build_containers.py::test_build_pihole_image[test/centos.Dockerfile-pytest_pihole:centos] PASSED -test/test_automated_install.py::test_setupVars_are_sourced_to_global_scope[debian] PASSED -test/test_automated_install.py::test_setupVars_are_sourced_to_global_scope[centos] PASSED -test/test_automated_install.py::test_setupVars_saved_to_file[debian] PASSED -test/test_automated_install.py::test_setupVars_saved_to_file[centos] PASSED -test/test_shellcheck.py::test_scripts_pass_shellcheck FAILED - -=================================== FAILURES =================================== -_________________________ test_scripts_pass_shellcheck _________________________ - - def test_scripts_pass_shellcheck(): - ''' Make sure shellcheck does not find anything wrong with our shell scripts ''' - shellcheck = "find . -name 'update.sh' | while read file; do shellcheck \"$file\"; done;" - results = run_local(shellcheck) - print results.stdout -> assert '' == results.stdout -E assert '' == '\nIn ./advanced/Scripts/upda...vent glob interpretation.\n\n' -E + -E + In ./advanced/Scripts/update.sh line 24: -E + while [ "$(ps a | awk '{print $1}' | grep "${pid}")" ]; do -E + ^-- SC2143: Instead of [ -n $(foo | grep bar) ], use foo | grep -q bar . -E + -E + -E + In ./advanced/Scripts/update.sh line 57: -E + git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $! -E + ^-- SC2086: Double quote to prevent globbing and word splitting. -E Detailed information truncated (27 more lines), use "-vv" to show - -test/test_shellcheck.py:13: AssertionError ------------------------------ Captured stdout call ----------------------------- - -In ./advanced/Scripts/update.sh line 24: - while [ "$(ps a | awk '{print $1}' | grep "${pid}")" ]; do - ^-- SC2143: Instead of [ -n $(foo | grep bar) ], use foo | grep -q bar . - - -In ./advanced/Scripts/update.sh line 57: - git clone -q --depth 1 "${2}" "${1}" > /dev/null & spinner $! - ^-- SC2086: Double quote to prevent globbing and word splitting. - - -In ./advanced/Scripts/update.sh line 65: - git stash -q > /dev/null & spinner $! - ^-- SC2086: Double quote to prevent globbing and word splitting. - - -In ./advanced/Scripts/update.sh line 66: - git pull -q > /dev/null & spinner $! - ^-- SC2086: Double quote to prevent globbing and word splitting. - - -In ./advanced/Scripts/update.sh line 107: -if [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then - ^-- SC2053: Quote the rhs of = in [[ ]] to prevent glob interpretation. - ^-- SC2053: Quote the rhs of = in [[ ]] to prevent glob interpretation. - - -In ./advanced/Scripts/update.sh line 112: -elif [[ ${piholeVersion} == ${piholeVersionLatest} && ${webVersion} != ${webVersionLatest} ]]; then - ^-- SC2053: Quote the rhs of = in [[ ]] to prevent glob interpretation. - - -In ./advanced/Scripts/update.sh line 120: -elif [[ ${piholeVersion} != ${piholeVersionLatest} && ${webVersion} == ${webVersionLatest} ]]; then - ^-- SC2053: Quote the rhs of = in [[ ]] to prevent glob interpretation. - - -===================== 1 failed, 6 passed in 24.01 seconds ====================== From 05e114173db93f9395866995c004138d1a9e56db Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 2 Nov 2016 23:25:13 -0500 Subject: [PATCH 03/23] update comments, add configureFirewall test * Comments to clarify some of the existing tests * mock_command to allow recording of calls and mocking return calls in bash * new configureFirewall test (only the first one of it's many paths) --- test/test_automated_install.py | 41 ++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 458536eb..b720b94d 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -10,8 +10,9 @@ SETUPVARS = { } def test_setupVars_are_sourced_to_global_scope(Pihole): - ''' currently update_dialogs sources setupVars with a dot, - then various other functions use the variables ''' + ''' currently update_dialogs sources setupVars with a dot, + then various other functions use the variables. + This confirms the sourced variables are in scope between functions ''' setup_var_file = 'cat < /etc/pihole/setupVars.conf\n' for k,v in SETUPVARS.iteritems(): setup_var_file += "{}={}\n".format(k, v) @@ -64,6 +65,42 @@ def test_setupVars_saved_to_file(Pihole): for k,v in SETUPVARS.iteritems(): assert "{}={}".format(k, v) in output +def test_configureFirewall_firewalld_no_errors(Pihole): + ''' confirms firewalld rules are applied when appopriate ''' + mock_command('firewall-cmd', '0', Pihole) + configureFirewall = Pihole.run(''' + bash -c " + PHTEST=TRUE + source /opt/pihole/basic-install.sh + configureFirewall + " ''') + expected_stdout = '::: Configuring firewalld for httpd and dnsmasq.' + assert expected_stdout in configureFirewall.stdout + firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout + assert 'firewall-cmd --state' in firewall_calls + assert 'firewall-cmd --permanent --add-port=80/tcp' in firewall_calls + assert 'firewall-cmd --permanent --add-port=53/tcp' in firewall_calls + assert 'firewall-cmd --permanent --add-port=53/udp' in firewall_calls + assert 'firewall-cmd --reload' in firewall_calls + + +# Helper functions +def mock_command(script, result, container): + ''' Allows for setup of commands we don't really want to have to run for real in unit tests ''' + ''' TODO: support array of results that enable the results to change over multiple executions of a command ''' + full_script_path = '/usr/local/bin/{}'.format(script) + mock_script = dedent('''\ + #!/bin/bash -e + echo "\$0 \$@" >> /var/log/{script} + exit {retcode} + '''.format(script=script, retcode=result)) + container.run(''' + cat < {script}\n{content}\nEOF + chmod +x {script} + '''.format(script=full_script_path, content=mock_script)) + print container.run('cat {}'.format(full_script_path)).stdout + + def run_script(Pihole, script, file="/test.sh"): _write_test_script(Pihole, script, file=file) result = Pihole.run(file) From 699e29934521587066f001800f09e76badc0a1d4 Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 2 Nov 2016 23:40:50 -0500 Subject: [PATCH 04/23] add a comment about bash vs dash. future refact needed --- test/test_automated_install.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/test_automated_install.py b/test/test_automated_install.py index b720b94d..6a3daf60 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -110,5 +110,8 @@ def run_script(Pihole, script, file="/test.sh"): def _write_test_script(Pihole, script, file): ''' Running the test script blocks directly can behave differently with regard to global vars ''' ''' this is a cheap work around to that until all functions no longer rely on global variables ''' + ''' found out why, dash: is the default in testinfra run() for Docker + Should try and convert the tests using this to firewalld style test + or override the run() function to use bash instead ''' Pihole.run('cat < {file}\n{script}\nEOF'.format(file=file, script=script)) Pihole.run('chmod +x {}'.format(file)) From a5a067d50fb15c5d1d03f6d0c70bb587c21c11db Mon Sep 17 00:00:00 2001 From: diginc Date: Wed, 2 Nov 2016 23:58:54 -0500 Subject: [PATCH 05/23] switching testinfra's Docker run from dash to bash --- test/conftest.py | 14 ++++++++++++++ test/test_automated_install.py | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/test/conftest.py b/test/conftest.py index 407d00dc..e99e47a3 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -8,6 +8,20 @@ check_output = testinfra.get_backend( @pytest.fixture def Pihole(Docker): ''' used to contain some script stubbing, now pretty much an alias ''' + def run_bash(self, command, *args, **kwargs): + cmd = self.get_command(command, *args) + if self.user is not None: + out = self.run_local( + "docker exec -u %s %s /bin/bash -c %s", + self.user, self.name, cmd) + else: + out = self.run_local( + "docker exec %s /bin/bash -c %s", self.name, cmd) + out.command = self.encode(cmd) + return out + + funcType = type(Docker.run) + Docker.run = funcType(run_bash, Docker, testinfra.backend.docker.DockerBackend) return Docker @pytest.fixture diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 6a3daf60..45fecfd0 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -69,11 +69,10 @@ def test_configureFirewall_firewalld_no_errors(Pihole): ''' confirms firewalld rules are applied when appopriate ''' mock_command('firewall-cmd', '0', Pihole) configureFirewall = Pihole.run(''' - bash -c " PHTEST=TRUE source /opt/pihole/basic-install.sh configureFirewall - " ''') + ''') expected_stdout = '::: Configuring firewalld for httpd and dnsmasq.' assert expected_stdout in configureFirewall.stdout firewall_calls = Pihole.run('cat /var/log/firewall-cmd').stdout From d2f815bba7c122d22bdfaf70e2ad2e4272e39fe6 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 3 Nov 2016 00:02:28 -0500 Subject: [PATCH 06/23] no longer need to write bash test scripts --- test/test_automated_install.py | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 45fecfd0..19d87fe8 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -20,15 +20,15 @@ def test_setupVars_are_sourced_to_global_scope(Pihole): Pihole.run(setup_var_file) script = dedent('''\ - #!/bin/bash -e + set -e printSetupVars() { # Currently debug test function only echo "Outputting sourced variables" - echo "PIHOLE_INTERFACE=\${PIHOLE_INTERFACE}" - echo "IPV4_ADDRESS=\${IPV4_ADDRESS}" - echo "IPV6_ADDRESS=\${IPV6_ADDRESS}" - echo "PIHOLE_DNS_1=\${PIHOLE_DNS_1}" - echo "PIHOLE_DNS_2=\${PIHOLE_DNS_2}" + echo "PIHOLE_INTERFACE=${PIHOLE_INTERFACE}" + echo "IPV4_ADDRESS=${IPV4_ADDRESS}" + echo "IPV6_ADDRESS=${IPV6_ADDRESS}" + echo "PIHOLE_DNS_1=${PIHOLE_DNS_1}" + echo "PIHOLE_DNS_2=${PIHOLE_DNS_2}" } update_dialogs() { . /etc/pihole/setupVars.conf @@ -50,7 +50,7 @@ def test_setupVars_saved_to_file(Pihole): Pihole.run(set_setup_vars).stdout script = dedent('''\ - #!/bin/bash -e + set -e echo start TERM=xterm PHTEST=TRUE @@ -100,17 +100,7 @@ def mock_command(script, result, container): print container.run('cat {}'.format(full_script_path)).stdout -def run_script(Pihole, script, file="/test.sh"): - _write_test_script(Pihole, script, file=file) - result = Pihole.run(file) +def run_script(Pihole, script): + result = Pihole.run(script) assert result.rc == 0 return result - -def _write_test_script(Pihole, script, file): - ''' Running the test script blocks directly can behave differently with regard to global vars ''' - ''' this is a cheap work around to that until all functions no longer rely on global variables ''' - ''' found out why, dash: is the default in testinfra run() for Docker - Should try and convert the tests using this to firewalld style test - or override the run() function to use bash instead ''' - Pihole.run('cat < {file}\n{script}\nEOF'.format(file=file, script=script)) - Pihole.run('chmod +x {}'.format(file)) From 5b54b9cb11173a0ffcab78d089da47c65236d77b Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 3 Nov 2016 00:05:19 -0500 Subject: [PATCH 07/23] update Pihole fixture comment --- test/conftest.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/conftest.py b/test/conftest.py index e99e47a3..5960cc24 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -7,7 +7,8 @@ check_output = testinfra.get_backend( @pytest.fixture def Pihole(Docker): - ''' used to contain some script stubbing, now pretty much an alias ''' + ''' used to contain some script stubbing, now pretty much an alias. + Also provides bash as the default run function shell ''' def run_bash(self, command, *args, **kwargs): cmd = self.get_command(command, *args) if self.user is not None: From c2930b0ca5fff156924d19ff71e6fc2ea76fd3bc Mon Sep 17 00:00:00 2001 From: Adam Hill Date: Thu, 3 Nov 2016 08:34:44 -0500 Subject: [PATCH 08/23] remove the debug print in mock_command --- test/test_automated_install.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/test_automated_install.py b/test/test_automated_install.py index 19d87fe8..a3c80666 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -97,8 +97,6 @@ def mock_command(script, result, container): cat < {script}\n{content}\nEOF chmod +x {script} '''.format(script=full_script_path, content=mock_script)) - print container.run('cat {}'.format(full_script_path)).stdout - def run_script(Pihole, script): result = Pihole.run(script) From b9f3493dbc13dffb72172118abb5bf8f8312dd04 Mon Sep 17 00:00:00 2001 From: diginc Date: Thu, 3 Nov 2016 22:34:04 -0500 Subject: [PATCH 09/23] move PH_TRUE to Dockerfiles to DRY --- automated install/basic-install.sh | 2 +- test/centos.Dockerfile | 2 ++ test/debian.Dockerfile | 3 ++- test/test_automated_install.py | 2 -- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/automated install/basic-install.sh b/automated install/basic-install.sh index 534b194d..491f7b6d 100755 --- a/automated install/basic-install.sh +++ b/automated install/basic-install.sh @@ -1149,6 +1149,6 @@ main() { echo "::: The install log is located at: /etc/pihole/install.log" } -if [[ "${PHTEST}" != "TRUE" ]] ; then +if [[ "${PH_TEST}" != true ]] ; then main "$@" fi diff --git a/test/centos.Dockerfile b/test/centos.Dockerfile index 9af7eb4d..00543b67 100644 --- a/test/centos.Dockerfile +++ b/test/centos.Dockerfile @@ -11,4 +11,6 @@ ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR RUN true && \ chmod +x $SCRIPTDIR/* +ENV PH_TEST true + #sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \ diff --git a/test/debian.Dockerfile b/test/debian.Dockerfile index b80d6155..931c0ba7 100644 --- a/test/debian.Dockerfile +++ b/test/debian.Dockerfile @@ -8,8 +8,9 @@ ADD . $GITDIR RUN cp $GITDIR/advanced/Scripts/*.sh $GITDIR/gravity.sh $GITDIR/pihole $GITDIR/automated\ install/*.sh $SCRIPTDIR/ ENV PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$SCRIPTDIR - RUN true && \ chmod +x $SCRIPTDIR/* +ENV PH_TEST true + #sed '/# Start the installer/Q' /opt/pihole/basic-install.sh > /opt/pihole/stub_basic-install.sh && \ diff --git a/test/test_automated_install.py b/test/test_automated_install.py index a3c80666..ee3beeee 100644 --- a/test/test_automated_install.py +++ b/test/test_automated_install.py @@ -53,7 +53,6 @@ def test_setupVars_saved_to_file(Pihole): set -e echo start TERM=xterm - PHTEST=TRUE source /opt/pihole/basic-install.sh {} finalExports @@ -69,7 +68,6 @@ def test_configureFirewall_firewalld_no_errors(Pihole): ''' confirms firewalld rules are applied when appopriate ''' mock_command('firewall-cmd', '0', Pihole) configureFirewall = Pihole.run(''' - PHTEST=TRUE source /opt/pihole/basic-install.sh configureFirewall ''') From fd7e4f2268eaea02f338ea1dd8056e80be811d03 Mon Sep 17 00:00:00 2001 From: Nicolas Lamirault Date: Tue, 15 Nov 2016 09:27:16 +0100 Subject: [PATCH 10/23] Add Pi-Hole Prometheus exporter project --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ed75d742..666fe863 100644 --- a/README.md +++ b/README.md @@ -107,6 +107,7 @@ You can view [real-time stats](http://pi-hole.net/faq/install-the-real-time-lcd- - [Minibian Pi-hole](http://munkjensen.net/wiki/index.php/See_my_Pi-Hole#Minibian_Pi-hole) - [Windows Tray Stat Application](https://github.com/goldbattle/copernicus) - [Let your blink1 device blink when Pi-hole filters ads](https://gist.github.com/elpatron68/ec0b4c582e5abf604885ac1e068d233f) +- [Pi-Hole Prometheus exporter](https://github.com/nlamirault/pihole_exporter) : a [Prometheus](https://prometheus.io/) exporter for Pi-Hole ## Coverage From 86d3ca48ae086c3833db345e24a545ab89cb7e56 Mon Sep 17 00:00:00 2001 From: Hayden Knowles Date: Tue, 15 Nov 2016 22:40:57 +1300 Subject: [PATCH 11/23] moved newline to correct place --- automated install/uninstall.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index abba88a5..6ed429aa 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -82,7 +82,7 @@ removeAndPurge() { read -rp "::: Do you wish to remove ${i} from your system? [y/n]: " yn case ${yn} in [Yy]* ) printf ":::\tRemoving %s..." "${i}"; ${SUDO} ${PKG_REMOVE} "${i}" &> /dev/null & spinner $!; printf "done!\n"; break;; - [Nn]* ) printf ":::\tSkipping %s" "${i}\n"; break;; + [Nn]* ) printf ":::\tSkipping %s\n" "${i}"; break;; * ) printf "::: You must answer yes or no!\n";; esac done From b191cd73a7810ee744e963d11e77f678b16ab616 Mon Sep 17 00:00:00 2001 From: Adam Warner Date: Tue, 15 Nov 2016 13:28:18 +0000 Subject: [PATCH 12/23] Update piholeDebug.sh wording --- advanced/Scripts/piholeDebug.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 6768a8ea..fd4b475d 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -384,10 +384,13 @@ finalWork() { # Check if tricorder.pi-hole.net is reachable and provide token. if [ -n "${tricorder}" ]; then echo "::: Your debug token is : ${tricorder}" - echo "::: Please contact the Pi-hole team with your token to being assistance." + echo "::: Please contact the Pi-hole team with your token for assistance." echo "::: Thank you." + else + echo "::: There was an error uploading your debug log." + echo "::: Please try again or contact the Pi-hole team for assistance." fi - echo "::: Debug log can be found at : /var/log/pihole_debug.log" + echo "::: A local copy of the Debug log can be found at : /var/log/pihole_debug.log" } trap finalWork EXIT From fd0dd9f54cc31ea4fb280ccff07d2c24823546cb Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 16 Nov 2016 13:55:29 -0800 Subject: [PATCH 13/23] Add GSG/Shell link --- CONTRIBUTING.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 539f55d5..d342a8b5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -33,5 +33,6 @@ When requesting or submitting new features, first consider whether it might be u - Submit Pull Requests to the **development branch only**. - Before Submitting your Pull Request, merge `development` with your new branch and fix any conflicts. (Make sure you don't break anything in development!) +- Please use the [Google Style Guide for Shell](https://google.github.io/styleguide/shell.xml) for your code submission styles. - Commit Unix line endings. - (Optional fun) keep to the theme of Star Trek/black holes/gravity. From cac9c633259ec92d9c1c022f7c5330faa8a87028 Mon Sep 17 00:00:00 2001 From: zbholman Date: Wed, 16 Nov 2016 17:06:30 -0500 Subject: [PATCH 14/23] Added removal of pihole user to the uninstall.sh Not sure if I should have created a variable for the username or if the echo is necessary. And this is my first time doing a pull request, hopefully it works out lol. --- automated install/uninstall.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/automated install/uninstall.sh b/automated install/uninstall.sh index abba88a5..b3ce5c7e 100755 --- a/automated install/uninstall.sh +++ b/automated install/uninstall.sh @@ -154,6 +154,12 @@ removeNoPurge() { ${SUDO} rm /usr/local/bin/pihole &> /dev/null ${SUDO} rm /etc/bash_completion.d/pihole &> /dev/null ${SUDO} rm /etc/sudoers.d/pihole &> /dev/null + + # If the pihole user exists, then remove + if id "pihole" >/dev/null 2>&1; then + echo "::: Removing pihole user..." + ${SUDO} userdel -r pihole + fi echo ":::" printf "::: Finished removing PiHole from your system. Sorry to see you go!\n" From 9bce5a09f35dd92b08c42ff0cc8f8f8ba1e61f47 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Wed, 16 Nov 2016 21:42:54 -0800 Subject: [PATCH 15/23] Small change in template Just a space, and italicize --- .github/PULL_REQUEST_TEMPLATE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 3882215d..9d6310d0 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -1,4 +1,4 @@ -**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 check boxes, eg [X]) _Failure to fill the template will close your PR_:** ***Please submit all pull requests against the `development` branch. Failure to do so will delay or deny your request*** From a95ce11ca68c7e9e0decdc0ed451a6fbc0384c1f Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 17 Nov 2016 10:39:51 -0800 Subject: [PATCH 16/23] Add debug timeoute --- advanced/Scripts/piholeDebug.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index fd4b475d..375fb927 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -27,7 +27,7 @@ PIHOLELOG="/var/log/pihole.log" WHITELISTMATCHES="/tmp/whitelistmatches.list" IPV6_READY=false - +TIMEOUT=60 # Header info and introduction cat << EOM ::: Beginning Pi-hole debug at $(date)! @@ -356,9 +356,10 @@ dumpPiHoleLog() { echo -e "::: Try loading a site that you are having trouble with now from a client web browser.. \n:::\t(Press CTRL+C to finish logging.)" header_write "pihole.log" if [ -e "${PIHOLELOG}" ]; then + # Dummy process to use for flagging down tail to terminate + sleep ${TIMEOUT} & while true; do - tail -f "${PIHOLELOG}" >> ${DEBUG_LOG} - log_write "" + tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG} done else log_write "No pihole.log file found!" From 6d2c5b23122dc7ffc4be5981cb5ceaa95561836d Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 17 Nov 2016 10:58:58 -0800 Subject: [PATCH 17/23] Add debug timeoute --- advanced/Scripts/piholeDebug.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index 375fb927..b39d038c 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -27,7 +27,7 @@ PIHOLELOG="/var/log/pihole.log" WHITELISTMATCHES="/tmp/whitelistmatches.list" IPV6_READY=false -TIMEOUT=60 +TIMEOUT=15 # Header info and introduction cat << EOM ::: Beginning Pi-hole debug at $(date)! @@ -358,9 +358,7 @@ dumpPiHoleLog() { if [ -e "${PIHOLELOG}" ]; then # Dummy process to use for flagging down tail to terminate sleep ${TIMEOUT} & - while true; do - tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG} - done + tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG} else log_write "No pihole.log file found!" printf ":::\tNo pihole.log file found!\n" From 0f4c8d4923a2d55d357e89aefaed802ed4d537f3 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Thu, 17 Nov 2016 11:00:11 -0800 Subject: [PATCH 18/23] Set default timeout to 60 seconds --- advanced/Scripts/piholeDebug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index b39d038c..c91edf2a 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -27,7 +27,7 @@ PIHOLELOG="/var/log/pihole.log" WHITELISTMATCHES="/tmp/whitelistmatches.list" IPV6_READY=false -TIMEOUT=15 +TIMEOUT=60 # Header info and introduction cat << EOM ::: Beginning Pi-hole debug at $(date)! From 27e5f2798d4a584c2655458ba646baedd8a38cfb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 18 Nov 2016 17:33:46 +0100 Subject: [PATCH 19/23] Added missing "done." output --- gravity.sh | 1 + 1 file changed, 1 insertion(+) mode change 100755 => 100644 gravity.sh diff --git a/gravity.sh b/gravity.sh old mode 100755 new mode 100644 index 15e157f6..4f9c2910 --- a/gravity.sh +++ b/gravity.sh @@ -264,6 +264,7 @@ gravity_hostFormat() { # Copy the file over as /etc/pihole/gravity.list so dnsmasq can use it cp ${piholeDir}/${accretionDisc} ${adList} + echo " done!" } # blackbody - remove any remnant files from script processes From 3fa05293fc466865a00140eaf65babae682b32f1 Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 18 Nov 2016 17:37:13 +0100 Subject: [PATCH 20/23] Fixed file permissions --- gravity.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 gravity.sh diff --git a/gravity.sh b/gravity.sh old mode 100644 new mode 100755 From 4945f33254755effa6a11c95787cb5804406dc0e Mon Sep 17 00:00:00 2001 From: DL6ER Date: Fri, 18 Nov 2016 17:39:34 +0100 Subject: [PATCH 21/23] Added "-n" to first echo call --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 4f9c2910..8ca2a3da 100755 --- a/gravity.sh +++ b/gravity.sh @@ -240,7 +240,7 @@ gravity_unique() { gravity_hostFormat() { # Format domain list as "192.168.x.x domain.com" - echo "::: Formatting domains into a HOSTS file..." + echo -n "::: Formatting domains into a HOSTS file..." # Check vars from setupVars.conf to see if we're using IPv4, IPv6, Or both. if [[ -n "${IPV4_ADDRESS}" && -n "${IPV6_ADDRESS}" ]];then From 68cb0782c05c1ba6701a8bc02f3332ab6260ee56 Mon Sep 17 00:00:00 2001 From: Dan Schaper Date: Fri, 18 Nov 2016 13:27:06 -0800 Subject: [PATCH 22/23] Add countdown timer --- advanced/Scripts/piholeDebug.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/advanced/Scripts/piholeDebug.sh b/advanced/Scripts/piholeDebug.sh index c91edf2a..d0e60177 100755 --- a/advanced/Scripts/piholeDebug.sh +++ b/advanced/Scripts/piholeDebug.sh @@ -316,6 +316,16 @@ debugLighttpd() { echo ":::" } +countdown() { + tuvix=${TIMEOUT} + printf "::: Logging will automatically teminate in ${TIMEOUT} seconds\n" + while [ $tuvix -ge 1 ] + do + printf ":::\t${tuvix} seconds left. \r" + sleep 5 + tuvix=$(( tuvix - 5 )) + done +} ### END FUNCTIONS ### # Gather version of required packages / repositories @@ -357,7 +367,7 @@ dumpPiHoleLog() { header_write "pihole.log" if [ -e "${PIHOLELOG}" ]; then # Dummy process to use for flagging down tail to terminate - sleep ${TIMEOUT} & + countdown & tail -n0 -f --pid=$! "${PIHOLELOG}" >> ${DEBUG_LOG} else log_write "No pihole.log file found!" From 08e7b7e0ad8ca94aafacf82158bbe75aeda02361 Mon Sep 17 00:00:00 2001 From: Mcat12 Date: Sat, 19 Nov 2016 14:00:56 -0500 Subject: [PATCH 23/23] Fix typo --- gravity.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gravity.sh b/gravity.sh index 8ca2a3da..4d440a4a 100755 --- a/gravity.sh +++ b/gravity.sh @@ -189,7 +189,7 @@ gravity_Blacklist() { if [[ -f "${blacklistFile}" ]]; then numBlacklisted=$(wc -l < "${blacklistFile}") plural=; [[ "$numBlacklisted" != "1" ]] && plural=s - echo -n "::: BlackListing $numBlacklisted domain${plural}..." + echo -n "::: Blacklisting $numBlacklisted domain${plural}..." cat ${blacklistFile} >> ${piholeDir}/${eventHorizon} echo " done!" else