xref: /dragonfly/etc/rc.d/cryptdisks (revision 7485684f)
1#!/bin/sh
2
3# PROVIDE: cryptdisks
4# REQUIRE: lvm
5
6. /etc/rc.subr
7
8name="cryptdisks"
9start_cmd="cryptdisks_start"
10stop_cmd="cryptdisks_stop"
11CRYPTTAB="/etc/crypttab"
12
13cryptdisks_start()
14{
15	if [ ! -f $CRYPTTAB ]; then
16		return 0;
17	fi
18
19	if [ -x /sbin/dmsetup ]; then
20		/sbin/dmsetup version >/dev/null 2>&1
21		if [ $? -ne 0 ]; then
22			warn "/etc/crypttab found but dm is not loaded or present in kernel"
23			return 1;
24		fi
25	fi
26
27	echo "Configuring crypto disks."
28	/sbin/cryptdisks -1
29}
30
31cryptdisks_stop()
32{
33	if [ ! -f $CRYPTTAB ]; then
34		return 0;
35	fi
36
37	if [ -x /sbin/dmsetup ]; then
38		/sbin/dmsetup version >/dev/null 2>&1
39		if [ $? -ne 0 ]; then
40			warn "/etc/crypttab found but dm is not loaded or present in kernel"
41			return 1;
42		fi
43	fi
44
45	echo "Unconfiguring crypto disks."
46	/sbin/cryptdisks -0
47
48}
49
50load_rc_config $name
51run_rc_command "$1"
52