simd_stat: fix undefined CONFIG_KERNEL_MODE_NEON error on armel
[zfs.git] / etc / init.d / zfs-load-key.in
blob27dfeeb0bcc572c7bdf71a1f5e704de4db0bd7f9
1 #!@DEFAULT_INIT_SHELL@
2 # shellcheck disable=SC2154
4 # zfs-load-key  This script will load/unload the zfs filesystems keys.
6 # chkconfig:    2345 06 99
7 # description:  This script will load or unload the zfs filesystems keys during
8 #               system boot/shutdown. Only filesystems with key path set
9 #               in keylocation property. See the zfs(8) man page for details.
10 # probe: true
12 ### BEGIN INIT INFO
13 # Provides:          zfs-load-key
14 # Required-Start:    $local_fs zfs-import
15 # Required-Stop:     $local_fs zfs-import
16 # Default-Start:     2 3 4 5
17 # Default-Stop:      0 1 6
18 # X-Start-Before:    zfs-mount
19 # X-Stop-After:      zfs-zed
20 # Short-Description: Load ZFS keys for filesystems and volumes
21 # Description: Run the `zfs load-key` or `zfs unload-key` commands.
22 ### END INIT INFO
24 # Released under the 2-clause BSD license.
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.
29 # Source the common init script
30 . @sysconfdir@/zfs/zfs-functions
32 # ----------------------------------------------------
34 do_depend()
36         # bootmisc will log to /var which may be a different zfs than root.
37         before bootmisc logger zfs-mount
39         after zfs-import sysfs
40         keyword -lxc -openvz -prefix -vserver
43 # Load keys for all datasets/filesystems
44 do_load_keys()
46         zfs_log_begin_msg "Load ZFS filesystem(s) keys"
48         "$ZFS" list -Ho name,encryptionroot,keystatus,keylocation |
49             while IFS=" " read -r name encryptionroot keystatus keylocation; do
50                 if [ "$encryptionroot" != "-" ] &&
51                         [ "$name" = "$encryptionroot" ] &&
52                         [ "$keystatus" = "unavailable" ] &&
53                         [ "$keylocation" != "prompt" ] &&
54                         [ "$keylocation" != "none" ]
55                 then
56                         zfs_action "Load key for $encryptionroot" \
57                             "$ZFS" load-key "$encryptionroot"
58                 fi
59         done
61         zfs_log_end_msg 0
63         return 0
66 # Unload keys for all datasets/filesystems
67 do_unload_keys()
69         zfs_log_begin_msg "Unload ZFS filesystem(s) key"
71         "$ZFS" list -Ho name,encryptionroot,keystatus | sed '1!G;h;$!d' |
72             while IFS=" " read -r name encryptionroot keystatus; do
73                 if [ "$encryptionroot" != "-" ] &&
74                         [ "$name" = "$encryptionroot" ] &&
75                         [ "$keystatus" = "available" ]
76                 then
77                         zfs_action "Unload key for $encryptionroot" \
78                             "$ZFS" unload-key "$encryptionroot"
79                 fi
80         done
82         zfs_log_end_msg 0
84         return 0
87 do_start()
89         check_boolean "$ZFS_LOAD_KEY" || exit 0
91         check_module_loaded "zfs" || exit 0
93         do_load_keys
96 do_stop()
98         check_boolean "$ZFS_UNLOAD_KEY" || exit 0
100         check_module_loaded "zfs" || exit 0
102         do_unload_keys
105 # ----------------------------------------------------
107 if @IS_SYSV_RC@
108 then
109         case "$1" in
110                 start)
111                         do_start
112                         ;;
113                 stop)
114                         do_stop
115                         ;;
116                 force-reload|condrestart|reload|restart|status)
117                         # no-op
118                         ;;
119                 *)
120                         [ -n "$1" ] && echo "Error: Unknown command $1."
121                         echo "Usage: $0 {start|stop}"
122                         exit 3
123                         ;;
124         esac
126         exit $?
127 else
128         # Create wrapper functions since Gentoo don't use the case part.
129         depend() { do_depend; }
130         start() { do_start; }
131         stop() { do_stop; }