wait-for-server.sh 622 B

123456789101112131415161718192021222324252627282930313233
  1. #!/usr/bin/env bash
  2. # Based on the script from Milen Pivchev in nextcloud/ios repository
  3. # This scripts waits until a server transitions to the "installed" state
  4. SERVER_PORT=8080
  5. SERVER_URL="http://localhost:${SERVER_PORT}"
  6. timeout=2000
  7. elapsed=0
  8. echo "Waiting for server..."
  9. sleep 5
  10. while true; do
  11. content=$(curl -s $SERVER_URL/status.php || true)
  12. if [[ $content == *"installed\":true"* ]]; then
  13. break
  14. fi
  15. elapsed=$((elapsed + 1))
  16. if [ $elapsed -ge $timeout ]; then
  17. echo "No success after $timeout seconds."
  18. exit 1
  19. fi
  20. sleep 1
  21. done
  22. echo "Server is installed."