The spinner will appear if VERBOSE=False.
Change-Id: I6413decbab2da3996dce5150a4600701eadd6f82
| ... | ... |
@@ -584,10 +584,35 @@ APACHE_GROUP=${APACHE_GROUP:-$APACHE_USER}
|
| 584 | 584 |
# Log files |
| 585 | 585 |
# --------- |
| 586 | 586 |
|
| 587 |
+# Draw a spinner so the user knows something is happening |
|
| 588 |
+function spinner() |
|
| 589 |
+{
|
|
| 590 |
+ local delay=0.75 |
|
| 591 |
+ local spinstr='|/-\' |
|
| 592 |
+ printf "..." >&3 |
|
| 593 |
+ while [ true ]; do |
|
| 594 |
+ local temp=${spinstr#?}
|
|
| 595 |
+ printf "[%c]" "$spinstr" >&3 |
|
| 596 |
+ local spinstr=$temp${spinstr%"$temp"}
|
|
| 597 |
+ sleep $delay |
|
| 598 |
+ printf "\b\b\b" >&3 |
|
| 599 |
+ done |
|
| 600 |
+} |
|
| 601 |
+ |
|
| 587 | 602 |
# Echo text to the log file, summary log file and stdout |
| 588 | 603 |
# echo_summary "something to say" |
| 589 | 604 |
function echo_summary() {
|
| 590 |
- echo $@ >&6 |
|
| 605 |
+ if [[ -t 3 && "$VERBOSE" != "True" ]]; then |
|
| 606 |
+ kill >/dev/null 2>&1 $LAST_SPINNER_PID |
|
| 607 |
+ if [ ! -z "$LAST_SPINNER_PID" ]; then |
|
| 608 |
+ printf "\b\b\bdone\n" >&3 |
|
| 609 |
+ fi |
|
| 610 |
+ echo -n $@ >&6 |
|
| 611 |
+ spinner & |
|
| 612 |
+ LAST_SPINNER_PID=$! |
|
| 613 |
+ else |
|
| 614 |
+ echo $@ >&6 |
|
| 615 |
+ fi |
|
| 591 | 616 |
} |
| 592 | 617 |
|
| 593 | 618 |
# Echo text only to stdout, no log files |
| ... | ... |
@@ -669,10 +694,20 @@ fi |
| 669 | 669 |
# Set Up Script Execution |
| 670 | 670 |
# ----------------------- |
| 671 | 671 |
|
| 672 |
+# Kill background processes on exit |
|
| 673 |
+trap clean EXIT |
|
| 674 |
+clean() {
|
|
| 675 |
+ local r=$? |
|
| 676 |
+ kill >/dev/null 2>&1 $(jobs -p) |
|
| 677 |
+ exit $r |
|
| 678 |
+} |
|
| 679 |
+ |
|
| 680 |
+ |
|
| 672 | 681 |
# Exit on any errors so that errors don't compound |
| 673 | 682 |
trap failed ERR |
| 674 | 683 |
failed() {
|
| 675 | 684 |
local r=$? |
| 685 |
+ kill >/dev/null 2>&1 $(jobs -p) |
|
| 676 | 686 |
set +o xtrace |
| 677 | 687 |
[ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
|
| 678 | 688 |
exit $r |