This is a slowly growing collection of hopefully useful and reusable shell functions and patterns. https://code.jan.io/jan/jans_shell_utils
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

wait_for_url.sh 698B

il y a 3 ans
il y a 3 ans
il y a 3 ans
1234567891011121314151617181920212223242526
  1. . ./lib.sh
  2. wait_for_url () {
  3. assert_arg "$1" && url="$1" || error_and_exit "url not provided, exiting"
  4. assert_arg "$2" && iterations="$2" || iterations=3
  5. assert_arg "$3" && duration="$3" || duration=1
  6. debug "called wait_for_url(url=$url, duration=$duration, iterations=$iterations)"
  7. waiting=0
  8. cmd="curl --output /dev/null --silent --insecure --head --fail --max-time 2 $url"
  9. debug_inline "waiting for $url "
  10. until ($cmd); do
  11. if [ $waiting -eq $iterations ]; then
  12. let after=$duration*iterations
  13. debug_inline "failed, $url can not be reached after $after seconds\n"
  14. return 1
  15. fi
  16. debug_inline .
  17. let waiting=waiting+1
  18. sleep $duration
  19. done
  20. debug_inline " succeeded\n"
  21. }