Provide option to mimic discontinued chronometer and exit PADD when run
I used the old chronometer as part of my MOTD when SSHing into the Pi running Pi-Hole. This gave me a quick overview about the current status and load on the Pi.
I have never heard of PADD before, and now with Pi-Hole 6 out, the old chronometer is discontinued. When installing and running PADD (v4), it seems to be running in a loop and always updating the displayed info regularly. Pressing Ctrl-C gives me my prompt back.
Is there a way to have PADD run only once, exit the program and show me my prompt again? That way, I can use it as a one-time quick look whenever I SSH into the Pi running Pi-Hole and then use my Pi in another way - as I was doing before.
Huh - I didn't realise that was even possible with chronometer. If you're looking to display information in the MOTD, you could even use the API to grab the relevant info, without fully running PADD
Currently there is no 'run-once-and-exit' option which prints everything nicely. You could use the -j option for some basic stats
./padd.sh -j
Establishing connection with FTL...
No authentication required.
{"domains_being_blocked":1003065,"dns_queries_today":32935,"ads_blocked_today":3998,"ads_percentage_today":12.1,"clients": 10}
I hacked this together really quickly for similar reasons:
diff --git a/padd.sh b/padd.sh
index 8fa5ef8..b7f1307 100755
--- a/padd.sh
+++ b/padd.sh
@@ -17,6 +17,8 @@ export LC_NUMERIC=C
# VERSION
padd_version="v4.0.0"
+runOnce=0
+
# LastChecks
LastCheckPADDInformation=$(date +%s)
LastCheckFullInformation=$(date +%s)
@@ -1692,6 +1694,10 @@ NormalPADD() {
# Output everything to the screen
PrintDashboard ${padd_size}
+ if [ "${runOnce}" -eq 1 ]; then
+ break
+ fi
+
# Sleep for 5 seconds
# sending sleep in the background and wait for it
# this way the TerminalResize trap can kill the sleep
@@ -1802,6 +1808,7 @@ DisplayHelp() {
::: --server <DOMAIN|IP> domain or IP of your Pi-hole (default: localhost)
::: --secret <password> your Pi-hole's password, required to access the API
::: --2fa <2fa> your Pi-hole's 2FA code, if 2FA is enabled
+;;; --runonce display output once and exit
::: -j, --json output stats as JSON formatted string and exit
::: -u, --update update to the latest version
::: -v, --version show PADD version info
@@ -1898,6 +1905,7 @@ while [ "$#" -gt 0 ]; do
"-u" | "--update" ) Update;;
"-h" | "--help" ) DisplayHelp; exit 0;;
"-v" | "--version" ) xOffset=0; ShowVersion; exit 0;;
+ "--runonce" ) runOnce=1;;
"--xoff" ) xOffset="$2"; xOffOrig="$2"; shift;;
"--yoff" ) yOffset="$2"; yOffOrig="$2"; shift;;
"--server" ) SERVER="$2"; shift;;
Would you like to file a pull request?
Sure. When I have some more time I was going to make sure I followed the coding style, etc. and then do so.
@daPhipz, the timeout command is a good solution for you. I use this in my .bashrc file.
PADD takes around 10 seconds to startup.
timeout 12 ./padd.sh
timeout 12 ./padd.sh
Thanks @robcmo, this is a good workaround!
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.
As I understand it, this issue will get a fix with #443, which will land in version 4.1.0 as per #438 - correct?
Correct.
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.
Still open, waiting for the new release PR to be merged.
This issue is stale because it has been open 30 days with no activity. Please comment or update this issue or it will be closed in 5 days.
I'll try to give PADD some attention in the next days including a new release which will fix this issue.