Init Script for FreeNAS


#!/bin/sh

PATH=/sbin:/bin:/usr/sbin:/usr/bin

. /lib/lsb/init-functions
. /lib/init/vars.sh

[ -f /etc/default/zfs ] && . /etc/default/zfs

do_start() {
log_begin_msg “Starting ZFS subsystem”
log_progress_msg “filesystems”
zfs mount -a
RET=$?
if [ $RET != 0 ] ; then
log_end_msg $RET
exit $RET
fi
log_end_msg 0

log_begin_msg “Exporting ZFS filesystems”
zfs share -a
log_end_msg $?
}

do_stop() {
log_begin_msg “Stopping ZFS subsystem”
log_progress_msg “filesystems”
zfs umount -a
RET=$?
if [ $RET != 0 ] ; then
log_end_msg $RET
fi
log_end_msg 0
}

do_status() {
zpool status
echo ”
zpool list
true
}

case “$1” in
start)
[ -z “$ZFS_MOUNT” ] && exit 0
do_start
;;
stop)
[ -z “$ZFS_UNMOUNT” ] && exit 0
do_stop
;;
status)
do_status
;;
*)
[ -n “$1” ] && echo “Error: Unknown command $1.”
echo “Usage: $0 {start|stop|status}”
exit 3
;;
esac

chmod 755 /etc/init.d/zfs

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s