Beef up error handling (#886666)
This commit is contained in:
parent
49946a14b5
commit
43392f74b8
@ -14,6 +14,9 @@ MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
|
|||||||
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
|
||||||
|
|
||||||
|
# exit on error to stop unexpected errors
|
||||||
|
set -o errexit
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "Usage: $0 - Prepare Ubuntu images"
|
echo "Usage: $0 - Prepare Ubuntu images"
|
||||||
echo ""
|
echo ""
|
||||||
@ -44,6 +47,14 @@ cleanup() {
|
|||||||
trap 2; kill -2 $$
|
trap 2; kill -2 $$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# apt-get wrapper to just get arguments set correctly
|
||||||
|
function apt_get() {
|
||||||
|
local sudo="sudo"
|
||||||
|
[ "$(id -u)" = "0" ] && sudo="env"
|
||||||
|
$sudo DEBIAN_FRONTEND=noninteractive apt-get \
|
||||||
|
--option "Dpkg::Options::=--force-confold" --assume-yes "$@"
|
||||||
|
}
|
||||||
|
|
||||||
while getopts f:hmr: c; do
|
while getopts f:hmr: c; do
|
||||||
case $c in
|
case $c in
|
||||||
f) FORMAT=$OPTARG
|
f) FORMAT=$OPTARG
|
||||||
@ -107,7 +118,14 @@ case $DIST_NAME in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
trap cleanup SIGHUP SIGINT SIGTERM
|
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT
|
||||||
|
|
||||||
|
# Check for dependencies
|
||||||
|
|
||||||
|
if [ ! -x "`which qemu-img`" -o ! -x "`which qemu-nbd`" ]; then
|
||||||
|
# Missing KVM?
|
||||||
|
apt_get install qemu-kvm
|
||||||
|
fi
|
||||||
|
|
||||||
# Prepare the base image
|
# Prepare the base image
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user