1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/bash
# vi: ts=4 noexpandtab
error() { echo "$@" 1>&2; }
errorp() { printf "$@" 1>&2; }
fail() { [ $# -eq 0 ] || error "$@"; exit 1; }
failp() { [ $# -eq 0 ] || errorp "$@"; exit 1; }
debug() {
local level=${1}
shift;
[ "${level}" -gt "${VERBOSITY}" ] && return
echo "$(date): ${@}" 1>&2
}
Usage() {
cat <<EOF
Usage: ${0##*/} [ options ] publish-info.txt
remove (unregister and delete) builds listed in publish-info.txt
published-info.txt is formated space delimited:
region id arch img_type manifest
This utility will silently skip kernel or ramdisks that are used by
other public AMIs.
Options:
-n | --dry-run only report what would be done
-v | --verbose increase verbosity
EOF
}
bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; exit 1; }
short_opts="nv"
long_opts="dry-run,verbose"
getopt_out=$(getopt --name "${0##*/}" \
--options "${short_opts}" --long "${long_opts}" -- "$@") &&
eval set -- "${getopt_out}" ||
bad_Usage
VERBOSITY=0
dry_run=0
while [ $# -ne 0 ]; do
cur=${1}; next=${2};
case "$cur" in
--) shift; break;;
-n|--dry-run) dry_run=1;;
-v|--verbose)
VERBOSITY=$((${VERBOSITY}+1));;
-*) bad_Usage "confused by ${cur}";;
esac
shift;
done
info=${1}
[ $# -gt 1 ] && bad_Usage "to many arguments given"
[ $# -lt 1 ] && bad_Usage "must provide publish-info.txt"
[ -f "${info}" ] || bad_usage "${info}: not a file"
echo "this tool is not written. please see remove-image"
exit 1
|