~philroche/ubuntu-on-ec2/ec2-publishing-scripts-kernel-panic-revert

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