Last active
August 29, 2015 14:22
-
-
Save holysugar/975c3aee9be4d763532a to your computer and use it in GitHub Desktop.
GCEでタグ情報を環境変数に持ってくる
This file contains hidden or 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
#!/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