Last active
November 24, 2015 06:43
-
-
Save wappy100/2b27f12e8f7184c4bfd6 to your computer and use it in GitHub Desktop.
bashでのニフクラAPIアクセス
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/sh | |
| ACCESSKEY="" | |
| SECRETKEY="" | |
| DATE=`LANG=en_US.UTF-8 /bin/date -u '+%Y-%m-%dT%H:%M:%SZ'` | |
| STS=${ACTION}${DATE} | |
| STSUTF8=`/bin/echo -en "${STS_HEAD}" | /usr/bin/iconv -t UTF-8` | |
| SIGNATURE=$(/bin/echo -n "${STS}" | /usr/bin/openssl dgst -sha1 -binary -hmac "${SECRETKEY}" | /usr/bin/openssl base64) | |
| # DescribeInstances | |
| ACTION="DescribeInstances" | |
| echo `curl "https://west-1.cp.cloud.nifty.com/api/" -v --get \ | |
| --data-urlencode Action=${ACTION} \ | |
| --data-urlencode AccessKeyId=${ACCESSKEY} \ | |
| --data-urlencode Timestamp=${DATE} \ | |
| --data-urlencode SignatureVersion=0 \ | |
| --data-urlencode Signature=${SIGNATURE}` | |
| # RebootInstances | |
| ACTION="RebootInstances" | |
| INSTANCEID="hostname" | |
| echo `curl "https://west-1.cp.cloud.nifty.com/api/" -v --get \ | |
| --data-urlencode Action=${ACTION} \ | |
| --data-urlencode InstanceId.1=${INSTANCEID} \ | |
| --data-urlencode AccessKeyId=${ACCESSKEY} \ | |
| --data-urlencode Timestamp=${DATE} \ | |
| --data-urlencode SignatureVersion=0 \ | |
| --data-urlencode Signature=${SIGNATURE}` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment