Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs.lsb improvements for milestone 0.6.0-rc7 #480

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions etc/init.d/zfs.lsb.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,20 @@
# Source function library.
. /lib/lsb/init-functions

# Source zfs configuration.
[ -f /etc/defaults/zfs ] && . /etc/defaults/zfs

RETVAL=0

LOCKFILE=/var/lock/zfs
ZFS="@sbindir@/zfs"
ZPOOL="@sbindir@/zpool"
ZPOOL_CACHE="@sysconfdir@/zfs/zpool.cache"

[ -x $ZPOOL ] || exit 1
[ -x $ZFS ] || exit 2
# Source zfs configuration.
[ -r '/etc/default/zfs' ] && . /etc/default/zfs

[ -x "$ZPOOL" ] || exit 1
[ -x "$ZFS" ] || exit 2

start()
{
[ -f $LOCKFILE ] && return 3
[ -f "$LOCKFILE" ] && return 3

# Requires selinux policy which has not been written.
if [ -r "/selinux/enforce" ] &&
Expand All @@ -60,45 +58,45 @@ start()
# This should be handled by rc.sysinit but lets be paranoid.
awk '$2 == "/" { exit 1 }' /etc/mtab
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
if [ "$RETVAL" -eq 0 ]; then
/bin/mount -f /
fi

# Import all pools described by the cache file, and then mount
# all filesystem based on their properties.
if [ -f $ZPOOL_CACHE ] ; then
if [ -f "$ZPOOL_CACHE" ] ; then
log_begin_msg "Importing ZFS pools"
$ZPOOL import -c $ZPOOL_CACHE -aN 2>/dev/null
"$ZPOOL" import -c "$ZPOOL_CACHE" -aN 2>/dev/null
log_end_msg $?

log_begin_msg "Mounting ZFS filesystems"
$ZFS mount -a
"$ZFS" mount -a
log_end_msg $?

log_begin_msg "Exporting ZFS filesystems"
$ZFS share -a
"$ZFS" share -a
log_end_msg $?
fi

touch $LOCKFILE
touch "$LOCKFILE"
}

stop()
{
[ ! -f $LOCKFILE ] && return 3
[ ! -f "$LOCKFILE" ] && return 3

log_begin_msg "Unmounting ZFS filesystems"
$ZFS umount -a
"$ZFS" umount -a
log_end_msg $?

rm -f $LOCKFILE
rm -f "$LOCKFILE"
}

status()
{
[ ! -f $LOCKFILE ] && return 3
[ ! -f "$LOCKFILE" ] && return 3

$ZPOOL status && echo && $ZPOOL list
"$ZPOOL" status && echo "" && "$ZPOOL" list
}

case "$1" in
Expand All @@ -119,7 +117,7 @@ case "$1" in
start
;;
condrestart)
if [ -f $LOCKFILE ]; then
if [ -f "$LOCKFILE" ]; then
stop
start
fi
Expand Down