Advertisement
pintcat

start.sh - Intercepts the progress output of wait.sh & draws a progress bar. For testing purposes.

Dec 25th, 2022 (edited)
1,172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.69 KB | Software | 0 0
  1. #!/bin/sh
  2.  
  3. . progress.sh
  4.  
  5. TMP=/media/ramdisk/log_$(date +%y%m%d%H%M%S%3N)
  6.  
  7. PROGRESS_R1=" "
  8. PROGRESS_ML=9
  9. PROGRESS_FT=D
  10. PROGRESS_TPOS=T
  11. PROGRESS_MAX1=1000
  12. PROGRESS_TC=5
  13. COUNT=0
  14.  
  15. PROGRESS_BAR
  16. [ -z "${1##*[!0-9]*}" ] || PROGRESS_MAX1=$1
  17. wait.sh $PROGRESS_MAX1 > $TMP &
  18. while [ $((COUNT=$COUNT+1)) -lt $PROGRESS_NLIN ]; do echo; done
  19. printf Progress:"\033["$(($PROGRESS_NLIN-1))"A\r"
  20. while [ -n "$(pgrep wait.sh)" ]; do
  21.     sleep 0.05s
  22.     if ! PROGRESS_BAR $(tail -c$((${#PROGRESS_MAX1}+2)) $TMP | sed 's/[^0-9]*//g'); then
  23.         echo "ERROR!"
  24.         exit 1
  25.     fi
  26. done
  27. PROGRESS_BAR $PROGRESS_MAX1
  28. rm -f $TMP
  29. #while [ $((COUNT=$COUNT-1)) -eq 0 ]; do echo; done
  30. printf "\033["$PROGRESS_NLIN"B\n"
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement