Skip to content

Commit

Permalink
install-chef-suse: Allow stopping spinner with specific message
Browse files Browse the repository at this point in the history
It can be "failed", and not simply "done".

Also stop spinner at the end.
  • Loading branch information
vuntz committed May 29, 2013
1 parent 06c2019 commit 01455db
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions releases/pebbles/master/extra/install-chef-suse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,19 @@ spinner () {
kill_spinner () {
if [ ! -z "$LAST_SPINNER_PID" ]; then
kill >/dev/null 2>&1 $LAST_SPINNER_PID
printf "\b\b\bdone\n" >&3
if [ $# -eq 0 ]; then
printf "\b\b\bdone\n" >&3
else
printf "\b\b\b$*\n" >&3
fi
unset LAST_SPINNER_PID
fi
}

kill_spinner_with_failed () {
kill_spinner "failed"
}

echo_log () {
echo -e === "$(date '+%F %T %z'): $@" >&4
}
Expand Down Expand Up @@ -113,7 +121,7 @@ die() {
echo >&4
echo_log "Error: $@"

kill_spinner
kill_spinner_with_failed

echo >&3
echo -e "Error: $@" >&3
Expand All @@ -123,11 +131,8 @@ die() {
}

exit_handler () {
if [ ! -z "$LAST_SPINNER_PID" ]; then
kill >/dev/null 2>&1 $LAST_SPINNER_PID
fi

if [ -z "$run_succeeded" ]; then
kill_spinner_with_failed
cat <<EOF | pipe_stdout_and_logfile
Crowbar installation terminated prematurely. Please examine the above
Expand All @@ -136,6 +141,8 @@ You should also check the SUSE Cloud Installation Manual, in
particular the Troubleshooting section. Note that this script can
safely be re-run multiple times if required.
EOF
else
kill_spinner
fi
}

Expand Down Expand Up @@ -712,6 +719,8 @@ echo_summary_no_spinner ""

touch /opt/dell/crowbar_framework/.crowbar-installed-ok

kill_spinner

cat <<EOF | pipe_stdout_and_logfile
Admin node deployed.
Expand Down

0 comments on commit 01455db

Please sign in to comment.