Support --ami and --instance-id options

changes/46/546/1
Michael Prokop 12 years ago
parent bd4745bc89
commit cbcc07d066

@ -15,17 +15,18 @@ usage() {
Usage:
$0 <AMI_ID>
$0 --ami <AMI_ID> [<OPTIONS>]
Supported OPTIONS:
--ami <AMI_ID> mark AMI_ID as public
--help display this help text
--region <REGION> specify region that should be used
(if unset defaults to the eu-west-1 zone)
"
}
CMDLINE_OPTS=help,region:
CMDLINE_OPTS=ami:,help,region:
_opt_temp=$(getopt --name $0 -o +bch --long $CMDLINE_OPTS -- "$@")
if [ $? -ne 0 ]; then
@ -38,6 +39,9 @@ _opt_public=false
while :; do
case "$1" in
--ami)
shift; AMI_ID="$1"
;;
--help)
usage ; exit 0;
;;
@ -84,13 +88,11 @@ if ! check4progs ec2-modify-image-attribute ; then
exit 1
fi
if [ $# -lt 1 ] ; then
if [ -z "$AMI_ID" ] ; then
usage >&2
exit 1
fi
AMI_ID="$1"
echo "Marking AMI $AMI_ID as public"
ec2-modify-image-attribute --region "$AWS_REGION" "$AMI_ID" --launch-permission -a all
if [ $? -ne 0 ] ; then

@ -20,13 +20,14 @@ Usage:
Supported OPTIONS:
--help display this help text
--instance-id <ID> operate on specified instance ID
--region <REGION> specify region that should be used
(if unset defaults to the eu-west-1 zone)
--terminate terminate instead of just stopping the instance
"
}
CMDLINE_OPTS=help,region:,terminate
CMDLINE_OPTS=help,instance-id:,region:,terminate
_opt_temp=$(getopt --name $0 -o +bch --long $CMDLINE_OPTS -- "$@")
if [ $? -ne 0 ]; then
@ -43,6 +44,9 @@ while :; do
--help)
usage ; exit 0;
;;
--instance-id)
shift; INSTANCE_ID="$1"
;;
--region)
shift; AWS_REGION="$1"
;;
@ -89,13 +93,11 @@ if ! check4progs ec2-stop-instances ; then
exit 1
fi
if [ $# -lt 1 ] ; then
if [ -z "$INSTANCE_ID" ] ; then
usage >&2
exit 1
fi
INSTANCE_ID="$1"
if $_opt_terminate ; then
echo "Terminating instance ID $INSTANCE_ID (as requested via --terminate)"
ec2-terminate-instances --region "$AWS_REGION" "$INSTANCE_ID"

Loading…
Cancel
Save