5 # chkconfig: 2345 29 99
6 # description: This script will start and stop the ZFS Event Daemon.
11 # Required-Start: zfs-mount
12 # Required-Stop: zfs-mount
13 # Default-Start: 2 3 4 5
15 # X-Stop-After: zfs-share
16 # Short-Description: ZFS Event Daemon
17 # Description: zed monitors ZFS events. When a zevent is posted, zed
18 # will run any scripts that have been enabled for the
19 # corresponding zevent class.
22 # Released under the 2-clause BSD license.
24 # The original script that acted as a template for this script came from
25 # the Debian GNU/Linux kFreeBSD ZFS packages (which did not include a
26 # licensing stansa) in the commit dated Mar 24, 2011:
27 # https://github.com/zfsonlinux/pkg-zfs/commit/80a3ae582b59c0250d7912ba794dca9e669e605a
29 # Source the common init script
30 . @sysconfdir@/zfs/zfs-functions
33 ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid"
35 extra_started_commands="reload"
37 # Exit if the package is not installed
38 [ -x "$ZED" ] || exit 0
40 # ----------------------------------------------------
44 after zfs-mount localmount
49 check_module_loaded "zfs" || exit 0
51 ZED_ARGS="$ZED_ARGS -p $ZED_PIDFILE"
53 zfs_action "Starting ZFS Event Daemon" zfs_daemon_start \
54 "$ZED_PIDFILE" "$ZED" "$ZED_ARGS"
61 check_module_loaded "zfs" || exit 0
63 zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
64 "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
67 # Let's see if we have any pools imported
68 pools=$("$ZPOOL" list -H -oname)
71 # No pools imported, it is/should be safe/possible to
73 zfs_action "Unloading modules" rmmod zfs zunicode \
74 zavl zcommon znvpair zlua spl
84 check_module_loaded "zfs" || exit 0
86 zfs_daemon_status "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
92 check_module_loaded "zfs" || exit 0
94 zfs_action "Reloading ZFS Event Daemon" zfs_daemon_reload \
95 "$ZED_PIDFILE" "$ZED_NAME"
99 # ----------------------------------------------------
101 if [ ! -e /sbin/openrc-run ]; then
120 [ -n "$1" ] && echo "Error: Unknown command $1."
121 echo "Usage: $0 {start|stop|status|reload|restart}"
128 # Create wrapper functions since Gentoo don't use the case part.
129 depend() { do_depend; }
130 start() { do_start; }
132 status() { do_status; }
133 reload() { do_reload; }