zfs/scripts/zpool-create.sh

79 lines
1.1 KiB
Bash
Raw Normal View History

2008-12-05 17:46:11 +00:00
#!/bin/bash
. ./common.sh
2009-01-16 21:57:12 +00:00
PROG=zpool-create.sh
2008-12-05 17:46:11 +00:00
usage() {
cat << EOF
USAGE:
$0 [hvcp]
DESCRIPTION:
Create one of several predefined zpool configurations.
OPTIONS:
-h Show this message
-v Verbose
-c Zpool configuration
-p Zpool name
EOF
}
check_config() {
if [ ! -f ${ZPOOL_CONFIG} ]; then
local NAME=`basename ${ZPOOL_CONFIG} .cfg`
ERROR="Unknown config '${NAME}', available configs are:\n"
for CFG in `ls ${TOPDIR}/scripts/zpool-config/`; do
local NAME=`basename ${CFG} .cfg`
ERROR="${ERROR}${NAME}\n"
done
return 1
fi
return 0
}
ZPOOL_CONFIG=zpool_config.cfg
ZPOOL_NAME=tank
while getopts 'hvc:p:' OPTION; do
case $OPTION in
h)
usage
exit 1
;;
v)
VERBOSE=1
;;
c)
2009-01-16 21:57:12 +00:00
ZPOOL_CONFIG=${TOPDIR}/scripts/zpool-config/${OPTARG}.cfg
;;
p)
ZPOOL_NAME=${OPTARG}
;;
?)
usage
exit
;;
esac
done
check_config || die "${ERROR}"
. ${ZPOOL_CONFIG}
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
2009-01-16 21:57:12 +00:00
fi
exit 0