Skip to content

Instantly share code, notes, and snippets.

@holysugar
Last active August 29, 2015 14:22
Show Gist options
  • Save holysugar/975c3aee9be4d763532a to your computer and use it in GitHub Desktop.
Save holysugar/975c3aee9be4d763532a to your computer and use it in GitHub Desktop.
GCEでタグ情報を環境変数に持ってくる
#!/bin/bash
while read tag; do
upper_tag=${tag^^}
upper_underscore_tag=${upper_tag//-/_}
export GCE_TAG_${upper_underscore_tag}=1
done < <( curl \
-H "X-Google-Metadata-Request: True" \
"http://metadata.google.internal/computeMetadata/v1/instance/tags?alt=text" 2>/dev/null )
# suppress pipelining http://stackoverflow.com/questions/13726764/bash-script-while-loop-subshell-dilemma
# and more
#if [ -n "$GCE_TAG_PRODUCTION" ]; then
# export RAILS_ENV=production
#fi
# ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment