commit 3ec8308c84a5122349a7fb21f55167ca9a0b9b3a parent e44890cfdd4875cea1040c85badc1d99561185d9 Author: Jan Pobrislo <ccx@webprojekty.cz> Date: Fri, 25 Oct 2013 20:35:49 +0200 better error handling Diffstat:
| M | snapshot.lvm2 | | | 16 | ++++++++++------ |
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/snapshot.lvm2 b/snapshot.lvm2 @@ -16,16 +16,20 @@ if test -b "$S_DEV"; then if grep -qF "$S_DEV"; then # TODO match only on start of line umount $S_DEV || exit $? fi - lvremove -f "$S_DEV" + lvremove -f "$S_DEV" || exit $? fi if test -d "$SNAPSHOT"; then # make sure it's empty and unused - rmdir "$SNAPSHOT" + rmdir "$SNAPSHOT" || exit $? fi -echo $$ >"$LOCKFILE" -mkdir -p "$SNAPSHOT" -lvcreate -n "${SRC##*/}.snaprep" -L "${SNAPSHOT_SIZE:-10G}" -s "$SRC" -mount "$S_DEV" "$SNAPSHOT" +echo $$ >"$LOCKFILE" || exit $? +mkdir -p "$SNAPSHOT" || exit $? +lvcreate -n "${SRC##*/}.snaprep" -L "${SNAPSHOT_SIZE:-10G}" -s "$SRC" || exit $? +die_lvremove() { + lvremove -f "$S_VOL" + exit $? +} +mount "$S_DEV" "$SNAPSHOT" || die_lvremove $? "$@" RETCODE=$? umount "$SNAPSHOT"