From af4324676797ef2051f423672b15d20648a78ae9 Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Tue, 20 Jan 2009 15:34:38 -0800 Subject: [PATCH] Minor script cleanup --- scripts/zpool-config/hda-raid0.sh | 4 ++-- scripts/zpool-config/lo-raid0.sh | 13 ++++++++----- scripts/zpool-config/sda-raid0.sh | 4 ++-- scripts/zpool-config/x4550-raid0.sh | 4 ++-- scripts/zpool-create.sh | 16 ++++++++-------- 5 files changed, 22 insertions(+), 19 deletions(-) diff --git a/scripts/zpool-config/hda-raid0.sh b/scripts/zpool-config/hda-raid0.sh index 9ddfdb3629..c2bda9cd76 100644 --- a/scripts/zpool-config/hda-raid0.sh +++ b/scripts/zpool-config/hda-raid0.sh @@ -6,11 +6,11 @@ DEVICES="/dev/hda" zpool_create() { - msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + msg ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 } zpool_destroy() { - msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + msg ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} || exit 1 } diff --git a/scripts/zpool-config/lo-raid0.sh b/scripts/zpool-config/lo-raid0.sh index fb40b15868..67beac2d11 100644 --- a/scripts/zpool-config/lo-raid0.sh +++ b/scripts/zpool-config/lo-raid0.sh @@ -8,28 +8,31 @@ DEVICES="/tmp/zpool-vdev0 \ /tmp/zpool-vdev2 \ /tmp/zpool-vdev3 \ /tmp/zpool-vdev4" -DEVICE_SIZE=512 zpool_create() { for DEV in ${DEVICES}; do LO=`/sbin/losetup -f` msg "Creating ${DEV} using loopback device ${LO}" rm -f ${DEV} || exit 1 - dd if=/dev/zero of=${DEV} bs=1024k count=${DEVICE_SIZE} &>/dev/null || exit 1 - losetup ${LO} ${DEV} || exit 1 + dd if=/dev/zero of=${DEV} bs=1024k count=256 status=noxfer &>/dev/null || + die "Error $? creating ${DEV}" + losetup ${LO} ${DEV} || + die "Error $? creating ${DEV} -> ${LO} loopback" done - msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + msg ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 } zpool_destroy() { - msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + msg ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} for DEV in ${DEVICES}; do LO=`/sbin/losetup -a | grep ${DEV} | head -n1 | cut -f1 -d:` msg "Removing ${DEV} using loopback device ${LO}" + losetup -d ${LO} || + die "Error $? destroying ${DEV} -> ${LO} loopback" rm -f ${DEV} || exit 1 done } diff --git a/scripts/zpool-config/sda-raid0.sh b/scripts/zpool-config/sda-raid0.sh index aa43b56517..c54ecd280e 100644 --- a/scripts/zpool-config/sda-raid0.sh +++ b/scripts/zpool-config/sda-raid0.sh @@ -6,11 +6,11 @@ DEVICES="/dev/sda" zpool_create() { - msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + msg ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 } zpool_destroy() { - msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + msg ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} || exit 1 } diff --git a/scripts/zpool-config/x4550-raid0.sh b/scripts/zpool-config/x4550-raid0.sh index 32e608fcef..8007d081d5 100644 --- a/scripts/zpool-config/x4550-raid0.sh +++ b/scripts/zpool-config/x4550-raid0.sh @@ -13,11 +13,11 @@ DEVICES="/dev/sda /dev/sdb /dev/sdc /dev/sdd /dev/sde /dev/sdf \ /dev/sdaq /dev/sdar /dev/sdas /dev/sdat /dev/sdau /dev/sdav" zpool_create() { - msg "${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES}" + msg ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} ${CMDDIR}/zpool/zpool create -f ${ZPOOL_NAME} ${DEVICES} || exit 1 } zpool_destroy() { - msg "${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME}" + msg ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} ${CMDDIR}/zpool/zpool destroy ${ZPOOL_NAME} } diff --git a/scripts/zpool-create.sh b/scripts/zpool-create.sh index fd54d42246..1eca9e036e 100755 --- a/scripts/zpool-create.sh +++ b/scripts/zpool-create.sh @@ -78,16 +78,16 @@ if [ ${ZPOOL_DESTROY} ]; then zpool_destroy else zpool_create -fi -if [ ${VERBOSE} ]; then - echo - echo "zpool list" - ${CMDDIR}/zpool/zpool list || exit 1 + if [ ${VERBOSE} ]; then + echo + echo "zpool list" + ${CMDDIR}/zpool/zpool list || exit 1 - echo - echo "zpool status ${ZPOOL_NAME}" - ${CMDDIR}/zpool/zpool status ${ZPOOL_NAME} || exit 1 + echo + echo "zpool status ${ZPOOL_NAME}" + ${CMDDIR}/zpool/zpool status ${ZPOOL_NAME} || exit 1 + fi fi exit 0