Skip to content

Commit 2440291

Browse files
authored
Add option to display PADD only once and exit (#443)
2 parents f350acf + 2aeb96c commit 2440291

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

padd.sh

+19-6
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ LastCheckNetworkInformation=$(date +%s)
2525
# padd_data holds the data returned by FTL's /padd endpoint globally
2626
padd_data=""
2727

28+
# should PADD run only once?
29+
runOnce=false
30+
2831
# COLORS
2932
CSI="$(printf '\033')[" # Control Sequence Introducer
3033
red_text="${CSI}91m" # Red
@@ -1710,12 +1713,15 @@ StartupRoutine(){
17101713
fi
17111714
fi
17121715

1713-
moveXOffset; printf "%s" "- Starting in "
1714-
for i in 3 2 1
1715-
do
1716-
printf "%s..." "$i"
1717-
sleep 1
1718-
done
1716+
if [ "${runOnce}" = "false" ]; then
1717+
moveXOffset; printf "%s" "- Starting in "
1718+
for i in 3 2 1
1719+
do
1720+
printf "%s..." "$i"
1721+
sleep 1
1722+
done
1723+
fi
1724+
17191725
}
17201726

17211727
NormalPADD() {
@@ -1739,6 +1745,11 @@ NormalPADD() {
17391745
# Output everything to the screen
17401746
PrintDashboard ${padd_size}
17411747

1748+
# Should we only run once?
1749+
if [ "${runOnce}" = "true" ]; then
1750+
break
1751+
fi
1752+
17421753
# Sleep for 5 seconds
17431754
# sending sleep in the background and wait for it
17441755
# this way the TerminalResize trap can kill the sleep
@@ -1842,6 +1853,7 @@ DisplayHelp() {
18421853
::: --server <DOMAIN|IP> domain or IP of your Pi-hole (default: localhost)
18431854
::: --secret <password> your Pi-hole's password, required to access the API
18441855
::: --2fa <2fa> your Pi-hole's 2FA code, if 2FA is enabled
1856+
::: --runonce display output once and exit
18451857
::: -u, --update update to the latest version
18461858
::: -v, --version show PADD version info
18471859
::: -h, --help display this help text
@@ -1939,6 +1951,7 @@ while [ "$#" -gt 0 ]; do
19391951
"-u" | "--update" ) xOffset=0; doUpdate=true;;
19401952
"-h" | "--help" ) DisplayHelp; exit 0;;
19411953
"-v" | "--version" ) xOffset=0; versionOnly=true ;;
1954+
"--runonce" ) runOnce=true;;
19421955
"--xoff" ) xOffset="$2"; xOffOrig="$2"; shift;;
19431956
"--yoff" ) yOffset="$2"; yOffOrig="$2"; shift;;
19441957
"--server" ) SERVER="$2"; shift;;

0 commit comments

Comments
 (0)