From d66d5cfa79e01ba5fa1466b84b14c2e6892a8fbd Mon Sep 17 00:00:00 2001 From: Daniel Hansson Date: Mon, 15 Oct 2018 22:04:27 +0200 Subject: [PATCH] add countdown (#691) --- apps/fulltextsearch.sh | 10 ++-------- lib.sh | 11 +++++++++++ nextcloud_update.sh | 6 ++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/apps/fulltextsearch.sh b/apps/fulltextsearch.sh index a3e6c7b9d5..4003b5d6a7 100644 --- a/apps/fulltextsearch.sh +++ b/apps/fulltextsearch.sh @@ -107,15 +107,9 @@ docker run -d --restart always \ -e "discovery.type=single-node" \ -i -t $nc_fts +# Wait for bootstraping docker restart $fts_es_name - -echo "Waiting for docker bootstraping..." -secs=$((20)) -while [ $secs -gt 0 ]; do - echo -ne "$secs\033[0K\r" - sleep 1 - : $((secs--)) -done +countdown "Waiting for docker bootstraping..." "20" docker logs $fts_es_name # Get Full Text Search app for nextcloud diff --git a/lib.sh b/lib.sh index 86205da306..1cf2658ef9 100644 --- a/lib.sh +++ b/lib.sh @@ -824,6 +824,17 @@ You will be given the option to abort when you hit OK." fi } +# countdown 'message looks like this' 10 +countdown() { +echo "$1" +secs="$(($2))" +while [ $secs -gt 0 ]; do + echo -ne "$secs\033[0K\r" + sleep 1 + : $((secs--)) +done +} + ## bash colors # Reset Color_Off='\e[0m' # Text Reset diff --git a/nextcloud_update.sh b/nextcloud_update.sh index 04a7c20777..7e8a86ded3 100644 --- a/nextcloud_update.sh +++ b/nextcloud_update.sh @@ -173,9 +173,7 @@ else rm -f "$STABLEVERSION.tar.bz2" fi -echo "Backing up files and upgrading to Nextcloud $NCVERSION in 10 seconds..." -echo "Press CTRL+C to abort." -sleep 10 +countdown "Backing up files and upgrading to Nextcloud $NCVERSION in 10 seconds... Press CTRL+C to abort." "10" # Stop Apache2 check_command service apache2 stop @@ -313,7 +311,7 @@ then echo printf "${Green}All files are backed up.${Color_Off}\n" occ_command maintenance:mode --on - echo "Removing old Nextcloud instance in 5 seconds..." && sleep 5 + countdown "Removing old Nextcloud instance in 5 seconds..." "5" rm -rf $NCPATH tar -xjf "$HTML/$STABLEVERSION.tar.bz2" -C "$HTML" rm "$HTML/$STABLEVERSION.tar.bz2"