2 # shellcheck disable=SC2154
6 # chkconfig: 2345 29 99
7 # description: This script will start and stop the ZFS Event Daemon.
12 # Required-Start: zfs-mount
13 # Required-Stop: zfs-mount
14 # Default-Start: 2 3 4 5
16 # X-Stop-After: zfs-share
17 # Short-Description: ZFS Event Daemon
18 # Description: zed monitors ZFS events. When a zevent is posted, zed
19 # will run any scripts that have been enabled for the
20 # corresponding zevent class.
23 # Released under the 2-clause BSD license.
25 # This script is based on debian/zfsutils.zfs.init from the
26 # Debian GNU/kFreeBSD zfsutils 8.1-3 package, written by Aurelien Jarno.
28 # Source the common init script
29 . @sysconfdir@/zfs/zfs-functions
32 ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid"
34 # shellcheck disable=SC2034
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" || return "$?"
66 # Let's see if we have any pools imported
67 pools=$("$ZPOOL" list -H -oname)
70 # No pools imported, it is/should be safe/possible to
72 zfs_action "Unloading modules" rmmod zfs spl
79 check_module_loaded "zfs" || exit 0
81 zfs_daemon_status "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
87 check_module_loaded "zfs" || exit 0
89 zfs_action "Reloading ZFS Event Daemon" zfs_daemon_reload \
90 "$ZED_PIDFILE" "$ZED_NAME"
94 # ----------------------------------------------------
96 if [ ! -e /sbin/openrc-run ]; then
115 [ -n "$1" ] && echo "Error: Unknown command $1."
116 echo "Usage: $0 {start|stop|status|reload|restart}"
123 # Create wrapper functions since Gentoo don't use the case part.
124 depend() { do_depend; }
125 start() { do_start; }
127 status() { do_status; }
128 reload() { do_reload; }