-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
enclave-manager/web/packages/app/scripts/wait-until-file-exists.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# 2021-07-08 WATERMARK, DO NOT REMOVE - This script was generated from the Kurtosis Bash script template | ||
|
||
set -euo pipefail # Bash "strict mode" | ||
|
||
# ================================================================================================== | ||
# Arg Parsing & Validation | ||
# ================================================================================================== | ||
show_helptext_and_exit() { | ||
echo "Usage: $(basename "${0}") file_name" | ||
echo "" | ||
echo " file_name The file to wait to exist" | ||
echo "" | ||
exit 1 # Exit with an error so that if this is accidentally called by CI, the script will fail | ||
} | ||
|
||
file_name="${1:-}" | ||
|
||
if [ -z "${file_name}" ]; then | ||
echo "Error: No file to wait for provided" >&2 | ||
show_helptext_and_exit | ||
fi | ||
|
||
# ================================================================================================== | ||
# Main Logic | ||
# ================================================================================================== | ||
# Block until the given file appears or the given timeout is reached. | ||
# Exit status is 0 iff the file exists. | ||
wait_file() { | ||
local file="$1"; shift | ||
local wait_seconds="${1:-30}"; shift # 30 seconds as default timeout | ||
test $wait_seconds -lt 1 && echo 'At least 1 second is required' && return 1 | ||
|
||
until test $((wait_seconds--)) -eq 0 -o -e "$file" ; do sleep 1; done | ||
|
||
test $wait_seconds -ge 0 # equivalent: let ++wait_seconds | ||
} | ||
|
||
wait_file "$file_name" 30 | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters