Minor script cleanup

This commit is contained in:
Brian Behlendorf 2009-01-20 15:34:38 -08:00
parent 5ae334d138
commit af43246767
5 changed files with 22 additions and 19 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -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}
}

View File

@ -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