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 -c Configuration for zpool
28 -d Destroy zpool (default create)
29 -l Additional zpool options
30 -s Additional zfs options
37 if [ ! -f ${ZPOOL_CONFIG} ]; then
38 local NAME=`basename ${ZPOOL_CONFIG} .sh`
39 ERROR="Unknown config '${NAME}', available configs are:\n"
41 for CFG in `ls ${ZPOOLDIR}/ | grep ".sh"`; do
42 local NAME=`basename ${CFG} .sh`
43 ERROR="${ERROR}${NAME}\n"
58 while getopts 'hvfc:p:dl:s:' OPTION; do
73 ZPOOL_CONFIG=${ZPOOLDIR}/${OPTARG}.sh
82 ZPOOL_OPTIONS=${OPTARG}
94 if [ $(id -u) != 0 ]; then
95 die "Must run as root"
98 check_config || die "${ERROR}"
101 if [ ${ZPOOL_DESTROY} ]; then
106 if [ "${ZPOOL_OPTIONS}" ]; then
107 if [ ${VERBOSE} ]; then
109 echo "${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME}"
111 ${ZPOOL} ${ZPOOL_OPTIONS} ${ZPOOL_NAME} || exit 1
114 if [ "${ZFS_OPTIONS}" ]; then
115 if [ ${VERBOSE} ]; then
117 echo "${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME}"
119 ${ZFS} ${ZFS_OPTIONS} ${ZPOOL_NAME} || exit 1
122 if [ ${VERBOSE} ]; then
125 ${ZPOOL} list || exit 1
128 echo "zpool status ${ZPOOL_NAME}"
129 ${ZPOOL} status ${ZPOOL_NAME} || exit 1