mkinitrd(8): Move the defaults to /etc/defaults/mkinitrd.conf.
[dragonfly.git] / etc / rc.d / cryptdisks
1 #!/bin/sh
2
3 # PROVIDE: cryptdisks
4 # BEFORE:  mountcritlocal localswap dumpon
5
6 $_rc_subr_loaded . /etc/rc.subr
7
8 name="cryptdisks"
9 start_cmd="cryptdisks_start"
10 stop_cmd="cryptdisks_stop"
11 CRYPTTAB="/etc/crypttab"
12
13 cryptdisks_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
31 cryptdisks_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
50 load_rc_config $name
51 run_rc_command "$1"