3 basedir="$(dirname $0)"
5 SCRIPT_COMMON=common.sh
6 if [ -f "${basedir}/${SCRIPT_COMMON}" ]; then
7 . "${basedir}/${SCRIPT_COMMON}"
9 echo "Missing helper script ${SCRIPT_COMMON}" && exit 1
20 Create one of several predefined zpool configurations.
26 -x Disable all zpool features
27 -c Configuration for zpool
29 -d Destroy zpool (default create)
30 -l Additional zpool options
31 -s Additional zfs options
38 if [ ! -f ${ZPOOL_CONFIG} ]; then
39 local NAME=`basename ${ZPOOL_CONFIG} .sh`
40 ERROR="Unknown config '${NAME}', available configs are:\n"
42 for CFG in `ls ${ZPOOLDIR}/ | grep ".sh"`; do
43 local NAME=`basename ${CFG} .sh`
44 ERROR="${ERROR}${NAME}\n"
56 ZPOOL_FLAGS=${ZPOOL_FLAGS:-""}
60 while getopts 'hvfxc:p:dl:s:' OPTION; do
72 ZPOOL_FLAGS="$ZPOOL_FLAGS -f"
76 ZPOOL_FLAGS="$ZPOOL_FLAGS -d"
79 ZPOOL_CONFIG=${ZPOOLDIR}/${OPTARG}.sh
88 ZPOOL_OPTIONS=${OPTARG}
100 if [ $(id -u) != 0 ]; then
101 die "Must run as root"
104 check_config || die "${ERROR}"
107 if [ ${ZPOOL_DESTROY} ]; then
112 if [ "${ZPOOL_OPTIONS}" ]; then
113 if [ ${VERBOSE} ]; then
115 echo "${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME}"
117 ${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME} || exit 1
120 if [ "${ZFS_OPTIONS}" ]; then
121 if [ ${VERBOSE} ]; then
123 echo "${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME}"
125 ${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME} || exit 1
128 if [ ${VERBOSE} ]; then
131 ${ZPOOL} list || exit 1
134 echo "zpool status ${ZPOOL_NAME}"
135 ${ZPOOL} status ${ZPOOL_NAME} || exit 1