two-images: gardes en if explicites, shellcheck propre en 0.10 comme en 0.11 syonad/two#53
All checks were successful
Tests / check (push) Successful in 38s
All checks were successful
Tests / check (push) Successful in 38s
Signed-off-by: GnomeZworc <nicolas.boufidjeline@g3e.fr>
This commit is contained in:
parent
fe401b9a12
commit
085882aa2b
2 changed files with 15 additions and 5 deletions
|
|
@ -57,8 +57,12 @@ mount_target () {
|
|||
mount --bind /sys /mnt/sys
|
||||
}
|
||||
|
||||
[ -n "${FAMILY:-}" ] && [ -n "${IMAGE_URL:-}" ] && [ -n "${IMAGE_CHECKSUM:-}" ] || die "FAMILY, IMAGE_URL, IMAGE_CHECKSUM requis"
|
||||
[ "${TARGET_BYTES:-0}" -gt 0 ] && [ "${WORK_BYTES:-0}" -gt 0 ] || die "TARGET_BYTES et WORK_BYTES requis"
|
||||
if [ -z "${FAMILY:-}" ] || [ -z "${IMAGE_URL:-}" ] || [ -z "${IMAGE_CHECKSUM:-}" ]; then
|
||||
die "FAMILY, IMAGE_URL, IMAGE_CHECKSUM requis"
|
||||
fi
|
||||
if [ "${TARGET_BYTES:-0}" -le 0 ] || [ "${WORK_BYTES:-0}" -le 0 ]; then
|
||||
die "TARGET_BYTES et WORK_BYTES requis"
|
||||
fi
|
||||
[ "${TARGET_BYTES}" -ne "${WORK_BYTES}" ] || die "disque cible et disque de travail de même taille : impossible de les distinguer"
|
||||
|
||||
wait_cloud_init
|
||||
|
|
@ -69,7 +73,9 @@ install_tools
|
|||
TARGET=$(disk_of_size "${TARGET_BYTES}")
|
||||
WORK=$(disk_of_size "${WORK_BYTES}")
|
||||
ROOT_DISK=/dev/$(lsblk -nro PKNAME "$(findmnt -nro SOURCE /)")
|
||||
[ "${TARGET}" != "${ROOT_DISK}" ] && [ "${WORK}" != "${ROOT_DISK}" ] || die "le disque système a la taille d'un disque de construction"
|
||||
if [ "${TARGET}" = "${ROOT_DISK}" ] || [ "${WORK}" = "${ROOT_DISK}" ]; then
|
||||
die "le disque système a la taille d'un disque de construction"
|
||||
fi
|
||||
assert_blank "${TARGET}"
|
||||
assert_blank "${WORK}"
|
||||
echo "== cible ${TARGET}, travail ${WORK}, système ${ROOT_DISK}"
|
||||
|
|
@ -81,7 +87,9 @@ curl -fsSL -o /work/source.qcow2 "${IMAGE_URL}"
|
|||
ALGO=${IMAGE_CHECKSUM%%:*}
|
||||
echo "${IMAGE_CHECKSUM#*:} /work/source.qcow2" | "${ALGO}sum" -c --quiet - || die "somme ${ALGO} de l'image incorrecte"
|
||||
VSIZE=$(qemu-img info --output=json /work/source.qcow2 | python3 -c 'import json, sys; print(json.load(sys.stdin)["virtual-size"])')
|
||||
[ -n "${VSIZE}" ] && [ "${VSIZE}" -le "${TARGET_BYTES}" ] || die "taille virtuelle de l'image (${VSIZE:-illisible}) supérieure au disque cible"
|
||||
if [ -z "${VSIZE}" ] || [ "${VSIZE}" -gt "${TARGET_BYTES}" ]; then
|
||||
die "taille virtuelle de l'image (${VSIZE:-illisible}) supérieure au disque cible"
|
||||
fi
|
||||
qemu-img convert -n --target-is-zero -f qcow2 -O raw /work/source.qcow2 "${TARGET}"
|
||||
umount /work
|
||||
blockdev --rereadpt "${TARGET}"
|
||||
|
|
|
|||
4
test.sh
4
test.sh
|
|
@ -132,7 +132,9 @@ cloud_init_done () {
|
|||
}
|
||||
|
||||
image="${1:-}"
|
||||
[ -n "${image}" ] && [ -f "${DIST}/${image}.qcow2" ] || die "usage : ${0} <image> (fichier ${DIST}/<image>.qcow2)"
|
||||
if [ -z "${image}" ] || [ ! -f "${DIST}/${image}.qcow2" ]; then
|
||||
die "usage : ${0} <image> (fichier ${DIST}/<image>.qcow2)"
|
||||
fi
|
||||
RUN=$(mktemp -d "${TMPDIR:-/tmp}/two-images-test.XXXXXX")
|
||||
trap cleanup EXIT
|
||||
mkdir "${RUN}/seed"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue