Shell fixes

This commit is contained in:
Héctor Molinero Fernández 2021-01-23 15:05:17 +01:00
parent 029d3be29c
commit 4375f49afc

View File

@ -3,7 +3,7 @@
set -eu set -eu
export LC_ALL=C export LC_ALL=C
SRC_DIR=$(dirname "$(dirname "$(readlink -f "$0")")") SRC_DIR=$(CDPATH='' cd -- "$(dirname -- "${0:?}")" && pwd -P)
TMP_DIR=$(mktemp -d) TMP_DIR=$(mktemp -d)
ORIGINAL_DISK=${SRC_DIR:?}/dist/qemu/wireguard.qcow2 ORIGINAL_DISK=${SRC_DIR:?}/dist/qemu/wireguard.qcow2
@ -13,7 +13,8 @@ USERDATA_YAML=${SRC_DIR:?}/qemu/http/seed/user-data
USERDATA_DISK=${TMP_DIR:?}/seed.img USERDATA_DISK=${TMP_DIR:?}/seed.img
# Remove temporary files on exit # Remove temporary files on exit
trap 'rm -rf "${TMP_DIR:?}"; trap - EXIT; exit 0' EXIT TERM INT HUP # shellcheck disable=SC2154
trap 'ret="$?"; rm -rf -- "${TMP_DIR:?}"; trap - EXIT; exit "${ret:?}"' EXIT TERM INT HUP
# Create a snapshot image to preserve the original image # Create a snapshot image to preserve the original image
qemu-img create -b "${ORIGINAL_DISK:?}" -f qcow2 "${SNAPSHOT_DISK:?}" qemu-img create -b "${ORIGINAL_DISK:?}" -f qcow2 "${SNAPSHOT_DISK:?}"