summaryrefslogtreecommitdiff
path: root/sys-freebsd/freebsd-cddl/files/zvol.initd
diff options
context:
space:
mode:
Diffstat (limited to 'sys-freebsd/freebsd-cddl/files/zvol.initd')
-rw-r--r--sys-freebsd/freebsd-cddl/files/zvol.initd46
1 files changed, 46 insertions, 0 deletions
diff --git a/sys-freebsd/freebsd-cddl/files/zvol.initd b/sys-freebsd/freebsd-cddl/files/zvol.initd
new file mode 100644
index 000000000000..28eba8e8c687
--- /dev/null
+++ b/sys-freebsd/freebsd-cddl/files/zvol.initd
@@ -0,0 +1,46 @@
+#!/sbin/openrc-run
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+depend() {
+ need hostid
+ before fsck
+}
+
+start() {
+ einfo "Starting zfs volumes..."
+ zfs volinit
+ eend $?
+ # Enable swap on ZVOLs that have org.freebsd:swap=on.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Enabling swap on zvol ${name}"
+ swapon /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+}
+
+stop() {
+ # Disable what we had enabled before.
+ zfs list -H -o org.freebsd:swap,name -t volume | \
+ while read state name; do
+ case "${state}" in
+ [oO][nN])
+ einfo "Disabling swap on zvol ${name}"
+ swapoff /dev/zvol/${name}
+ eend $?
+ ;;
+ esac
+ done
+ einfo "Stopping zfs volumes..."
+ zfs volfini
+ eend $?
+}
+
+restart() {
+ :
+}