aboutsummaryrefslogtreecommitdiff
path: root/bin/sqlwait
diff options
context:
space:
mode:
authorjakobst1n <jakob.stendahl@outlook.com>2024-06-11 23:54:09 +0200
committerjakobst1n <jakob.stendahl@outlook.com>2024-06-11 23:54:09 +0200
commit1b3bd0f2e97b299dcfaf450f991cc0134a849087 (patch)
tree57fcfe96218573f74f6018042fad252f49962047 /bin/sqlwait
parent8966f28d8ebff43174fe225c3a49b4cb89c1980f (diff)
downloaddotfiles-1b3bd0f2e97b299dcfaf450f991cc0134a849087.tar.gz
dotfiles-1b3bd0f2e97b299dcfaf450f991cc0134a849087.zip
Add silent mode to sqlwait
Diffstat (limited to 'bin/sqlwait')
-rwxr-xr-xbin/sqlwait64
1 files changed, 37 insertions, 27 deletions
diff --git a/bin/sqlwait b/bin/sqlwait
index 71dc01f..d4409f3 100755
--- a/bin/sqlwait
+++ b/bin/sqlwait
@@ -4,6 +4,7 @@ SLEEP=10
PRINT=false
CALCULATE=false
REDRAW=false
+SILENT=false
EXIT_ON_ERROR=false
WATCH=false
MYSQL_HOST="localhost"
@@ -25,6 +26,7 @@ usage() {
printf " -p Print the current value for each check\n"
printf " -P Print only on same line (also enables -p)\n"
printf " -k C(k)alculate estimation until target\n"
+ printf " -s Silent mode, print only minimal info\n"
printf " -e Exit on error\n"
}
@@ -64,6 +66,9 @@ while getopts "H:u:d:c:t:n:l:pPewkh" opt; do
k )
CALCULATE=true
;;
+ s )
+ SILENT=true
+ ;;
e )
EXIT_ON_ERROR=true
;;
@@ -147,7 +152,10 @@ while true; do
tput cr
tput el
fi
- printf "[$(date)]: ${RESULT}"
+ if [ "$SILENT" = false ]; then
+ printf "[$(date)]: "
+ fi
+ printf "${RESULT}"
if [ "$CALCULATE" = true ]; then
CHANGE=$(python -c "print(int(abs($RESULT-$LAST)))" 2> /dev/null)
ELAPSED_TIME=$(($ELAPSED_TIME+$SLEEP))
@@ -193,44 +201,46 @@ while true; do
if [ "$_TARGET_OK" = true ]; then
if [ "$TARGET_OK" = false ]; then
- if [ "$PRINT" = true ]; then
- printf "[$(date)]: Target "
- tput setaf 2
- printf "OK "
- tput sgr0
- tput sitm
- printf "$TARGET "
- tput ritm
- printf "$SIGN_OK "
- tput bold
- printf "$RESULT\n"
- tput sgr0
+ if [ "$SILENT" = false ]; then
+ if [ "$PRINT" = true ]; then
+ printf "[$(date)]: Target "
+ tput setaf 2
+ printf "OK "
+ tput sgr0
+ tput sitm
+ printf "$TARGET "
+ tput ritm
+ printf "$SIGN_OK "
+ tput bold
+ printf "$RESULT\n"
+ tput sgr0
+ fi
fi
if [ ! "$COMMAND" = "" ]; then
sh -c "$COMMAND"
fi
fi
-
TARGET_OK=true
-
if [ "$WATCH" = false ]; then
break
fi
else
if [ "$TARGET_OK" = true ]; then
- if [ "$PRINT" = true ]; then
- printf "[$(date)]: Target "
- tput setaf 1
- printf "NOK "
- tput sgr0
- tput sitm
- printf "$TARGET "
- tput ritm
- printf "$SIGN_NOK "
- tput bold
- printf "$RESULT\n"
- tput sgr0
+ if [ "$SILENT" = false ]; then
+ if [ "$PRINT" = true ]; then
+ printf "[$(date)]: Target "
+ tput setaf 1
+ printf "NOK "
+ tput sgr0
+ tput sitm
+ printf "$TARGET "
+ tput ritm
+ printf "$SIGN_NOK "
+ tput bold
+ printf "$RESULT\n"
+ tput sgr0
+ fi
fi
if [ ! "$COMMAND_NOK" = "" ]; then
sh -c "$COMMAND_NOK"