diff options
author | Matt Macy <mmacy@FreeBSD.org> | 2020-08-24 22:48:19 +0000 |
---|---|---|
committer | Matt Macy <mmacy@FreeBSD.org> | 2020-08-24 22:48:19 +0000 |
commit | 3b0ce0e28db46d0403929aba45c682285e1ac217 (patch) | |
tree | 91721e6e5518bd0d8113dee535898f2225443411 /etc/init.d/zfs-share.in |
Notes
Diffstat (limited to 'etc/init.d/zfs-share.in')
-rwxr-xr-x | etc/init.d/zfs-share.in | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/etc/init.d/zfs-share.in b/etc/init.d/zfs-share.in new file mode 100755 index 0000000000000..3256d1d067f15 --- /dev/null +++ b/etc/init.d/zfs-share.in @@ -0,0 +1,85 @@ +#!@DEFAULT_INIT_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 +# Required-Stop: $local_fs $network $remote_fs zfs-mount +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Should-Start: iscsi iscsitarget istgt scst @DEFAULT_INIT_NFS_SERVER@ samba samba4 zfs-mount zfs-zed +# Should-Stop: iscsi iscsitarget istgt scst @DEFAULT_INIT_NFS_SERVER@ 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() +{ + check_boolean "$ZFS_SHARE" || exit 0 + + check_module_loaded "zfs" || exit 0 + + zfs_action "Sharing ZFS filesystems" "$ZFS" share -a +} + +do_stop() +{ + check_boolean "$ZFS_UNSHARE" || exit 0 + + check_module_loaded "zfs" || exit 0 + + zfs_action "Unsharing ZFS filesystems" "$ZFS" unshare -a +} + +# ---------------------------------------------------- + +if [ ! -e /sbin/openrc-run ]; 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 |