aboutsummaryrefslogtreecommitdiff
path: root/init.d/encswap.in
diff options
context:
space:
mode:
authorRichard Yao <ryao@cs.stonybrook.edu>2012-07-15 08:47:00 -0400
committerWilliam Hubbs <w.d.hubbs@gmail.com>2012-07-15 13:57:57 -0500
commit0730ac61e8e674c5751ff8fa3857184326a40460 (patch)
tree0a98fb79cbd72e48d496ad24a5e26ba07ffd803c /init.d/encswap.in
parent006fbdce83a8b75766f9d6deeedefef001f15b32 (diff)
Import encswap init script from FreeBSD
The FreeBSD encswap init script has been adapted to function in OpenRC. It should function identically to its FreeBSD counterpart.
Diffstat (limited to 'init.d/encswap.in')
-rw-r--r--init.d/encswap.in46
1 files changed, 46 insertions, 0 deletions
diff --git a/init.d/encswap.in b/init.d/encswap.in
new file mode 100644
index 00000000..a03fe581
--- /dev/null
+++ b/init.d/encswap.in
@@ -0,0 +1,46 @@
+#!@PREFIX@/sbin/runscript
+# Copyright 1992-2012 FreeBSD Project
+# Released under the 2-clause BSD license
+# $Header: $
+
+depend() {
+ before swap
+}
+
+start() {
+ while read device mountpoint type options rest ; do
+ case ":${device}:${type}:${options}" in
+ :#*)
+ continue
+ ;;
+ *.bde:swap:sw)
+ passphrase=`dd if=/dev/random count=1 2>/dev/null | md5 -q`
+ device="${device%.bde}"
+ gbde init "${device}" -P "${passphrase}" || return 1
+ gbde attach "${device}" -p "${passphrase}" || return 1
+ ;;
+ *.eli:swap:sw)
+ device="${device%.eli}"
+ geli onetime ${geli_swap_flags} "${device}" || return 1
+ ;;
+ esac
+ done < /etc/fstab
+}
+
+stop() {
+ while read device mountpoint type options rest ; do
+ case ":${device}:${type}:${options}" in
+ :#*)
+ continue
+ ;;
+ *.bde:swap:sw)
+ device="${device%.bde}"
+ gbde detach "${device}"
+ ;;
+ *.eli:swap:sw)
+ # Nothing here, because geli swap devices should be
+ # created with the auto-detach-on-last-close option.
+ ;;
+ esac
+ done < /etc/fstab
+}