From ad4644e2f75f304a48ba1003f50d36d3db0ab55b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 29 Jun 2022 13:48:32 +0200 Subject: [PATCH 01/20] Add yaml and markdown linters to stickler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .stickler.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.stickler.yml b/.stickler.yml index b96fc2e7..949e8e64 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -1,3 +1,6 @@ +--- linters: shellcheck: shell: bash + yamllint: + remarklint: From 796883a904added6b4ae4ae346aa22beff39e46c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 14 Jul 2022 22:02:21 +0200 Subject: [PATCH 02/20] Add yamllint.conf MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .stickler.yml | 1 + .yamllint.conf | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 .yamllint.conf diff --git a/.stickler.yml b/.stickler.yml index 949e8e64..3fbeb742 100644 --- a/.stickler.yml +++ b/.stickler.yml @@ -3,4 +3,5 @@ linters: shellcheck: shell: bash yamllint: + config: ./.yamllint.conf remarklint: diff --git a/.yamllint.conf b/.yamllint.conf new file mode 100644 index 00000000..d1b0953b --- /dev/null +++ b/.yamllint.conf @@ -0,0 +1,3 @@ +rules: + line-length: disable + document-start: disable From 8f7168432f757716e7bee51acaffbd4bacda5949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sun, 24 Jul 2022 22:19:11 +0200 Subject: [PATCH 03/20] Explicit set minor and patch version on used actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .github/workflows/codespell.yml | 2 +- .github/workflows/editorconfig-checker.yml | 4 ++-- .github/workflows/sync-back-to-dev.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index d7af7c4f..cdb33bc5 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3 + uses: actions/checkout@v3.0.0 - name: Spell-Checking uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/editorconfig-checker.yml b/.github/workflows/editorconfig-checker.yml index 37b20ba3..67bf86aa 100644 --- a/.github/workflows/editorconfig-checker.yml +++ b/.github/workflows/editorconfig-checker.yml @@ -9,6 +9,6 @@ jobs: name: editorconfig-checker runs-on: ubuntu-20.04 steps: - - uses: actions/checkout@v3 - - uses: editorconfig-checker/action-editorconfig-checker@main + - uses: actions/checkout@v3.0.0 + - uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 - run: editorconfig-checker diff --git a/.github/workflows/sync-back-to-dev.yml b/.github/workflows/sync-back-to-dev.yml index 5b9fa570..530debd3 100644 --- a/.github/workflows/sync-back-to-dev.yml +++ b/.github/workflows/sync-back-to-dev.yml @@ -11,7 +11,7 @@ jobs: name: Syncing branches steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v2.0.0 - name: Opening pull request id: pull uses: tretuna/sync-branches@1.4.0 @@ -20,7 +20,7 @@ jobs: FROM_BRANCH: 'master' TO_BRANCH: 'development' - name: Label the pull request to ignore for release note generation - uses: actions-ecosystem/action-add-labels@v1 + uses: actions-ecosystem/action-add-labels@v1.0.0 with: labels: internal repo: ${{ github.repository }} From 948d7194691eb144e4ded10d5ee4100772d80cc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Mon, 25 Jul 2022 21:33:39 +0200 Subject: [PATCH 04/20] Update all actions to latest versions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .github/workflows/codespell.yml | 2 +- .github/workflows/editorconfig-checker.yml | 6 +++--- .github/workflows/sync-back-to-dev.yml | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index cdb33bc5..a6dcf330 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -10,7 +10,7 @@ jobs: steps: - name: Checkout repository - uses: actions/checkout@v3.0.0 + uses: actions/checkout@v3.0.2 - name: Spell-Checking uses: codespell-project/actions-codespell@master diff --git a/.github/workflows/editorconfig-checker.yml b/.github/workflows/editorconfig-checker.yml index 67bf86aa..b21598ba 100644 --- a/.github/workflows/editorconfig-checker.yml +++ b/.github/workflows/editorconfig-checker.yml @@ -7,8 +7,8 @@ on: jobs: build: name: editorconfig-checker - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3.0.0 - - uses: editorconfig-checker/action-editorconfig-checker@v1.0.0 + - uses: actions/checkout@v3.0.2 + - uses: editorconfig-checker/action-editorconfig-checker@main # current tag v1.0.0 is really out-of-date - run: editorconfig-checker diff --git a/.github/workflows/sync-back-to-dev.yml b/.github/workflows/sync-back-to-dev.yml index 530debd3..27d966d2 100644 --- a/.github/workflows/sync-back-to-dev.yml +++ b/.github/workflows/sync-back-to-dev.yml @@ -11,7 +11,7 @@ jobs: name: Syncing branches steps: - name: Checkout - uses: actions/checkout@v2.0.0 + uses: actions/checkout@v3.0.2 - name: Opening pull request id: pull uses: tretuna/sync-branches@1.4.0 @@ -20,7 +20,7 @@ jobs: FROM_BRANCH: 'master' TO_BRANCH: 'development' - name: Label the pull request to ignore for release note generation - uses: actions-ecosystem/action-add-labels@v1.0.0 + uses: actions-ecosystem/action-add-labels@v1.1.0 with: labels: internal repo: ${{ github.repository }} From ff504f729a385f9e40bcda4f43429640d8ec9951 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 26 Jul 2022 09:23:14 +0200 Subject: [PATCH 05/20] Use correct target branch for dependabot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .github/dependabot.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 63e5a27f..42be6905 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,6 +7,6 @@ updates: day: saturday time: "10:00" open-pull-requests-limit: 10 - target-branch: devel + target-branch: development reviewers: - "pi-hole/padd-maintainers" From 45ec1ae051bec967fb5df2e626a4e75b6dba8719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Wed, 27 Jul 2022 09:54:33 +0200 Subject: [PATCH 06/20] Remove empty line after IPv6 on tiny and regular MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/padd.sh b/padd.sh index 5cb68c4e..6c83e2b2 100755 --- a/padd.sh +++ b/padd.sh @@ -670,7 +670,7 @@ PrintNetworkInformation() { elif [ "$1" = "tiny" ]; then CleanEcho "${bold_text}NETWORK ============================================${reset_text}" CleanPrintf " %-10s%-16s %-8s%-16s\e[0K\\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" - CleanPrintf " %-10s%-16s %-8s%-16s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" + CleanPrintf " %-10s%-16s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" CleanPrintf " %-10s%-16s %-4s%-5s %-4s%-5s\e[0K\\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" CleanPrintf " %-10s%-16s %-8s%-16s\e[0K\\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" @@ -681,7 +681,7 @@ PrintNetworkInformation() { elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then CleanEcho "${bold_text}NETWORK ===================================================${reset_text}" CleanPrintf " %-10s%-19s %-10s%-19s\e[0K\\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" - CleanPrintf " %-10s%-19s %-10s%-19s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" + CleanPrintf " %-10s%-19s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" CleanPrintf " %-10s%-19s %-4s%-5s %-4s%-5s\e[0K\\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" CleanPrintf " %-10s%-19s %-10s%-19s\e[0K\\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" From 7b3f9c46c9159ec371fde27c3e6cd7ba473ce16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 29 Jul 2022 18:32:49 +0200 Subject: [PATCH 07/20] Wait until telnet server said everything MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index 5cb68c4e..c57b11ca 100755 --- a/padd.sh +++ b/padd.sh @@ -110,7 +110,8 @@ GetFTLData() { ftl_port=$(cat /run/pihole-FTL.port 2> /dev/null) if [ -n "$ftl_port" ]; then # Send command to FTL and ask to quit when finished - echo ">$1 >quit" | nc 127.0.0.1 "${ftl_port}" + data="$(echo ">$1 >quit" | nc 127.0.0.1 "${ftl_port}")" + echo "${data}" else echo "0" fi From 21a75aea1eb6f379004fb11b93938594793521f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 29 Jul 2022 22:36:45 +0200 Subject: [PATCH 08/20] Allow to set local variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 102 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/padd.sh b/padd.sh index 5cb68c4e..6c451802 100755 --- a/padd.sh +++ b/padd.sh @@ -1,6 +1,10 @@ #!/usr/bin/env sh # shellcheck disable=SC1091 +# Ignore warning about `local` being undefinded in POSIX +# shellcheck disable=SC3043 +# https://github.com/koalaman/shellcheck/wiki/SC3043#exceptions + # PADD # A more advanced version of the chronometer provided with Pihole @@ -936,65 +940,67 @@ SizeChecker(){ } CheckConnectivity() { - connectivity="false" - connection_attempts=1 - wait_timer=1 + local connectivity connection_attempts wait_timer - while [ $connection_attempts -lt 9 ]; do + connectivity="false" + connection_attempts=1 + wait_timer=1 - if nc -zw1 google.com 443 2>/dev/null; then - if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then - echo "Attempt #${connection_attempts} passed..." - elif [ "$1" = "mini" ]; then - echo "Attempt ${connection_attempts} passed." - else - echo " - Attempt ${connection_attempts} passed... " - fi + while [ $connection_attempts -lt 9 ]; do - connectivity="true" - connection_attempts=11 - else - connection_attempts=$((connection_attempts+1)) + if nc -zw1 google.com 443 2>/dev/null; then + if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then + echo "Attempt #${connection_attempts} passed..." + elif [ "$1" = "mini" ]; then + echo "Attempt ${connection_attempts} passed." + else + echo " - Attempt ${connection_attempts} passed... " + fi + + connectivity="true" + connection_attempts=11 + else + connection_attempts=$((connection_attempts+1)) + local inner_wait_timer + inner_wait_timer=$((wait_timer*1)) + + # echo "$wait_timer = $inner_wait_timer" + while [ $inner_wait_timer -gt 0 ]; do + if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then + printf "%b" "Attempt #${connection_attempts} failed...\\r" + elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then + printf "%b" "- Attempt ${connection_attempts} failed, wait ${inner_wait_timer} \\r" + else + printf "%b" " - Attempt ${connection_attempts} failed... waiting ${inner_wait_timer} seconds... \\r" + fi + sleep 1 + inner_wait_timer=$((inner_wait_timer-1)) + done + + # echo -ne "Attempt $connection_attempts failed... waiting $wait_timer seconds...\\r" + # sleep $wait_timer + wait_timer=$((wait_timer*2)) + fi - inner_wait_timer=$((wait_timer*1)) + done - # echo "$wait_timer = $inner_wait_timer" - while [ $inner_wait_timer -gt 0 ]; do + if [ "$connectivity" = "false" ]; then if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then - printf "%b" "Attempt #${connection_attempts} failed...\\r" + echo "Check failed..." elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then - printf "%b" "- Attempt ${connection_attempts} failed, wait ${inner_wait_timer} \\r" + echo "- Connectivity check failed." else - printf "%b" " - Attempt ${connection_attempts} failed... waiting ${inner_wait_timer} seconds... \\r" + echo " - Connectivity check failed..." fi - sleep 1 - inner_wait_timer=$((inner_wait_timer-1)) - done - - # echo -ne "Attempt $connection_attempts failed... waiting $wait_timer seconds...\\r" - # sleep $wait_timer - wait_timer=$((wait_timer*2)) - fi - - done - - if [ "$connectivity" = "false" ]; then - if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then - echo "Check failed..." - elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then - echo "- Connectivity check failed." - else - echo " - Connectivity check failed..." - fi - else - if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then - echo "Check passed..." - elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then - echo "- Connectivity check passed." else - echo " - Connectivity check passed..." + if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then + echo "Check passed..." + elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then + echo "- Connectivity check passed." + else + echo " - Connectivity check passed..." + fi fi - fi } # converts a given version string e.g. v3.7.1 to 3007001000 to allow for easier comparison of multi digit version numbers From 4dcfbeb765e06f062091d3841857232c8ddccdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 29 Jul 2022 22:41:36 +0200 Subject: [PATCH 09/20] Set variables to local MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/padd.sh b/padd.sh index c57b11ca..b168d9d7 100755 --- a/padd.sh +++ b/padd.sh @@ -107,6 +107,7 @@ padd_logo_retro_3="${bold_text}${green_text}| ${red_text}/${yellow_text}-${gre ############################################# GETTERS ############################################## GetFTLData() { + local ftl_port data ftl_port=$(cat /run/pihole-FTL.port 2> /dev/null) if [ -n "$ftl_port" ]; then # Send command to FTL and ask to quit when finished From 9488db9a2a01a2bb962d2bce060e6ff0a8f950c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 19 Aug 2022 20:12:54 +0200 Subject: [PATCH 10/20] Bump version to v3.8.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index b2ea2bb1..194650d7 100755 --- a/padd.sh +++ b/padd.sh @@ -18,7 +18,7 @@ LC_NUMERIC=C ############################################ VARIABLES ############################################# # VERSION -padd_version="v3.8.0" +padd_version="v3.8.1" # LastChecks LastCheckVersionInformation=$(date +%s) From 15670cb66ca268eab5312c3977752dae24175431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 19 Aug 2022 20:17:32 +0200 Subject: [PATCH 11/20] Silence, please! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- .codespellignore | 1 + .github/workflows/codespell.yml | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 .codespellignore diff --git a/.codespellignore b/.codespellignore new file mode 100644 index 00000000..5f24e728 --- /dev/null +++ b/.codespellignore @@ -0,0 +1 @@ +padd diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml index a6dcf330..7c55f6a7 100644 --- a/.github/workflows/codespell.yml +++ b/.github/workflows/codespell.yml @@ -14,3 +14,5 @@ jobs: - name: Spell-Checking uses: codespell-project/actions-codespell@master + with: + ignore_words_file: .codespellignore From 9f333c8ff680a99e0fe3a677fd744717fbe61065 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Tue, 27 Sep 2022 21:21:03 +0200 Subject: [PATCH 12/20] Get API port from pihole-FTL.conf instead of port file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index 194650d7..64dc8e7c 100755 --- a/padd.sh +++ b/padd.sh @@ -112,7 +112,7 @@ padd_logo_retro_3="${bold_text}${green_text}| ${red_text}/${yellow_text}-${gre GetFTLData() { local ftl_port data - ftl_port=$(cat /run/pihole-FTL.port 2> /dev/null) + ftl_port=$(getFTLAPIPort) if [ -n "$ftl_port" ]; then # Send command to FTL and ask to quit when finished data="$(echo ">$1 >quit" | nc 127.0.0.1 "${ftl_port}")" @@ -1011,6 +1011,28 @@ VersionConverter() { echo "$@" | tr -d '[:alpha:]' | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } +# get the Telnet API Port FTL is using by parsing `pihole-FTL.conf` +# same implementation as https://github.com/pi-hole/pi-hole/pull/4945 +getFTLAPIPort(){ + local FTLCONFFILE="/etc/pihole/pihole-FTL.conf" + local DEFAULT_FTL_PORT=4711 + local ftl_api_port + + if [ -s "$FTLCONFFILE" ]; then + # if FTLPORT is not set in pihole-FTL.conf, use the default port + ftl_api_port="$({ grep '^FTLPORT=' "${FTLCONFFILE}" || echo "${DEFAULT_FTL_PORT}"; } | cut -d'=' -f2-)" + # Exploit prevention: set the port to the default port if there is malicious (non-numeric) + # content set in pihole-FTL.conf + expr "${ftl_api_port}" : "[^[:digit:]]" > /dev/null && ftl_api_port="${DEFAULT_FTL_PORT}" + else + # if there is no pihole-FTL.conf, use the default port + ftl_api_port="${DEFAULT_FTL_PORT}" + fi + + echo "${ftl_api_port}" + +} + ########################################## MAIN FUNCTIONS ########################################## OutputJSON() { From 2b406c18982368b15d92065cd4d523238a33f550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Thu, 18 Aug 2022 22:51:26 +0200 Subject: [PATCH 13/20] Remove CleanPrintf and CleanEcho MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 292 ++++++++++++++++++++++++++------------------------------ 1 file changed, 135 insertions(+), 157 deletions(-) diff --git a/padd.sh b/padd.sh index 64dc8e7c..a26a3d80 100755 --- a/padd.sh +++ b/padd.sh @@ -39,6 +39,7 @@ blue_text="${CSI}94m" # Blue magenta_text="${CSI}95m" # Magenta cyan_text="${CSI}96m" # Cyan reset_text="${CSI}0m" # Reset to default +clear_line="${CSI}0K" # Clear the current line to the right to wipe any artifacts remaining from last print # STYLES bold_text="${CSI}1m" @@ -597,116 +598,93 @@ GetVersionInformation() { ############################################# PRINTERS ############################################# -# terminfo clr_eol (clears to end of line to erase artifacts after resizing smaller) -ceol=$(tput el) - -# wrapper - echo with a clear eol afterwards to wipe any artifacts remaining from last print -CleanEcho() { - echo "${ceol}$1" -} - -# wrapper - printf -CleanPrintf() { -# tput el -# disabling shellcheck here because we pass formatting instructions within `"${@}"` -# shellcheck disable=SC2059 - printf "$@" -} - PrintLogo() { # Screen size checks if [ "$1" = "pico" ]; then - CleanEcho "p${padd_text} ${pico_status}" + printf "%s${clear_line}\n" "p${padd_text} ${pico_status}" elif [ "$1" = "nano" ]; then - CleanEcho "n${padd_text} ${mini_status}" + printf "%s${clear_line}\n" "n${padd_text} ${mini_status}" elif [ "$1" = "micro" ]; then - CleanEcho "µ${padd_text} ${mini_status}" - CleanEcho "" + printf "%s${clear_line}\n\n" "µ${padd_text} ${mini_status}" elif [ "$1" = "mini" ]; then - CleanEcho "${padd_text}${dim_text}mini${reset_text} ${mini_status}" - CleanEcho "" + printf "%s${clear_line}\n\n" "${padd_text}${dim_text}mini${reset_text} ${mini_status}" elif [ "$1" = "tiny" ]; then - CleanEcho "${padd_text}${dim_text}tiny${reset_text} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" - CleanPrintf " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${tiny_status}${reset_text}\e[0K\\n" + printf "%s${clear_line}\n" "${padd_text}${dim_text}tiny${reset_text} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" + printf "%s${clear_line}\n" " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${tiny_status}${reset_text}" elif [ "$1" = "slim" ]; then - CleanEcho "${padd_text}${dim_text}slim${reset_text} ${full_status}" - CleanEcho "" - # For the next two, use printf to make sure spaces aren't collapsed + printf "%s${clear_line}\n\n" "${padd_text}${dim_text}slim${reset_text} ${full_status}" elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - CleanPrintf "${padd_logo_1}\e[0K\\n" - CleanPrintf "${padd_logo_2}Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}\e[0K\\n" - CleanPrintf "${padd_logo_3}PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}\e[0K\\n" - CleanEcho "" + printf "%s${clear_line}\n" "${padd_logo_1}" + printf "%s${clear_line}\n" "${padd_logo_2}Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" + printf "%s${clear_line}\n\n" "${padd_logo_3}PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" # normal or not defined else - CleanPrintf "${padd_logo_retro_1}\e[0K\\n" - CleanPrintf "${padd_logo_retro_2} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}, PADD ${padd_version_heatmap}${padd_version}${reset_text}\e[0K\\n" - CleanPrintf "${padd_logo_retro_3} ${pihole_check_box} Core ${ftl_check_box} FTL ${mega_status}${reset_text}\e[0K\\n" - - CleanEcho "" + printf "%s${clear_line}\n" "${padd_logo_retro_1}" + printf "%s${clear_line}\n" "${padd_logo_retro_2} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}, PADD ${padd_version_heatmap}${padd_version}${reset_text}" + printf "%s${clear_line}\n\n" "${padd_logo_retro_3} ${pihole_check_box} Core ${ftl_check_box} FTL ${mega_status}${reset_text}" fi } PrintNetworkInformation() { if [ "$1" = "pico" ]; then - CleanEcho "${bold_text}NETWORK ============${reset_text}" - CleanEcho " Hst: ${pi_hostname}" - CleanEcho " IP: ${pi_ip4_addr}" - CleanEcho " DHCP ${dhcp_check_box} IPv6 ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ============${reset_text}" + printf "%s${clear_line}\n" " Hst: ${pi_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP ${dhcp_check_box} IPv6 ${dhcp_ipv6_check_box}" elif [ "$1" = "nano" ]; then - CleanEcho "${bold_text}NETWORK ================${reset_text}" - CleanEcho " Host: ${pi_hostname}" - CleanEcho " IP: ${pi_ip4_addr}" - CleanEcho " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ================${reset_text}" + printf "%s${clear_line}\n" " Host: ${pi_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" elif [ "$1" = "micro" ]; then - CleanEcho "${bold_text}NETWORK ======================${reset_text}" - CleanEcho " Host: ${full_hostname}" - CleanEcho " IP: ${pi_ip4_addr}" - CleanEcho " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ======================${reset_text}" + printf "%s${clear_line}\n" " Host: ${full_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" elif [ "$1" = "mini" ]; then - CleanEcho "${bold_text}NETWORK ================================${reset_text}" - CleanPrintf " %-9s%-19s\e[0K\\n" "Host:" "${full_hostname}" - CleanPrintf " %-9s%-19s\e[0K\\n" "IP:" "${pi_ip4_addr}" - CleanPrintf " %-9s%-8s %-4s%-5s %-4s%-5s\e[0K\\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - CleanPrintf " %-9s%-10s\e[0K\\n" "DNS:" "${dns_information}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ================================${reset_text}" + printf " %-9s%-19s${clear_line}\n" "Host:" "${full_hostname}" + printf " %-9s%-19s${clear_line}\n" "IP:" "${pi_ip4_addr}" + printf " %-9s%-8s %-4s%-5s %-4s%-5s${clear_line}\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-9s%-10s${clear_line}\n" "DNS:" "${dns_information}" if [ "${DHCP_ACTIVE}" = "true" ]; then - CleanPrintf " %-9s${dhcp_heatmap}%-10s${reset_text} %-9s${dhcp_ipv6_heatmap}%-10s${reset_text}\e[0K\\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf " %-9s${dhcp_heatmap}%-10s${reset_text} %-9s${dhcp_ipv6_heatmap}%-10s${reset_text}" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} fi elif [ "$1" = "tiny" ]; then - CleanEcho "${bold_text}NETWORK ============================================${reset_text}" - CleanPrintf " %-10s%-16s %-8s%-16s\e[0K\\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" - CleanPrintf " %-10s%-16s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" - CleanPrintf " %-10s%-16s %-4s%-5s %-4s%-5s\e[0K\\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - CleanPrintf " %-10s%-16s %-8s%-16s\e[0K\\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ============================================${reset_text}" + printf " %-10s%-16s %-8s%-16s${clear_line}\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" + printf " %-10s%-16s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" + printf " %-10s%-16s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-16s %-8s%-16s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" if [ "${DHCP_ACTIVE}" = "true" ]; then - CleanPrintf " %-10s${dhcp_heatmap}%-16s${reset_text} %-8s${dhcp_ipv6_heatmap}%-10s${reset_text}\e[0K\\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} - CleanPrintf "%s\e[0K\\n" "${dhcp_info}" + printf " %-10s${dhcp_heatmap}%-16s${reset_text} %-8s${dhcp_ipv6_heatmap}%-10s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf "%s${clear_line}\n" "${dhcp_info}" fi elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - CleanEcho "${bold_text}NETWORK ===================================================${reset_text}" - CleanPrintf " %-10s%-19s %-10s%-19s\e[0K\\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" - CleanPrintf " %-10s%-19s\e[0K\\n" "IPv6:" "${pi_ip6_addr}" - CleanPrintf " %-10s%-19s %-4s%-5s %-4s%-5s\e[0K\\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - CleanPrintf " %-10s%-19s %-10s%-19s\e[0K\\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ===================================================${reset_text}" + printf " %-10s%-19s %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" + printf " %-10s%-19s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" + printf " %-10s%-19s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-19s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" if [ "${DHCP_ACTIVE}" = "true" ]; then - CleanPrintf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}\e[0K\\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} - CleanPrintf "%s\e[0K\\n" "${dhcp_info}" + printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf "%s${clear_line}\n" "${dhcp_info}" fi else - CleanEcho "${bold_text}NETWORK =======================================================================${reset_text}" - CleanPrintf " %-10s%-19s\e[0K\\n" "Hostname:" "${full_hostname}" - CleanPrintf " %-11s%-14s %-4s%-9s %-4s%-9s\e[0K\\n" "Interface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - CleanPrintf " %-6s%-19s %-10s%-29s\e[0K\\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" - CleanEcho "DNS ===========================================================================" - CleanPrintf " %-10s%-39s\e[0K\\n" "Servers:" "${dns_information}" - CleanPrintf " %-10s${dnssec_heatmap}%-19s${reset_text} %-20s${conditional_forwarding_heatmap}%-9s${reset_text}\e[0K\\n" "DNSSEC:" "${dnssec_status}" "Conditional Fwding:" "${conditional_forwarding_status}" - - CleanEcho "DHCP ==========================================================================" - CleanPrintf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-9s${reset_text}\e[0K\\n" "DHCP:" "${dhcp_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" - CleanPrintf "%s\e[0K\\n" "${dhcp_info}" + printf "%s${clear_line}\n" "${bold_text}NETWORK =======================================================================${reset_text}" + printf " %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" + printf " %-11s%-14s %-4s%-9s %-4s%-9s${clear_line}\n" "Interface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-6s%-19s %-10s%-29s${clear_line}\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" + printf "%s${clear_line}\n" "DNS ===========================================================================" + printf " %-10s%-39s${clear_line}\n" "Servers:" "${dns_information}" + printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-20s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "Conditional Fwding:" "${conditional_forwarding_status}" + + printf "%s${clear_line}\n" "DHCP ==========================================================================" + printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-9s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" + printf "%s${clear_line}\n" "${dhcp_info}" fi } @@ -715,20 +693,20 @@ PrintPiholeInformation() { if [ "$1" = "pico" ]; then : elif [ "$1" = "nano" ]; then - CleanEcho "${bold_text}PI-HOLE ================${reset_text}" - CleanEcho " Up: ${pihole_check_box} FTL: ${ftl_check_box}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================${reset_text}" + printf "%s${clear_line}\n" " Up: ${pihole_check_box} FTL: ${ftl_check_box}" elif [ "$1" = "micro" ]; then - CleanEcho "${bold_text}PI-HOLE ======================${reset_text}" - CleanEcho " Status: ${pihole_check_box} FTL: ${ftl_check_box}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ======================${reset_text}" + printf "%s${clear_line}\n" " Status: ${pihole_check_box} FTL: ${ftl_check_box}" elif [ "$1" = "mini" ]; then - CleanEcho "${bold_text}PI-HOLE ================================${reset_text}" - CleanPrintf " %-9s${pihole_heatmap}%-10s${reset_text} %-9s${ftl_heatmap}%-10s${reset_text}\e[0K\\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================================${reset_text}" + printf " %-9s${pihole_heatmap}%-10s${reset_text} %-9s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" elif [ "$1" = "tiny" ]; then - CleanEcho "${bold_text}PI-HOLE ============================================${reset_text}" - CleanPrintf " %-10s${pihole_heatmap}%-16s${reset_text} %-8s${ftl_heatmap}%-10s${reset_text}\e[0K\\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============================================${reset_text}" + printf " %-10s${pihole_heatmap}%-16s${reset_text} %-8s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - CleanEcho "${bold_text}PI-HOLE ===================================================${reset_text}" - CleanPrintf " %-10s${pihole_heatmap}%-19s${reset_text} %-10s${ftl_heatmap}%-19s${reset_text}\e[0K\\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ===================================================${reset_text}" + printf " %-10s${pihole_heatmap}%-19s${reset_text} %-10s${ftl_heatmap}%-19s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" else return fi @@ -737,110 +715,110 @@ PrintPiholeInformation() { PrintPiholeStats() { # are we on a reduced screen size? if [ "$1" = "pico" ]; then - CleanEcho "${bold_text}PI-HOLE ============${reset_text}" - CleanEcho " [${ads_blocked_bar}] ${ads_percentage_today}%" - CleanEcho " ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============${reset_text}" + printf "%s${clear_line}\n" " [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " ${ads_blocked_today} / ${dns_queries_today}" elif [ "$1" = "nano" ]; then - CleanEcho " Blk: [${ads_blocked_bar}] ${ads_percentage_today}%" - CleanEcho " Blk: ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" " Blk: [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " Blk: ${ads_blocked_today} / ${dns_queries_today}" elif [ "$1" = "micro" ]; then - CleanEcho "${bold_text}STATS ========================${reset_text}" - CleanEcho " Blckng: ${domains_being_blocked} domains" - CleanEcho " Piholed: [${ads_blocked_bar}] ${ads_percentage_today}%" - CleanEcho " Piholed: ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" "${bold_text}STATS ========================${reset_text}" + printf "%s${clear_line}\n" " Blckng: ${domains_being_blocked} domains" + printf "%s${clear_line}\n" " Piholed: [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " Piholed: ${ads_blocked_today} / ${dns_queries_today}" elif [ "$1" = "mini" ]; then - CleanEcho "${bold_text}STATS ==================================${reset_text}" - CleanPrintf " %-9s%-29s\e[0K\\n" "Blckng:" "${domains_being_blocked} domains" - CleanPrintf " %-9s[%-20s] %-5s\e[0K\\n" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - CleanPrintf " %-9s%-29s\e[0K\\n" "Piholed:" "${ads_blocked_today} out of ${dns_queries_today}" - CleanPrintf " %-9s%-29s\e[0K\\n" "Latest:" "${latest_blocked}" + printf "%s${clear_line}\n" "${bold_text}STATS ==================================${reset_text}" + printf " %-9s%-29s${clear_line}\n" "Blckng:" "${domains_being_blocked} domains" + printf " %-9s[%-20s] %-5s${clear_line}\n" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-9s%-29s${clear_line}\n" "Piholed:" "${ads_blocked_today} out of ${dns_queries_today}" + printf " %-9s%-29s${clear_line}\n" "Latest:" "${latest_blocked}" if [ "${DHCP_ACTIVE}" != "true" ]; then - CleanPrintf " %-9s%-29s\\n" "Top Ad:" "${top_blocked}" + printf " %-9s%-29s\\n" "Top Ad:" "${top_blocked}" fi elif [ "$1" = "tiny" ]; then - CleanEcho "${bold_text}STATS ==============================================${reset_text}" - CleanPrintf " %-10s%-29s\e[0K\\n" "Blocking:" "${domains_being_blocked} domains" - CleanPrintf " %-10s[%-30s] %-5s\e[0K\\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - CleanPrintf " %-10s%-39s\e[0K\\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Latest:" "${latest_blocked}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Ad:" "${top_blocked}" + printf "%s${clear_line}\n" "${bold_text}STATS ==============================================${reset_text}" + printf " %-10s%-29s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" + printf " %-10s[%-30s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-39s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today}" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" if [ "${DHCP_ACTIVE}" != "true" ]; then - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Dmn:" "${top_domain}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Clnt:" "${top_client}" + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" fi elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - CleanEcho "${bold_text}STATS =====================================================${reset_text}" - CleanPrintf " %-10s%-49s\e[0K\\n" "Blocking:" "${domains_being_blocked} domains" - CleanPrintf " %-10s[%-40s] %-5s\e[0K\\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - CleanPrintf " %-10s%-49s\e[0K\\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today} queries" - CleanPrintf " %-10s%-39s\e[0K\\n" "Latest:" "${latest_blocked}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Ad:" "${top_blocked}" + printf "%s${clear_line}\n" "${bold_text}STATS =====================================================${reset_text}" + printf " %-10s%-49s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" + printf " %-10s[%-40s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-49s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today} queries" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" if [ "${DHCP_ACTIVE}" != "true" ]; then - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Dmn:" "${top_domain}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Clnt:" "${top_client}" + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" fi else - CleanEcho "${bold_text}STATS =========================================================================${reset_text}" - CleanPrintf " %-10s%-19s %-10s[%-40s] %-5s\e[0K\\n" "Blocking:" "${domains_being_blocked} domains" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - CleanPrintf " %-10s%-30s%-29s\e[0K\\n" "Clients:" "${clients}" " ${ads_blocked_today} out of ${dns_queries_today} queries" - CleanPrintf " %-10s%-39s\e[0K\\n" "Latest:" "${latest_blocked}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Ad:" "${top_blocked}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Dmn:" "${top_domain}" - CleanPrintf " %-10s%-39s\e[0K\\n" "Top Clnt:" "${top_client}" - CleanEcho "FTL ===========================================================================" - CleanPrintf " %-10s%-9s %-10s%-9s %-10s%-9s\e[0K\\n" "PID:" "${ftlPID}" "CPU Use:" "${ftl_cpu}%" "Mem. Use:" "${ftl_mem_percentage}%" - CleanPrintf " %-10s%-69s\e[0K\\n" "DNSCache:" "${cache_inserts} insertions, ${cache_deletes} deletions, ${cache_size} total entries" + printf "%s${clear_line}\n" "${bold_text}STATS =========================================================================${reset_text}" + printf " %-10s%-19s %-10s[%-40s] %-5s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-30s%-29s${clear_line}\n" "Clients:" "${clients}" " ${ads_blocked_today} out of ${dns_queries_today} queries" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" + printf "%s${clear_line}\n" "FTL ===========================================================================" + printf " %-10s%-9s %-10s%-9s %-10s%-9s${clear_line}\n" "PID:" "${ftlPID}" "CPU Use:" "${ftl_cpu}%" "Mem. Use:" "${ftl_mem_percentage}%" + printf " %-10s%-69s${clear_line}\n" "DNSCache:" "${cache_inserts} insertions, ${cache_deletes} deletions, ${cache_size} total entries" fi } PrintSystemInformation() { if [ "$1" = "pico" ]; then - CleanEcho "${bold_text}CPU ================${reset_text}" - printf "%b" "${ceol} [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}\n" "${bold_text}CPU ================${reset_text}" + printf "%s${clear_line}" " [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" elif [ "$1" = "nano" ]; then - CleanEcho "${ceol}${bold_text}SYSTEM =================${reset_text}" - CleanEcho " Up: ${system_uptime}" - printf "%b" "${ceol} CPU: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =================${reset_text}" + printf "%s${clear_line}\n" " Up: ${system_uptime}" + printf "%s${clear_line}" " CPU: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" elif [ "$1" = "micro" ]; then - CleanEcho "${bold_text}SYSTEM =======================${reset_text}" - CleanEcho " Uptime: ${system_uptime}" - CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - printf "%b" "${ceol} Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =======================${reset_text}" + printf "%s${clear_line}\n" " Uptime: ${system_uptime}" + printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" elif [ "$1" = "mini" ]; then - CleanEcho "${bold_text}SYSTEM =================================${reset_text}" - CleanPrintf " %-9s%-29s\\n" "Uptime:" "${system_uptime}" - CleanEcho " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - printf "%b" "${ceol} Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =================================${reset_text}" + printf " %-9s%-29s\\n" "Uptime:" "${system_uptime}" + printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" elif [ "$1" = "tiny" ]; then - CleanEcho "${bold_text}SYSTEM =============================================${reset_text}" - CleanPrintf " %-10s%-29s\e[0K\\n" "Uptime:" "${system_uptime}" - CleanPrintf " %-10s${temp_heatmap}%-17s${reset_text} %-8s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}\e[0K\\n" "CPU Temp:" "${temperature}" "Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =============================================${reset_text}" + printf " %-10s%-29s${clear_line}\n" "Uptime:" "${system_uptime}" + printf " %-10s${temp_heatmap}%-17s${reset_text} %-8s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" # Memory and CPU bar - CleanPrintf " %-10s[${memory_heatmap}%-7s${reset_text}] %-6s %-8s[${cpu_load_1_heatmap}%-7s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU:" "${cpu_bar}" "${cpu_percent}%" + printf " %-10s[${memory_heatmap}%-7s${reset_text}] %-6s %-8s[${cpu_load_1_heatmap}%-7s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU:" "${cpu_bar}" "${cpu_percent}%" # else we're not elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - CleanEcho "${bold_text}SYSTEM ====================================================${reset_text}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM ====================================================${reset_text}" # Device - CleanPrintf " %-10s%-39s\e[0K\\n" "Device:" "${sys_model}" + printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" # Uptime - CleanPrintf " %-10s%-39s\e[0K\\n" "Uptime:" "${system_uptime}" + printf " %-10s%-39s${clear_line}\n" "Uptime:" "${system_uptime}" # Temp and Loads - CleanPrintf " %-10s${temp_heatmap}%-20s${reset_text}" "CPU Temp:" "${temperature}" - CleanPrintf " %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}\e[0K\\n" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + printf " %-10s${temp_heatmap}%-20s${reset_text}" "CPU Temp:" "${temperature}" + printf " %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" # Memory and CPU bar - CleanPrintf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" + printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" else - CleanEcho "${bold_text}SYSTEM ========================================================================${reset_text}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM ========================================================================${reset_text}" # Device - CleanPrintf " %-10s%-39s\e[0K\\n" "Device:" "${sys_model}" + printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" # Uptime and memory - CleanPrintf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s\\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" + printf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s\\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" # CPU temp, load, percentage - CleanPrintf " %-10s${temp_heatmap}%-10s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" + printf " %-10s${temp_heatmap}%-10s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" fi } From 6eb6d39f610600f87aaaaec1dd30652e481bb222 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 19 Aug 2022 20:57:19 +0200 Subject: [PATCH 14/20] Clear screen before draw the dashboard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/padd.sh b/padd.sh index a26a3d80..e93a24fb 100755 --- a/padd.sh +++ b/padd.sh @@ -605,23 +605,23 @@ PrintLogo() { elif [ "$1" = "nano" ]; then printf "%s${clear_line}\n" "n${padd_text} ${mini_status}" elif [ "$1" = "micro" ]; then - printf "%s${clear_line}\n\n" "µ${padd_text} ${mini_status}" + printf "%s${clear_line}\n${clear_line}\n" "µ${padd_text} ${mini_status}" elif [ "$1" = "mini" ]; then - printf "%s${clear_line}\n\n" "${padd_text}${dim_text}mini${reset_text} ${mini_status}" + printf "%s${clear_line}\n${clear_line}\n" "${padd_text}${dim_text}mini${reset_text} ${mini_status}" elif [ "$1" = "tiny" ]; then printf "%s${clear_line}\n" "${padd_text}${dim_text}tiny${reset_text} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" printf "%s${clear_line}\n" " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${tiny_status}${reset_text}" elif [ "$1" = "slim" ]; then - printf "%s${clear_line}\n\n" "${padd_text}${dim_text}slim${reset_text} ${full_status}" + printf "%s${clear_line}\n${clear_line}\n" "${padd_text}${dim_text}slim${reset_text} ${full_status}" elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then printf "%s${clear_line}\n" "${padd_logo_1}" printf "%s${clear_line}\n" "${padd_logo_2}Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" - printf "%s${clear_line}\n\n" "${padd_logo_3}PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" + printf "%s${clear_line}\n${clear_line}\n" "${padd_logo_3}PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" # normal or not defined else printf "%s${clear_line}\n" "${padd_logo_retro_1}" printf "%s${clear_line}\n" "${padd_logo_retro_2} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}, PADD ${padd_version_heatmap}${padd_version}${reset_text}" - printf "%s${clear_line}\n\n" "${padd_logo_retro_3} ${pihole_check_box} Core ${ftl_check_box} FTL ${mega_status}${reset_text}" + printf "%s${clear_line}\n${clear_line}\n" "${padd_logo_retro_3} ${pihole_check_box} Core ${ftl_check_box} FTL ${mega_status}${reset_text}" fi } @@ -1119,6 +1119,9 @@ NormalPADD() { # Sizing Checks SizeChecker + # Clear to end of screen (below the drawn dashboard) + tput ed + # Move the cursor to top left of console to redraw tput cup 0 0 From c274b393c23c9dec59f99ae63e6b8a1f67e98a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 19 Aug 2022 23:40:44 +0200 Subject: [PATCH 15/20] Switch from functional oriented to a size oriented code style for the print functions. This should make it easier to spot misalignments and outputs that are bigger than the minimal screen sizes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 400 ++++++++++++++++++++++++++------------------------------ 1 file changed, 186 insertions(+), 214 deletions(-) diff --git a/padd.sh b/padd.sh index e93a24fb..1d4c8f4a 100755 --- a/padd.sh +++ b/padd.sh @@ -625,201 +625,176 @@ PrintLogo() { fi } -PrintNetworkInformation() { - if [ "$1" = "pico" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ============${reset_text}" - printf "%s${clear_line}\n" " Hst: ${pi_hostname}" - printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" - printf "%s${clear_line}\n" " DHCP ${dhcp_check_box} IPv6 ${dhcp_ipv6_check_box}" - elif [ "$1" = "nano" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ================${reset_text}" - printf "%s${clear_line}\n" " Host: ${pi_hostname}" - printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" - printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" - elif [ "$1" = "micro" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ======================${reset_text}" - printf "%s${clear_line}\n" " Host: ${full_hostname}" - printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" - printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" - elif [ "$1" = "mini" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ================================${reset_text}" - printf " %-9s%-19s${clear_line}\n" "Host:" "${full_hostname}" - printf " %-9s%-19s${clear_line}\n" "IP:" "${pi_ip4_addr}" - printf " %-9s%-8s %-4s%-5s %-4s%-5s${clear_line}\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-9s%-10s${clear_line}\n" "DNS:" "${dns_information}" - - if [ "${DHCP_ACTIVE}" = "true" ]; then - printf " %-9s${dhcp_heatmap}%-10s${reset_text} %-9s${dhcp_ipv6_heatmap}%-10s${reset_text}" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} - fi - elif [ "$1" = "tiny" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ============================================${reset_text}" - printf " %-10s%-16s %-8s%-16s${clear_line}\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" - printf " %-10s%-16s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" - printf " %-10s%-16s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-10s%-16s %-8s%-16s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" - - if [ "${DHCP_ACTIVE}" = "true" ]; then - printf " %-10s${dhcp_heatmap}%-16s${reset_text} %-8s${dhcp_ipv6_heatmap}%-10s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} - printf "%s${clear_line}\n" "${dhcp_info}" - fi - elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - printf "%s${clear_line}\n" "${bold_text}NETWORK ===================================================${reset_text}" - printf " %-10s%-19s %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" - printf " %-10s%-19s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" - printf " %-10s%-19s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-10s%-19s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" - - if [ "${DHCP_ACTIVE}" = "true" ]; then - printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} - printf "%s${clear_line}\n" "${dhcp_info}" - fi - else - printf "%s${clear_line}\n" "${bold_text}NETWORK =======================================================================${reset_text}" - printf " %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" - printf " %-11s%-14s %-4s%-9s %-4s%-9s${clear_line}\n" "Interface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-6s%-19s %-10s%-29s${clear_line}\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" - printf "%s${clear_line}\n" "DNS ===========================================================================" - printf " %-10s%-39s${clear_line}\n" "Servers:" "${dns_information}" - printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-20s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "Conditional Fwding:" "${conditional_forwarding_status}" - - printf "%s${clear_line}\n" "DHCP ==========================================================================" - printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-9s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" - printf "%s${clear_line}\n" "${dhcp_info}" - fi -} - -PrintPiholeInformation() { - # size checks - if [ "$1" = "pico" ]; then - : - elif [ "$1" = "nano" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================${reset_text}" - printf "%s${clear_line}\n" " Up: ${pihole_check_box} FTL: ${ftl_check_box}" - elif [ "$1" = "micro" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ======================${reset_text}" - printf "%s${clear_line}\n" " Status: ${pihole_check_box} FTL: ${ftl_check_box}" - elif [ "$1" = "mini" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================================${reset_text}" - printf " %-9s${pihole_heatmap}%-10s${reset_text} %-9s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" - elif [ "$1" = "tiny" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============================================${reset_text}" - printf " %-10s${pihole_heatmap}%-16s${reset_text} %-8s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" - elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ===================================================${reset_text}" - printf " %-10s${pihole_heatmap}%-19s${reset_text} %-10s${ftl_heatmap}%-19s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" - else - return - fi -} - -PrintPiholeStats() { - # are we on a reduced screen size? - if [ "$1" = "pico" ]; then - printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============${reset_text}" - printf "%s${clear_line}\n" " [${ads_blocked_bar}] ${ads_percentage_today}%" - printf "%s${clear_line}\n" " ${ads_blocked_today} / ${dns_queries_today}" - elif [ "$1" = "nano" ]; then - printf "%s${clear_line}\n" " Blk: [${ads_blocked_bar}] ${ads_percentage_today}%" - printf "%s${clear_line}\n" " Blk: ${ads_blocked_today} / ${dns_queries_today}" - elif [ "$1" = "micro" ]; then - printf "%s${clear_line}\n" "${bold_text}STATS ========================${reset_text}" - printf "%s${clear_line}\n" " Blckng: ${domains_being_blocked} domains" - printf "%s${clear_line}\n" " Piholed: [${ads_blocked_bar}] ${ads_percentage_today}%" - printf "%s${clear_line}\n" " Piholed: ${ads_blocked_today} / ${dns_queries_today}" - elif [ "$1" = "mini" ]; then - printf "%s${clear_line}\n" "${bold_text}STATS ==================================${reset_text}" - printf " %-9s%-29s${clear_line}\n" "Blckng:" "${domains_being_blocked} domains" - printf " %-9s[%-20s] %-5s${clear_line}\n" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - printf " %-9s%-29s${clear_line}\n" "Piholed:" "${ads_blocked_today} out of ${dns_queries_today}" - printf " %-9s%-29s${clear_line}\n" "Latest:" "${latest_blocked}" - if [ "${DHCP_ACTIVE}" != "true" ]; then - printf " %-9s%-29s\\n" "Top Ad:" "${top_blocked}" - fi - elif [ "$1" = "tiny" ]; then - printf "%s${clear_line}\n" "${bold_text}STATS ==============================================${reset_text}" - printf " %-10s%-29s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" - printf " %-10s[%-30s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - printf " %-10s%-39s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today}" - printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" - printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" - if [ "${DHCP_ACTIVE}" != "true" ]; then - printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" - printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" - fi - elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - printf "%s${clear_line}\n" "${bold_text}STATS =====================================================${reset_text}" - printf " %-10s%-49s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" - printf " %-10s[%-40s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - printf " %-10s%-49s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today} queries" - printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" - printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" - if [ "${DHCP_ACTIVE}" != "true" ]; then - printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" - printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" +PrintDashboard() { + if [ "$1" = "pico" ]; then + # pico is a screen at least 20x10 (columns x lines) + printf "%s${clear_line}\n" "p${padd_text} ${pico_status}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============${reset_text}" + printf "%s${clear_line}\n" " [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ============${reset_text}" + printf "%s${clear_line}\n" " Hst: ${pi_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP ${dhcp_check_box} IPv6 ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}CPU ================${reset_text}" + printf "%s${clear_line}" " [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + elif [ "$1" = "nano" ]; then + # nano is a screen at least 24x12 (columns x lines) + printf "%s${clear_line}\n" "n${padd_text} ${mini_status}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================${reset_text}" + printf "%s${clear_line}\n" " Up: ${pihole_check_box} FTL: ${ftl_check_box}" + printf "%s${clear_line}\n" " Blk: [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " Blk: ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ================${reset_text}" + printf "%s${clear_line}\n" " Host: ${pi_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =================${reset_text}" + printf "%s${clear_line}\n" " Up: ${system_uptime}" + printf "%s${clear_line}" " CPU: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + elif [ "$1" = "micro" ]; then + # micro is a screen at least 30x16 (columns x lines) + printf "%s${clear_line}\n" "µ${padd_text} ${mini_status}" + printf "%s${clear_line}\n" "" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ======================${reset_text}" + printf "%s${clear_line}\n" " Status: ${pihole_check_box} FTL: ${ftl_check_box}" + printf "%s${clear_line}\n" "${bold_text}STATS ========================${reset_text}" + printf "%s${clear_line}\n" " Blckng: ${domains_being_blocked} domains" + printf "%s${clear_line}\n" " Piholed: [${ads_blocked_bar}] ${ads_percentage_today}%" + printf "%s${clear_line}\n" " Piholed: ${ads_blocked_today} / ${dns_queries_today}" + printf "%s${clear_line}\n" "${bold_text}NETWORK ======================${reset_text}" + printf "%s${clear_line}\n" " Host: ${full_hostname}" + printf "%s${clear_line}\n" " IP: ${pi_ip4_addr}" + printf "%s${clear_line}\n" " DHCP: ${dhcp_check_box} IPv6: ${dhcp_ipv6_check_box}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM =======================${reset_text}" + printf "%s${clear_line}\n" " Uptime: ${system_uptime}" + printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" + elif [ "$1" = "mini" ]; then + # mini is a screen at least 40x18 (columns x lines) + printf "%s${clear_line}\n" "${padd_text}${dim_text}mini${reset_text} ${mini_status}" + printf "%s${clear_line}\n" "" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ================================${reset_text}" + printf " %-9s${pihole_heatmap}%-10s${reset_text} %-9s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}STATS ==================================${reset_text}" + printf " %-9s%-29s${clear_line}\n" "Blckng:" "${domains_being_blocked} domains" + printf " %-9s[%-20s] %-5s${clear_line}\n" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-9s%-29s${clear_line}\n" "Piholed:" "${ads_blocked_today} out of ${dns_queries_today}" + printf " %-9s%-29s${clear_line}\n" "Latest:" "${latest_blocked}" + if [ "${DHCP_ACTIVE}" != "true" ]; then + printf " %-9s%-29s${clear_line}\n" "Top Ad:" "${top_blocked}" + fi + printf "%s${clear_line}\n" "${bold_text}NETWORK ================================${reset_text}" + printf " %-9s%-19s${clear_line}\n" "Host:" "${full_hostname}" + printf " %-9s%-19s${clear_line}\n" "IP:" "${pi_ip4_addr}" + printf " %-9s%-8s %-4s%-5s %-4s%-5s${clear_line}\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-9s%-10s${clear_line}\n" "DNS:" "${dns_information}" + if [ "${DHCP_ACTIVE}" = "true" ]; then + printf " %-9s${dhcp_heatmap}%-10s${reset_text} %-9s${dhcp_ipv6_heatmap}%-10s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + fi + printf "%s${clear_line}\n" "${bold_text}SYSTEM =================================${reset_text}" + printf " %-9s%-29s${clear_line}\n" "Uptime:" "${system_uptime}" + printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" + printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" + elif [ "$1" = "tiny" ]; then + # tiny is a screen at least 53x20 (columns x lines) + printf "%s${clear_line}\n" "${padd_text}${dim_text}tiny${reset_text} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" + printf "%s${clear_line}\n" " PADD ${padd_version_heatmap}${padd_version}${reset_text} ${tiny_status}${reset_text}" + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ============================================${reset_text}" + printf " %-10s${pihole_heatmap}%-16s${reset_text} %-8s${ftl_heatmap}%-10s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}STATS ==============================================${reset_text}" + printf " %-10s%-29s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" + printf " %-10s[%-30s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-39s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today}" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" + if [ "${DHCP_ACTIVE}" != "true" ]; then + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" + fi + printf "%s${clear_line}\n" "${bold_text}NETWORK ============================================${reset_text}" + printf " %-10s%-16s %-8s%-16s${clear_line}\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" + printf " %-10s%-16s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" + printf " %-10s%-16s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-16s %-8s%-16s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + if [ "${DHCP_ACTIVE}" = "true" ]; then + printf " %-10s${dhcp_heatmap}%-16s${reset_text} %-8s${dhcp_ipv6_heatmap}%-10s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf "%s${clear_line}\n" "${dhcp_info}" + fi + printf "%s${clear_line}\n" "${bold_text}SYSTEM =============================================${reset_text}" + printf " %-10s%-29s${clear_line}\n" "Uptime:" "${system_uptime}" + printf " %-10s${temp_heatmap}%-17s${reset_text} %-8s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + printf " %-10s[${memory_heatmap}%-7s${reset_text}] %-6s %-8s[${cpu_load_1_heatmap}%-7s${reset_text}] %-5s${clear_line}" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU:" "${cpu_bar}" "${cpu_percent}%" + elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then + # slim is a screen with at least 60 columns and exactly 21 lines + # regular is a screen at least 60x22 (columns x lines) + if [ "$1" = "slim" ]; then + printf "%s${clear_line}\n" "${padd_text}${dim_text}slim${reset_text} ${full_status}" + printf "%s${clear_line}\n" "" + else + printf "%s${clear_line}\n" "${padd_logo_1}" + printf "%s${clear_line}\n" "${padd_logo_2}Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}" + printf "%s${clear_line}\n" "${padd_logo_3}PADD ${padd_version_heatmap}${padd_version}${reset_text} ${full_status}${reset_text}" + printf "%s${clear_line}\n" "" + fi + printf "%s${clear_line}\n" "${bold_text}PI-HOLE ===================================================${reset_text}" + printf " %-10s${pihole_heatmap}%-19s${reset_text} %-10s${ftl_heatmap}%-19s${reset_text}${clear_line}\n" "Status:" "${pihole_status}" "FTL:" "${ftl_status}" + printf "%s${clear_line}\n" "${bold_text}STATS =====================================================${reset_text}" + printf " %-10s%-49s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" + printf " %-10s[%-40s] %-5s${clear_line}\n" "Pi-holed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-49s${clear_line}\n" "Pi-holed:" "${ads_blocked_today} out of ${dns_queries_today} queries" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" + if [ "${DHCP_ACTIVE}" != "true" ]; then + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" + fi + printf "%s${clear_line}\n" "${bold_text}NETWORK ===================================================${reset_text}" + printf " %-10s%-19s %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" + printf " %-10s%-19s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" + printf " %-10s%-19s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-19s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + if [ "${DHCP_ACTIVE}" = "true" ]; then + printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf "%s${clear_line}\n" "${dhcp_info}" + fi + printf "%s${clear_line}\n" "${bold_text}SYSTEM ====================================================${reset_text}" + printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" + printf " %-10s%-39s${clear_line}\n" "Uptime:" "${system_uptime}" + printf " %-10s${temp_heatmap}%-20s${reset_text}${clear_line}" "CPU Temp:" "${temperature}" + printf " %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s${clear_line}" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" + else # ${padd_size} = mega + # mega is a screen with at least 80 columns and 26 lines + printf "%s${clear_line}\n" "${padd_logo_retro_1}" + printf "%s${clear_line}\n" "${padd_logo_retro_2} Pi-hole® ${core_version_heatmap}${core_version}${reset_text}, Web ${web_version_heatmap}${web_version}${reset_text}, FTL ${ftl_version_heatmap}${ftl_version}${reset_text}, PADD ${padd_version_heatmap}${padd_version}${reset_text}" + printf "%s${clear_line}\n" "${padd_logo_retro_3} ${pihole_check_box} Core ${ftl_check_box} FTL ${mega_status}${reset_text}" + printf "%s${clear_line}\n" "" + printf "%s${clear_line}\n" "${bold_text}STATS =========================================================================${reset_text}" + printf " %-10s%-19s %-10s[%-40s] %-5s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" + printf " %-10s%-30s%-29s${clear_line}\n" "Clients:" "${clients}" " ${ads_blocked_today} out of ${dns_queries_today} queries" + printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" + printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" + printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" + printf "%s${clear_line}\n" "FTL ===========================================================================" + printf " %-10s%-9s %-10s%-9s %-10s%-9s${clear_line}\n" "PID:" "${ftlPID}" "CPU Use:" "${ftl_cpu}%" "Mem. Use:" "${ftl_mem_percentage}%" + printf " %-10s%-69s${clear_line}\n" "DNSCache:" "${cache_inserts} insertions, ${cache_deletes} deletions, ${cache_size} total entries" + printf "%s${clear_line}\n" "${bold_text}NETWORK =======================================================================${reset_text}" + printf " %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" + printf " %-11s%-14s %-4s%-9s %-4s%-9s${clear_line}\n" "Interface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-6s%-19s %-10s%-29s${clear_line}\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" + printf "%s${clear_line}\n" "DNS ===========================================================================" + printf " %-10s%-39s${clear_line}\n" "Servers:" "${dns_information}" + printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-20s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "Conditional Fwding:" "${conditional_forwarding_status}" + printf "%s${clear_line}\n" "DHCP ==========================================================================" + printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-9s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" + printf "%s${clear_line}\n" "${dhcp_info}" + printf "%s${clear_line}\n" "${bold_text}SYSTEM ========================================================================${reset_text}" + printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" + printf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" + printf " %-10s${temp_heatmap}%-10s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" fi - else - printf "%s${clear_line}\n" "${bold_text}STATS =========================================================================${reset_text}" - printf " %-10s%-19s %-10s[%-40s] %-5s${clear_line}\n" "Blocking:" "${domains_being_blocked} domains" "Piholed:" "${ads_blocked_bar}" "${ads_percentage_today}%" - printf " %-10s%-30s%-29s${clear_line}\n" "Clients:" "${clients}" " ${ads_blocked_today} out of ${dns_queries_today} queries" - printf " %-10s%-39s${clear_line}\n" "Latest:" "${latest_blocked}" - printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" - printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" - printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" - printf "%s${clear_line}\n" "FTL ===========================================================================" - printf " %-10s%-9s %-10s%-9s %-10s%-9s${clear_line}\n" "PID:" "${ftlPID}" "CPU Use:" "${ftl_cpu}%" "Mem. Use:" "${ftl_mem_percentage}%" - printf " %-10s%-69s${clear_line}\n" "DNSCache:" "${cache_inserts} insertions, ${cache_deletes} deletions, ${cache_size} total entries" - fi -} - -PrintSystemInformation() { - if [ "$1" = "pico" ]; then - printf "%s${clear_line}\n" "${bold_text}CPU ================${reset_text}" - printf "%s${clear_line}" " [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - elif [ "$1" = "nano" ]; then - printf "%s${clear_line}\n" "${bold_text}SYSTEM =================${reset_text}" - printf "%s${clear_line}\n" " Up: ${system_uptime}" - printf "%s${clear_line}" " CPU: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - elif [ "$1" = "micro" ]; then - printf "%s${clear_line}\n" "${bold_text}SYSTEM =======================${reset_text}" - printf "%s${clear_line}\n" " Uptime: ${system_uptime}" - printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" - elif [ "$1" = "mini" ]; then - printf "%s${clear_line}\n" "${bold_text}SYSTEM =================================${reset_text}" - printf " %-9s%-29s\\n" "Uptime:" "${system_uptime}" - printf "%s${clear_line}\n" " Load: [${cpu_load_1_heatmap}${cpu_bar}${reset_text}] ${cpu_percent}%" - printf "%s${clear_line}" " Memory: [${memory_heatmap}${memory_bar}${reset_text}] ${memory_percent}%" - elif [ "$1" = "tiny" ]; then - printf "%s${clear_line}\n" "${bold_text}SYSTEM =============================================${reset_text}" - printf " %-10s%-29s${clear_line}\n" "Uptime:" "${system_uptime}" - printf " %-10s${temp_heatmap}%-17s${reset_text} %-8s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" - # Memory and CPU bar - printf " %-10s[${memory_heatmap}%-7s${reset_text}] %-6s %-8s[${cpu_load_1_heatmap}%-7s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU:" "${cpu_bar}" "${cpu_percent}%" - # else we're not - elif [ "$1" = "regular" ] || [ "$1" = "slim" ]; then - printf "%s${clear_line}\n" "${bold_text}SYSTEM ====================================================${reset_text}" - # Device - printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" - # Uptime - printf " %-10s%-39s${clear_line}\n" "Uptime:" "${system_uptime}" - - # Temp and Loads - printf " %-10s${temp_heatmap}%-20s${reset_text}" "CPU Temp:" "${temperature}" - printf " %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" - - # Memory and CPU bar - printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" - else - printf "%s${clear_line}\n" "${bold_text}SYSTEM ========================================================================${reset_text}" - # Device - printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" - - # Uptime and memory - printf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s\\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" - - # CPU temp, load, percentage - printf " %-10s${temp_heatmap}%-10s${reset_text} %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-7s${reset_text} %-10s[${memory_heatmap}%-10s${reset_text}] %-6s" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" - fi } ############################################# HELPERS ############################################## @@ -889,7 +864,7 @@ SizeChecker(){ if [ "$console_width" -lt "20" ] || [ "$console_height" -lt "10" ]; then # Nothing is this small, sorry clear - printf "%b" "${check_box_bad} Error!\\n PADD isn't\\n for ants!\n" + printf "%b" "${check_box_bad} Error!\n PADD isn't\n for ants!\n" exit 1 # Below Nano. Gives you Pico. elif [ "$console_width" -lt "24" ] || [ "$console_height" -lt "12" ]; then @@ -947,17 +922,17 @@ CheckConnectivity() { # echo "$wait_timer = $inner_wait_timer" while [ $inner_wait_timer -gt 0 ]; do if [ "$1" = "pico" ] || [ "$1" = "nano" ] || [ "$1" = "micro" ]; then - printf "%b" "Attempt #${connection_attempts} failed...\\r" + printf "%b" "Attempt #${connection_attempts} failed...\r" elif [ "$1" = "mini" ] || [ "$1" = "tiny" ]; then - printf "%b" "- Attempt ${connection_attempts} failed, wait ${inner_wait_timer} \\r" + printf "%b" "- Attempt ${connection_attempts} failed, wait ${inner_wait_timer} \r" else - printf "%b" " - Attempt ${connection_attempts} failed... waiting ${inner_wait_timer} seconds... \\r" + printf "%b" " - Attempt ${connection_attempts} failed... waiting ${inner_wait_timer} seconds... \r" fi sleep 1 inner_wait_timer=$((inner_wait_timer-1)) done - # echo -ne "Attempt $connection_attempts failed... waiting $wait_timer seconds...\\r" + # echo -ne "Attempt $connection_attempts failed... waiting $wait_timer seconds...\r" # sleep $wait_timer wait_timer=$((wait_timer*2)) fi @@ -1029,25 +1004,25 @@ StartupRoutine(){ CheckConnectivity "$1" printf "%b" "Starting PADD...\n" - printf "%b" " [■·········] 10%\\r" + printf "%b" " [■·········] 10%\r" # Check for updates - printf "%b" " [■■········] 20%\\r" - printf "%b" " [■■■·······] 30%\\r" + printf "%b" " [■■········] 20%\r" + printf "%b" " [■■■·······] 30%\r" # Get our information for the first time - printf "%b" " [■■■■······] 40%\\r" + printf "%b" " [■■■■······] 40%\r" GetSystemInformation "$1" - printf "%b" " [■■■■■·····] 50%\\r" + printf "%b" " [■■■■■·····] 50%\r" GetSummaryInformation "$1" - printf "%b" " [■■■■■■····] 60%\\r" + printf "%b" " [■■■■■■····] 60%\r" GetPiholeInformation "$1" - printf "%b" " [■■■■■■■···] 70%\\r" + printf "%b" " [■■■■■■■···] 70%\r" GetNetworkInformation "$1" - printf "%b" " [■■■■■■■■··] 80%\\r" + printf "%b" " [■■■■■■■■··] 80%\r" GetVersionInformation "$1" - printf "%b" " [■■■■■■■■■·] 90%\\r" - printf "%b" " [■■■■■■■■■■] 100%\\n" + printf "%b" " [■■■■■■■■■·] 90%\r" + printf "%b" " [■■■■■■■■■■] 100%\n" elif [ "$1" = "mini" ]; then PrintLogo "$1" @@ -1126,15 +1101,12 @@ NormalPADD() { tput cup 0 0 # Output everything to the screen - PrintLogo ${padd_size} - PrintPiholeInformation ${padd_size} - PrintPiholeStats ${padd_size} - PrintNetworkInformation ${padd_size} - PrintSystemInformation ${padd_size} + PrintDashboard ${padd_size} # Clear to end of screen (below the drawn dashboard) tput ed + # Reset status indicator (can be overwritten by one of the GetXXXXInformation) pico_status=${pico_status_ok} mini_status=${mini_status_ok} tiny_status=${tiny_status_ok} From b37543508d006deedbb70aaeb1ffc7bd36b163d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 20 Aug 2022 09:56:21 +0200 Subject: [PATCH 16/20] Fix number of lines in "mini" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 5 ++-- pass_size_checker.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 3 deletions(-) create mode 100755 pass_size_checker.sh diff --git a/padd.sh b/padd.sh index 1d4c8f4a..39a629cd 100755 --- a/padd.sh +++ b/padd.sh @@ -31,7 +31,7 @@ LastCheckSystemInformation=$(date +%s) core_count=$(nproc --all 2> /dev/null) # COLORS -CSI="$(printf '\033')[" +CSI="$(printf '\033')[" # Control Sequence Introducer red_text="${CSI}91m" # Red green_text="${CSI}92m" # Green yellow_text="${CSI}93m" # Yellow @@ -685,8 +685,7 @@ PrintDashboard() { printf " %-9s%-29s${clear_line}\n" "Top Ad:" "${top_blocked}" fi printf "%s${clear_line}\n" "${bold_text}NETWORK ================================${reset_text}" - printf " %-9s%-19s${clear_line}\n" "Host:" "${full_hostname}" - printf " %-9s%-19s${clear_line}\n" "IP:" "${pi_ip4_addr}" + printf " %-9s%-15s%-4s%-11s${clear_line}\n" "Host:" "${full_hostname}" "IP:" "${pi_ip4_addr}" printf " %-9s%-8s %-4s%-5s %-4s%-5s${clear_line}\n" "Iface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" printf " %-9s%-10s${clear_line}\n" "DNS:" "${dns_information}" if [ "${DHCP_ACTIVE}" = "true" ]; then diff --git a/pass_size_checker.sh b/pass_size_checker.sh new file mode 100755 index 00000000..470fb15b --- /dev/null +++ b/pass_size_checker.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env sh + +SizeChecker(){ + # Below Pico. Gives you nothing... + if [ "$console_width" -lt "20" ] || [ "$console_height" -lt "10" ]; then + # Nothing is this small, sorry + padd_size="ants" + # Below Nano. Gives you Pico. + elif [ "$console_width" -lt "24" ] || [ "$console_height" -lt "12" ]; then + padd_size="pico" + # Below Micro, Gives you Nano. + elif [ "$console_width" -lt "30" ] || [ "$console_height" -lt "16" ]; then + padd_size="nano" + # Below Mini. Gives you Micro. + elif [ "$console_width" -lt "40" ] || [ "$console_height" -lt "18" ]; then + padd_size="micro" + # Below Tiny. Gives you Mini. + elif [ "$console_width" -lt "53" ] || [ "$console_height" -lt "20" ]; then + padd_size="miprintf '\e[8;16;30t' > /dev/pts/0idth" -lt "60" ] || [ "$console_height" -lt "21" ]; then + padd_size="tiny" + # Below Regular. Gives you Slim. + elif [ "$console_width" -lt "80" ] || [ "$console_height" -lt "26" ]; then + if [ "$console_height" -lt "22" ]; then + padd_size="slim" + else + padd_size="regular" + fi + # Mega + else + padd_size="mega" + fi +} + +clear +setterm -cursor off +trap "{ setterm -cursor on ; echo "" ; exit 0 ; }" INT TERM EXIT + +while true; do + # Clear to end of screen (below the drawn dashboard) + tput ed + + # Move the cursor to top left of console to redraw + tput cup 0 0 + + + console_width=$(tput cols) + console_height=$(tput lines) + SizeChecker + + echo "Columns: ${console_width}\033[0K" + echo "Lines: ${console_height}\033[0K" + echo "" + echo "Padd_size ${padd_size}\033[0K" + + +done + +# Hint: to resize another terminal (e.g. connected via SSH) +# printf '\e[8;16;30t' > /dev/pts/0 From ad72d13b64a2f989a712f3d6f08a9ecce27ca3fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 20 Aug 2022 10:03:38 +0200 Subject: [PATCH 17/20] Remove IPv6 info from "tiny" to fit interface and TX/RX info MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/padd.sh b/padd.sh index 39a629cd..b3e192bc 100755 --- a/padd.sh +++ b/padd.sh @@ -713,7 +713,6 @@ PrintDashboard() { fi printf "%s${clear_line}\n" "${bold_text}NETWORK ============================================${reset_text}" printf " %-10s%-16s %-8s%-16s${clear_line}\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" - printf " %-10s%-16s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" printf " %-10s%-16s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" printf " %-10s%-16s %-8s%-16s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" if [ "${DHCP_ACTIVE}" = "true" ]; then From 9285567ae636b01222b4721e2bce9c9336f13b34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Sat, 20 Aug 2022 15:19:54 +0200 Subject: [PATCH 18/20] Fix regular and mega MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 29 ++++++++++------------ pass_size_checker.sh | 59 -------------------------------------------- 2 files changed, 13 insertions(+), 75 deletions(-) delete mode 100755 pass_size_checker.sh diff --git a/padd.sh b/padd.sh index b3e192bc..8f6eaead 100755 --- a/padd.sh +++ b/padd.sh @@ -297,9 +297,11 @@ GetNetworkInformation() { elif [ "${pi_ip6_addrs}" -eq 1 ]; then # One IPv6 address available pi_ip6_addr="$(ip addr | grep 'inet6 ' | grep -v '::1/128' | awk '{print $2}' | cut -f1 -d'/' | head -n 1)" + ipv6_check_box=${check_box_bad} else # More than one IPv6 address available pi_ip6_addr="$(ip addr | grep 'inet6 ' | grep -v '::1/128' | awk '{print $2}' | cut -f1 -d'/' | head -n 1)+" + ipv6_check_box=${check_box_good} fi # Get hostname and gateway @@ -748,19 +750,16 @@ PrintDashboard() { printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" fi printf "%s${clear_line}\n" "${bold_text}NETWORK ===================================================${reset_text}" - printf " %-10s%-19s %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" - printf " %-10s%-19s${clear_line}\n" "IPv6:" "${pi_ip6_addr}" - printf " %-10s%-19s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-10s%-19s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + printf " %-10s%-15s %-4s%-17s%-6s%s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" "IPv6:" "${ipv6_check_box}" + printf " %-10s%-15s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-15s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" if [ "${DHCP_ACTIVE}" = "true" ]; then - printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} + printf " %-10s${dhcp_heatmap}%-15s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} printf "%s${clear_line}\n" "${dhcp_info}" fi printf "%s${clear_line}\n" "${bold_text}SYSTEM ====================================================${reset_text}" - printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" printf " %-10s%-39s${clear_line}\n" "Uptime:" "${system_uptime}" - printf " %-10s${temp_heatmap}%-20s${reset_text}${clear_line}" "CPU Temp:" "${temperature}" - printf " %-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" + printf " %-10s${temp_heatmap}%-21s${reset_text}%-10s${cpu_load_1_heatmap}%-4s${reset_text}, ${cpu_load_5_heatmap}%-4s${reset_text}, ${cpu_load_15_heatmap}%-4s${reset_text}${clear_line}\n" "CPU Temp:" "${temperature}" "CPU Load:" "${cpu_load_1}" "${cpu_load_5}" "${cpu_load_15}" printf " %-10s[${memory_heatmap}%-10s${reset_text}] %-6s %-10s[${cpu_load_1_heatmap}%-10s${reset_text}] %-5s${clear_line}" "Memory:" "${memory_bar}" "${memory_percent}%" "CPU Load:" "${cpu_bar}" "${cpu_percent}%" else # ${padd_size} = mega # mega is a screen with at least 80 columns and 26 lines @@ -775,19 +774,17 @@ PrintDashboard() { printf " %-10s%-39s${clear_line}\n" "Top Ad:" "${top_blocked}" printf " %-10s%-39s${clear_line}\n" "Top Dmn:" "${top_domain}" printf " %-10s%-39s${clear_line}\n" "Top Clnt:" "${top_client}" - printf "%s${clear_line}\n" "FTL ===========================================================================" + printf "%s${clear_line}\n" "${bold_text}FTL ===========================================================================${reset_text}" printf " %-10s%-9s %-10s%-9s %-10s%-9s${clear_line}\n" "PID:" "${ftlPID}" "CPU Use:" "${ftl_cpu}%" "Mem. Use:" "${ftl_mem_percentage}%" printf " %-10s%-69s${clear_line}\n" "DNSCache:" "${cache_inserts} insertions, ${cache_deletes} deletions, ${cache_size} total entries" printf "%s${clear_line}\n" "${bold_text}NETWORK =======================================================================${reset_text}" printf " %-10s%-19s${clear_line}\n" "Hostname:" "${full_hostname}" - printf " %-11s%-14s %-4s%-9s %-4s%-9s${clear_line}\n" "Interface:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" + printf " %-10s%-15s %-4s%-9s %-4s%-9s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" printf " %-6s%-19s %-10s%-29s${clear_line}\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" - printf "%s${clear_line}\n" "DNS ===========================================================================" - printf " %-10s%-39s${clear_line}\n" "Servers:" "${dns_information}" - printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-20s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "Conditional Fwding:" "${conditional_forwarding_status}" - printf "%s${clear_line}\n" "DHCP ==========================================================================" - printf " %-10s${dhcp_heatmap}%-19s${reset_text} %-10s${dhcp_ipv6_heatmap}%-9s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" - printf "%s${clear_line}\n" "${dhcp_info}" + printf "%s${clear_line}\n" "${bold_text}DNS ==========================DHCP=============================================${reset_text}" + printf " %-10s%-19s %-6s${dhcp_heatmap}%-19s${clear_line}\n" "Servers:" "${dns_information}" "DHCP:" "${dhcp_status}" + printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-10s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" + printf " %-10s${conditional_forwarding_heatmap}%-19s${reset_text}%s${clear_line}\n" "CdFwding:" "${conditional_forwarding_status}" "${dhcp_info}" printf "%s${clear_line}\n" "${bold_text}SYSTEM ========================================================================${reset_text}" printf " %-10s%-39s${clear_line}\n" "Device:" "${sys_model}" printf " %-10s%-39s %-10s[${memory_heatmap}%-10s${reset_text}] %-6s${clear_line}\n" "Uptime:" "${system_uptime}" "Memory:" "${memory_bar}" "${memory_percent}%" diff --git a/pass_size_checker.sh b/pass_size_checker.sh deleted file mode 100755 index 470fb15b..00000000 --- a/pass_size_checker.sh +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/env sh - -SizeChecker(){ - # Below Pico. Gives you nothing... - if [ "$console_width" -lt "20" ] || [ "$console_height" -lt "10" ]; then - # Nothing is this small, sorry - padd_size="ants" - # Below Nano. Gives you Pico. - elif [ "$console_width" -lt "24" ] || [ "$console_height" -lt "12" ]; then - padd_size="pico" - # Below Micro, Gives you Nano. - elif [ "$console_width" -lt "30" ] || [ "$console_height" -lt "16" ]; then - padd_size="nano" - # Below Mini. Gives you Micro. - elif [ "$console_width" -lt "40" ] || [ "$console_height" -lt "18" ]; then - padd_size="micro" - # Below Tiny. Gives you Mini. - elif [ "$console_width" -lt "53" ] || [ "$console_height" -lt "20" ]; then - padd_size="miprintf '\e[8;16;30t' > /dev/pts/0idth" -lt "60" ] || [ "$console_height" -lt "21" ]; then - padd_size="tiny" - # Below Regular. Gives you Slim. - elif [ "$console_width" -lt "80" ] || [ "$console_height" -lt "26" ]; then - if [ "$console_height" -lt "22" ]; then - padd_size="slim" - else - padd_size="regular" - fi - # Mega - else - padd_size="mega" - fi -} - -clear -setterm -cursor off -trap "{ setterm -cursor on ; echo "" ; exit 0 ; }" INT TERM EXIT - -while true; do - # Clear to end of screen (below the drawn dashboard) - tput ed - - # Move the cursor to top left of console to redraw - tput cup 0 0 - - - console_width=$(tput cols) - console_height=$(tput lines) - SizeChecker - - echo "Columns: ${console_width}\033[0K" - echo "Lines: ${console_height}\033[0K" - echo "" - echo "Padd_size ${padd_size}\033[0K" - - -done - -# Hint: to resize another terminal (e.g. connected via SSH) -# printf '\e[8;16;30t' > /dev/pts/0 From 2dd7a81c64925628adcc0597f4a151e1bde28746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 7 Oct 2022 14:37:52 +0200 Subject: [PATCH 19/20] Fix dnssec_heatmap MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/padd.sh b/padd.sh index 8f6eaead..26232a2f 100755 --- a/padd.sh +++ b/padd.sh @@ -716,7 +716,7 @@ PrintDashboard() { printf "%s${clear_line}\n" "${bold_text}NETWORK ============================================${reset_text}" printf " %-10s%-16s %-8s%-16s${clear_line}\n" "Hostname:" "${full_hostname}" "IP: " "${pi_ip4_addr}" printf " %-10s%-16s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-10s%-16s %-8s%-16s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + printf " %-10s%-16s %-8s${dnssec_heatmap}%-16s${reset_text}${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_status}" if [ "${DHCP_ACTIVE}" = "true" ]; then printf " %-10s${dhcp_heatmap}%-16s${reset_text} %-8s${dhcp_ipv6_heatmap}%-10s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} printf "%s${clear_line}\n" "${dhcp_info}" @@ -752,7 +752,7 @@ PrintDashboard() { printf "%s${clear_line}\n" "${bold_text}NETWORK ===================================================${reset_text}" printf " %-10s%-15s %-4s%-17s%-6s%s${clear_line}\n" "Hostname:" "${full_hostname}" "IP:" "${pi_ip4_addr}" "IPv6:" "${ipv6_check_box}" printf " %-10s%-15s %-4s%-5s %-4s%-5s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" - printf " %-10s%-15s %-10s%-19s${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_heatmap}${dnssec_status}${reset_text}" + printf " %-10s%-15s %-10s${dnssec_heatmap}%-19s${reset_text}${clear_line}\n" "DNS:" "${dns_information}" "DNSSEC:" "${dnssec_status}" if [ "${DHCP_ACTIVE}" = "true" ]; then printf " %-10s${dhcp_heatmap}%-15s${reset_text} %-10s${dhcp_ipv6_heatmap}%-19s${reset_text}${clear_line}\n" "DHCP:" "${dhcp_status}" "IPv6:" ${dhcp_ipv6_status} printf "%s${clear_line}\n" "${dhcp_info}" @@ -782,7 +782,7 @@ PrintDashboard() { printf " %-10s%-15s %-4s%-9s %-4s%-9s${clear_line}\n" "Interfce:" "${iface_name}" "TX:" "${tx_bytes}" "RX:" "${rx_bytes}" printf " %-6s%-19s %-10s%-29s${clear_line}\n" "IPv4:" "${pi_ip4_addr}" "IPv6:" "${pi_ip6_addr}" printf "%s${clear_line}\n" "${bold_text}DNS ==========================DHCP=============================================${reset_text}" - printf " %-10s%-19s %-6s${dhcp_heatmap}%-19s${clear_line}\n" "Servers:" "${dns_information}" "DHCP:" "${dhcp_status}" + printf " %-10s%-19s %-6s${dhcp_heatmap}%-19s${reset_text}${clear_line}\n" "Servers:" "${dns_information}" "DHCP:" "${dhcp_status}" printf " %-10s${dnssec_heatmap}%-19s${reset_text} %-10s${conditional_forwarding_heatmap}%-9s${reset_text}${clear_line}\n" "DNSSEC:" "${dnssec_status}" "IPv6 Spt:" "${dhcp_ipv6_status}" printf " %-10s${conditional_forwarding_heatmap}%-19s${reset_text}%s${clear_line}\n" "CdFwding:" "${conditional_forwarding_status}" "${dhcp_info}" printf "%s${clear_line}\n" "${bold_text}SYSTEM ========================================================================${reset_text}" From 2483d8c86d732ec6695624245330a52e9e957c6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6nig?= Date: Fri, 7 Oct 2022 14:48:41 +0200 Subject: [PATCH 20/20] Having one IPv6 is not bad MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Christian König --- padd.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/padd.sh b/padd.sh index 26232a2f..7c2fa867 100755 --- a/padd.sh +++ b/padd.sh @@ -294,10 +294,11 @@ GetNetworkInformation() { if [ "${pi_ip6_addrs}" -eq 0 ]; then # No IPv6 address available pi_ip6_addr="N/A" + ipv6_check_box=${check_box_bad} elif [ "${pi_ip6_addrs}" -eq 1 ]; then # One IPv6 address available pi_ip6_addr="$(ip addr | grep 'inet6 ' | grep -v '::1/128' | awk '{print $2}' | cut -f1 -d'/' | head -n 1)" - ipv6_check_box=${check_box_bad} + ipv6_check_box=${check_box_good} else # More than one IPv6 address available pi_ip6_addr="$(ip addr | grep 'inet6 ' | grep -v '::1/128' | awk '{print $2}' | cut -f1 -d'/' | head -n 1)+"