3 # This file, originally written by Garrett A. Wollman, is in the public
15 desc="GEOM Based Disk Encryption"
16 start_precmd="find_gbde_devices start"
17 stop_precmd="find_gbde_devices stop"
18 start_cmd="gbde_start"
23 case "${gbde_devices-auto}" in
37 fstab=$(mktemp /tmp/mtab.XXXXXX)
43 # We can't use "mount -p | while ..." because when a shell loop
44 # is the target of a pipe it executes in a subshell, and so can't
45 # modify variables in the script.
47 while read device mountpt type options dump pass; do
59 if checkyesno gbde_autoattach_all; then
60 gbde_devices="${gbde_devices} ${device}"
64 gbde_devices="${gbde_devices} ${device}"
82 for device in $gbde_devices; do
84 parent=${parent#/dev/}
85 parent_=`ltr ${parent} '/' '_'`
86 eval "lock=\${gbde_lock_${parent_}-\"${gbde_lockdir}/${parent_}.lock\"}"
87 if [ -e "/dev/${parent}" -a ! -e "/dev/${parent}.bde" ]; then
88 echo "Configuring Disk Encryption for ${parent}."
91 while [ ${count} -le ${gbde_attach_attempts} ]; do
92 if [ -e "${lock}" ]; then
93 gbde attach ${parent} -l ${lock}
97 if [ -e "/dev/${parent}.bde" ]; then
100 echo "Attach failed; attempt ${count} of ${gbde_attach_attempts}."
101 count=$((${count} + 1))
109 for device in $gbde_devices; do
110 parent=${device%.bde}
111 parent=${parent#/dev/}
112 if [ -e "/dev/${parent}.bde" ]; then
113 umount "/dev/${parent}.bde" 2>/dev/null
114 gbde detach "${parent}"