Skip to content

Instantly share code, notes, and snippets.

@maelvls
Last active November 30, 2022 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maelvls/dbb7b6f6cb3f6f9844e7468d619c5490 to your computer and use it in GitHub Desktop.
Save maelvls/dbb7b6f6cb3f6f9844e7468d619c5490 to your computer and use it in GitHub Desktop.

Tired of having to wait for Cloudshare's progress bar to fill up? Here is a script that does it for you.

2022-11-30 15 27 23

#! /bin/bash
set -euo pipefail
if [ $# -ne 1 ]; then
echo "Usage: $0 <cloudshare-tpp-url>"
exit 1
fi
url="$1"
redirect_url="$(curl -sS -w "%{redirect_url}" "$url" -o/dev/null)"
if [[ "$redirect_url" = "" ]]; then
echo "Machine is ready"
exit 0
fi
machine="$(sed -e 's/^.*m=\([^&]*\).*/\1/' <<<"$redirect_url")"
echo "Machine is not ready, waiting for $machine (refreshing every second)"
while true; do
json=$(curl -sS "https://use.cloudshare.com/api/v3/unauthenticated/httpAccess/machine/$machine")
progress=$(jq -r .progress <<<"$json") || echo "$json" >&2
if [[ "$progress" = "100" ]]; then
echo "Machine is ready"
exit 0
fi
printf "Progress: %s%%\r" "$progress"
sleep 1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment