Reports startup script exit status to a GCE guest attribute so the controller
waits for completion before launching the agent. The snippet receives the exit code
as $1 and must PUT it to:
http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/startup-script/status
Clear this field to disable waiting.
The default uses curl, which is widely available across Linux environments.
Any tool capable of an HTTP PUT to the URL above will work.
Keep $1 as the exit code placeholder.
Alternative examples:
bash /dev/tcp (no external tools):
exec 3<>/dev/tcp/metadata.google.internal/80
printf "PUT /computeMetadata/v1/instance/guest-attributes/startup-script/status HTTP/1.0\r\nHost: metadata.google.internal\r\nMetadata-Flavor: Google\r\nContent-Length: ${#1}\r\n\r\n$1" >&3
exec 3>&-
wget:
wget -q --method=PUT --header="Metadata-Flavor: Google" --body-data="$1" \ "http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/startup-script/status" -O /dev/null
python3:
python3 -c "import urllib.request; urllib.request.urlopen(urllib.request.Request( \
'http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/startup-script/status', \
data=b'$1', headers={'Metadata-Flavor':'Google'}, method='PUT'))"