diff --git a/lib/display.sh b/lib/display.sh index f4b608d..a0a95f8 100644 --- a/lib/display.sh +++ b/lib/display.sh @@ -88,10 +88,17 @@ export On_IWhite='\e[0;107m' # ------------------------------------------------------------------------------ # Display status with color and timestamp +# (-n on first parameter to stay on the same line) # ($1 accepted values: I=info, W=warning, E=error, m=des espaces (allignement) # no header if anything else) prnt() { + if [[ $1 == "-n" ]]; then + local echoopt=$1 + shift + else + local echoopt="" + fi case $1 in "I") local heads="[ ${IGreen}info${DEFAULTFG} ]" @@ -110,13 +117,30 @@ prnt() shift ;; esac - echo -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${heads} $@" + echo $echoopt -e "${IWhite}$(date $DATEFORMAT)${DEFAULTFG} ${heads} $@" - unset heads + unset heads echoopt } export -f prnt +# ------------------------------------------------------------------------------ +# Sleep and display a counter (or "the second parameter" every second) +dsleep() +{ + i=$1 + while test $i -gt 0 + do + if [[ -n $2 ]]; then + echo -n "$2" + else + echo -n "${i} " + (( i=i-1 )) + sleep 1 + done + echo +} + # ------------------------------------------------------------------------------ # Dump the keyboard's buffer dump_key_buffer() diff --git a/modules/conf_ntp.sh b/modules/conf_ntp.sh index 4734b32..979a715 100644 --- a/modules/conf_ntp.sh +++ b/modules/conf_ntp.sh @@ -41,8 +41,8 @@ conf_ntp() prnt I "Démarrage du service ntp..." svc_start ntp - prnt I "Attente de 5 secondes pour synchronisation de l'heure..." - sleep 5 + prnt -n I "Attente de 5 secondes pour synchronisation de l'heure" + dsleep 5 ntptime }