diff --git a/install_iomatex_edge.sh b/install_iomatex_edge.sh index fafe354..e6f4c3a 100755 --- a/install_iomatex_edge.sh +++ b/install_iomatex_edge.sh @@ -36,22 +36,24 @@ spinner() { local elapsed=0 local last_heartbeat=0 local spinner_tty=0 + local spinner_tty_path="" start_ts="$(date +%s)" - if [[ -w /dev/tty ]]; then + spinner_tty_path="$(tty 2>/dev/null || true)" + if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then spinner_tty=1 fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput civis >/dev/tty 2>/dev/null || true + tput civis >"$spinner_tty_path" 2>/dev/null || true fi while kill -0 "$pid" 2>/dev/null; do i=$(((i + 1) % 4)) elapsed=$(( $(date +%s) - start_ts )) if [[ "$spinner_tty" -eq 1 ]]; then - printf '\r[%c] %s... %ss' "${spin:$i:1}" "$msg" "$elapsed" >/dev/tty + printf '\r[%c] %s... %ss' "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path" fi if (( elapsed >= last_heartbeat + 15 )); then log "HEARTBEAT: ${msg} still running (${elapsed}s)" @@ -61,20 +63,20 @@ spinner() { done if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput cnorm >/dev/tty 2>/dev/null || true + tput cnorm >"$spinner_tty_path" 2>/dev/null || true fi wait "$pid" local rc=$? if [[ "$rc" -eq 0 ]]; then if [[ "$spinner_tty" -eq 1 ]]; then - printf '\r[OK] %s. \n' "$msg" >/dev/tty + printf '\r[OK] %s. \n' "$msg" >"$spinner_tty_path" else echo "[OK] $msg" fi else if [[ "$spinner_tty" -eq 1 ]]; then - printf '\r[FAIL:%s] %s. \n' "$rc" "$msg" >/dev/tty + printf '\r[FAIL:%s] %s. \n' "$rc" "$msg" >"$spinner_tty_path" else echo "[FAIL:$rc] $msg" fi diff --git a/stage_env/stage_env_install_no_pulse.sh b/stage_env/stage_env_install_no_pulse.sh index 7bb1297..f55239a 100644 --- a/stage_env/stage_env_install_no_pulse.sh +++ b/stage_env/stage_env_install_no_pulse.sh @@ -464,22 +464,24 @@ spinner() { local elapsed=0 local last_heartbeat=0 local spinner_tty=0 + local spinner_tty_path="" start_ts="$(date +%s)" - if [[ -w /dev/tty ]]; then + spinner_tty_path="$(tty 2>/dev/null || true)" + if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then spinner_tty=1 fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput civis >/dev/tty 2>/dev/null || true + tput civis >"$spinner_tty_path" 2>/dev/null || true fi while kill -0 "$pid" 2>/dev/null; do i=$(((i+1) % 4)) elapsed=$(( $(date +%s) - start_ts )) if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >/dev/tty + printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path" fi if (( elapsed >= last_heartbeat + 15 )); then log "HEARTBEAT: ${msg} still running (${elapsed}s)" @@ -489,10 +491,10 @@ spinner() { done if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r%-80s\r" "" >/dev/tty + printf "\r%-80s\r" "" >"$spinner_tty_path" fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput cnorm >/dev/tty 2>/dev/null || true + tput cnorm >"$spinner_tty_path" 2>/dev/null || true fi } @@ -507,6 +509,7 @@ run_long() { local elapsed=0 local last_heartbeat=0 local spinner_tty=0 + local spinner_tty_path="" local timed_out=0 shift 2 @@ -516,12 +519,13 @@ run_long() { pid=$! start_ts="$(date +%s)" - if [[ -w /dev/tty ]]; then + spinner_tty_path="$(tty 2>/dev/null || true)" + if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then spinner_tty=1 fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput civis >/dev/tty 2>/dev/null || true + tput civis >"$spinner_tty_path" 2>/dev/null || true fi while kill -0 "$pid" 2>/dev/null; do @@ -529,7 +533,7 @@ run_long() { elapsed=$(( $(date +%s) - start_ts )) if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >/dev/tty + printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path" fi if (( elapsed >= last_heartbeat + 15 )); then @@ -550,10 +554,10 @@ run_long() { done if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r%-80s\r" "" >/dev/tty + printf "\r%-80s\r" "" >"$spinner_tty_path" fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput cnorm >/dev/tty 2>/dev/null || true + tput cnorm >"$spinner_tty_path" 2>/dev/null || true fi if wait "$pid"; then diff --git a/stage_itscreen/stage_itscreen_install.sh b/stage_itscreen/stage_itscreen_install.sh index d465a8b..678d2e1 100755 --- a/stage_itscreen/stage_itscreen_install.sh +++ b/stage_itscreen/stage_itscreen_install.sh @@ -233,6 +233,7 @@ run_long() { local elapsed=0 local last_heartbeat=0 local spinner_tty=0 + local spinner_tty_path="" local timed_out=0 shift 2 @@ -242,12 +243,13 @@ run_long() { pid=$! start_ts="$(date +%s)" - if [[ -w /dev/tty ]]; then + spinner_tty_path="$(tty 2>/dev/null || true)" + if [[ -n "$spinner_tty_path" && "$spinner_tty_path" != "not a tty" && -w "$spinner_tty_path" ]]; then spinner_tty=1 fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput civis >/dev/tty 2>/dev/null || true + tput civis >"$spinner_tty_path" 2>/dev/null || true fi while kill -0 "$pid" 2>/dev/null; do @@ -255,7 +257,7 @@ run_long() { elapsed=$(( $(date +%s) - start_ts )) if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >/dev/tty + printf "\r[%c] %s... %ss" "${spin:$i:1}" "$msg" "$elapsed" >"$spinner_tty_path" fi if (( elapsed >= last_heartbeat + 15 )); then @@ -276,10 +278,10 @@ run_long() { done if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r%-80s\r" "" >/dev/tty + printf "\r%-80s\r" "" >"$spinner_tty_path" fi if command -v tput >/dev/null 2>&1 && [[ "$spinner_tty" -eq 1 ]]; then - tput cnorm >/dev/tty 2>/dev/null || true + tput cnorm >"$spinner_tty_path" 2>/dev/null || true fi wait "$pid" @@ -290,13 +292,13 @@ run_long() { if [[ "$rc" -eq 0 ]]; then if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r[OK] %s. \n" "$msg" >/dev/tty + printf "\r[OK] %s. \n" "$msg" >"$spinner_tty_path" else echo "[OK] $msg" fi else if [[ "$spinner_tty" -eq 1 ]]; then - printf "\r[FAIL:%s] %s. \n" "$rc" "$msg" >/dev/tty + printf "\r[FAIL:%s] %s. \n" "$rc" "$msg" >"$spinner_tty_path" else echo "[FAIL:$rc] $msg" fi