The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/contrib/openzfs/etc/init.d/zfs-zed.in

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 #!@DEFAULT_INIT_SHELL@
    2 # shellcheck disable=SC2154
    3 #
    4 # zfs-zed
    5 #
    6 # chkconfig:    2345 29 99
    7 # description:  This script will start and stop the ZFS Event Daemon.
    8 # probe: true
    9 #
   10 ### BEGIN INIT INFO
   11 # Provides:          zfs-zed
   12 # Required-Start:    zfs-mount
   13 # Required-Stop:     zfs-mount
   14 # Default-Start:     2 3 4 5
   15 # Default-Stop:      0 1 6
   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.
   21 ### END INIT INFO
   22 #
   23 # Released under the 2-clause BSD license.
   24 #
   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.
   27 
   28 # Source the common init script
   29 . @sysconfdir@/zfs/zfs-functions
   30 
   31 ZED_NAME="zed"
   32 ZED_PIDFILE="@runstatedir@/$ZED_NAME.pid"
   33 
   34 # shellcheck disable=SC2034
   35 extra_started_commands="reload"
   36 
   37 # Exit if the package is not installed
   38 [ -x "$ZED" ] || exit 0
   39 
   40 # ----------------------------------------------------
   41 
   42 do_depend()
   43 {
   44         after zfs-mount localmount
   45 }
   46 
   47 do_start()
   48 {
   49         check_module_loaded "zfs" || exit 0
   50 
   51         ZED_ARGS="$ZED_ARGS -p $ZED_PIDFILE"
   52 
   53         zfs_action "Starting ZFS Event Daemon" zfs_daemon_start \
   54             "$ZED_PIDFILE" "$ZED" "$ZED_ARGS"
   55         return "$?"
   56 }
   57 
   58 do_stop()
   59 {
   60         local pools
   61         check_module_loaded "zfs" || exit 0
   62 
   63         zfs_action "Stopping ZFS Event Daemon" zfs_daemon_stop \
   64            "$ZED_PIDFILE" "$ZED" "$ZED_NAME" || return "$?"
   65 
   66         # Let's see if we have any pools imported
   67         pools=$("$ZPOOL" list -H -oname)
   68         if [ -z "$pools" ]
   69         then
   70                 # No pools imported, it is/should be safe/possible to
   71                 # unload modules.
   72                 zfs_action "Unloading modules" rmmod zfs spl
   73                 return "$?"
   74         fi
   75 }
   76 
   77 do_status()
   78 {
   79         check_module_loaded "zfs" || exit 0
   80 
   81         zfs_daemon_status "$ZED_PIDFILE" "$ZED" "$ZED_NAME"
   82         return "$?"
   83 }
   84 
   85 do_reload()
   86 {
   87         check_module_loaded "zfs" || exit 0
   88 
   89         zfs_action "Reloading ZFS Event Daemon" zfs_daemon_reload \
   90             "$ZED_PIDFILE" "$ZED_NAME"
   91         return "$?"
   92 }
   93 
   94 # ----------------------------------------------------
   95 
   96 if [ ! -e /sbin/openrc-run ]; then
   97         case "$1" in
   98                 start)
   99                         do_start
  100                         ;;
  101                 stop)
  102                         do_stop
  103                         ;;
  104                 status)
  105                         do_status
  106                         ;;
  107                 reload|force-reload)
  108                         do_reload
  109                         ;;
  110                 restart)
  111                         do_stop
  112                         do_start
  113                         ;;
  114                 *)
  115                         [ -n "$1" ] && echo "Error: Unknown command $1."
  116                         echo "Usage: $0 {start|stop|status|reload|restart}"
  117                         exit 1
  118                         ;;
  119         esac
  120 
  121         exit $?
  122 else
  123         # Create wrapper functions since Gentoo don't use the case part.
  124         depend() { do_depend; }
  125         start() { do_start; }
  126         stop() { do_stop; }
  127         status() { do_status; }
  128         reload() { do_reload; }
  129 fi

Cache object: 96b91c1826767c5a7a7d2de461cde120


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.