wait_for_server.sh 619 B

123456789101112131415161718192021222324
  1. #!/usr/bin/env bash
  2. # SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
  3. # SPDX-FileCopyrightText: 2019-2020 Tobias Kaminsky <tobias@kaminsky.me>
  4. # SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only
  5. counter=0
  6. status=""
  7. until [[ $status = "false" ]]; do
  8. status=$(curl 2>/dev/null "http://$1/status.php" | jq .maintenance)
  9. echo "($counter) $status"
  10. if [[ "$status" =~ "false" || "$status" = "" ]]; then
  11. let "counter += 1"
  12. if [[ $counter -gt 50 ]]; then
  13. echo "Failed to wait for server"
  14. exit 1
  15. fi
  16. fi
  17. sleep 10
  18. done