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