ci-wait-for-server.sh 722 B

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