1#!@DEFAULT_INIT_SHELL@ 2# shellcheck disable=SC2154 3# 4# zfs-share This script will network share zfs filesystems and volumes. 5# 6# chkconfig: 2345 30 99 7# description: Run the `zfs share -a` or `zfs unshare -a` commands 8# for controlling iSCSI, NFS, or CIFS network shares. 9# probe: true 10# 11### BEGIN INIT INFO 12# Provides: zfs-share 13# Required-Start: $local_fs $network $remote_fs zfs-mount 14# Required-Stop: $local_fs $network $remote_fs zfs-mount 15# Default-Start: 2 3 4 5 16# Default-Stop: 0 1 6 17# Should-Start: iscsi iscsitarget istgt scst @DEFAULT_INIT_NFS_SERVER@ samba samba4 zfs-mount zfs-zed 18# Should-Stop: iscsi iscsitarget istgt scst @DEFAULT_INIT_NFS_SERVER@ samba samba4 zfs-mount zfs-zed 19# Short-Description: Network share ZFS datasets and volumes. 20# Description: Run the `zfs share -a` or `zfs unshare -a` commands 21# for controlling iSCSI, NFS, or CIFS network shares. 22### END INIT INFO 23# 24# Released under the 2-clause BSD license. 25# 26# This script is based on debian/zfsutils.zfs.init from the 27# Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno. 28 29# Source the common init script 30. @sysconfdir@/zfs/zfs-functions 31 32# ---------------------------------------------------- 33 34do_depend() 35{ 36 after sysfs zfs-mount zfs-zed 37 keyword -lxc -openvz -prefix -vserver 38} 39 40do_start() 41{ 42 check_boolean "$ZFS_SHARE" || exit 0 43 44 check_module_loaded "zfs" || exit 0 45 46 zfs_action "Sharing ZFS filesystems" "$ZFS" share -a 47} 48 49do_stop() 50{ 51 check_boolean "$ZFS_UNSHARE" || exit 0 52 53 check_module_loaded "zfs" || exit 0 54 55 zfs_action "Unsharing ZFS filesystems" "$ZFS" unshare -a 56} 57 58# ---------------------------------------------------- 59 60if [ ! -e /sbin/openrc-run ]; then 61 case "$1" in 62 start) 63 do_start 64 ;; 65 stop) 66 do_stop 67 ;; 68 force-reload|reload|restart|status) 69 # no-op 70 ;; 71 *) 72 [ -n "$1" ] && echo "Error: Unknown command $1." 73 echo "Usage: $0 {start|stop}" 74 exit 3 75 ;; 76 esac 77 78 exit $? 79else 80 # Create wrapper functions since Gentoo don't use the case part. 81 depend() { do_depend; } 82 start() { do_start; } 83 stop() { do_stop; } 84fi 85