Last active
May 21, 2018 03:42
-
-
Save sinmetal/2f550aa6530d82e4c1a1b3186c3f9d88 to your computer and use it in GitHub Desktop.
適当にコマンドを実行し、自ら死ぬインスタンスを生成するstartup-script
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
#!/bin/bash | |
# Install google-fluentd | |
curl -sSO https://dl.google.com/cloudagents/install-logging-agent.sh | |
sha256sum install-logging-agent.sh | |
sudo bash install-logging-agent.sh | |
# Restart google-fluentd | |
service google-fluentd restart | |
# Your Task | |
echo "Start Task!" | |
echo "DONE Task!" | |
# Delete Me | |
INSTANCE_NAME=$(curl http://metadata/computeMetadata/v1/instance/name -H "Metadata-Flavor: Google") | |
INSTANCE_ZONE=$(curl http://metadata/computeMetadata/v1/instance/zone -H "Metadata-Flavor: Google") | |
IFS='/' | |
set -- $INSTANCE_ZONE | |
INSTANCE_ZONE=$4 | |
echo $INSTANCE_ZONE | |
yes | gcloud compute instances delete $INSTANCE_NAME --zone $INSTANCE_ZONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最も小さいインスタンスで、全てのScopeを与えたインスタンスを利用する場合のcommand