mirror_zfs/etc/init.d/zfs-share.in
James Lee 3f1cc17c90 Reorder zfs-* services to allow /var on separate dataset
ZED depends on /var.  When /var is a separate dataset, it must be
mounted before starting ZED.  This change moves the zfs-zed service
from starting first, to starting after zfs-mount, but before zfs-share.

As discussed in issue #3513, ZED does not need to start first in order
to consume events made during the zfs-import and zfs-mount services.
The events will be queued and can be handled later in the boot process.

ZED may, however, handle sharing in the future, so it should be started
before the zfs-share service.

This commit also stops the zfs-import service from writing temp files
to /var/tmp on shutdown and it corrects the return code for the OpenRC
service.

Other OpenRC-specific changes noted in issue #3513 were reitereated in
issue #3715 and committed in da619f3.

Signed-off-by: James Lee <jlee@thestaticvoid.com>
Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3513
2015-09-02 09:16:39 -07:00

94 lines
2.3 KiB
Plaintext
Executable File

#!@SHELL@
#
# zfs-share This script will network share zfs filesystems and volumes.
#
# chkconfig: 2345 30 99
# description: Run the `zfs share -a` or `zfs unshare -a` commands
# for controlling iSCSI, NFS, or CIFS network shares.
# probe: true
#
### BEGIN INIT INFO
# Provides: zfs-share
# Required-Start: $local_fs $network $remote_fs zfs-mount zfs-zed
# Required-Stop: $local_fs $network $remote_fs zfs-mount zfs-zed
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Should-Start: iscsi iscsitarget istgt scst @NFS_SRV@ samba samba4 zfs-mount zfs-zed
# Should-Stop: iscsi iscsitarget istgt scst @NFS_SRV@ samba samba4 zfs-mount zfs-zed
# Short-Description: Network share ZFS datasets and volumes.
# Description: Run the `zfs share -a` or `zfs unshare -a` commands
# for controlling iSCSI, NFS, or CIFS network shares.
### END INIT INFO
#
# Released under the 2-clause BSD license.
#
# The original script that acted as a template for this script came from
# the Debian GNU/Linux kFreeBSD ZFS packages (which did not include a
# licensing stansa) in the commit dated Mar 24, 2011:
# https://github.com/zfsonlinux/pkg-zfs/commit/80a3ae582b59c0250d7912ba794dca9e669e605a
# Source the common init script
. @sysconfdir@/zfs/zfs-functions
# ----------------------------------------------------
do_depend()
{
after sysfs zfs-mount zfs-zed
keyword -lxc -openvz -prefix -vserver
}
do_start()
{
case "$ZFS_SHARE" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 0
;;
esac
check_module_loaded "zfs" || exit 0
zfs_action "Sharing ZFS filesystems" "$ZFS" share -a
}
do_stop()
{
case "$ZFS_UNSHARE" in
[Oo][Ff][Ff]|[Nn][Oo]|''|0)
exit 0
;;
esac
check_module_loaded "zfs" || exit 0
zfs_action "Unsharing ZFS filesystems" "$ZFS" unshare -a
}
# ----------------------------------------------------
if [ ! -e /etc/gentoo-release ]; then
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
force-reload|reload|restart|status)
# no-op
;;
*)
[ -n "$1" ] && echo "Error: Unknown command $1."
echo "Usage: $0 {start|stop}"
exit 3
;;
esac
exit $?
else
# Create wrapper functions since Gentoo don't use the case part.
depend() { do_depend; }
start() { do_start; }
stop() { do_stop; }
fi