3 # This file, originally written by Garrett A. Wollman, is in the public
15 start_precmd="find_gbde_devices start"
16 stop_precmd="find_gbde_devices stop"
17 start_cmd="gbde_start"
20 # Change every ${_src} in ${_str} to ${_dst}.
21 # We cannot use tr(1), sed(1) nor awk(1) here, because this script is executed
22 # before /usr is mounted.
31 for _com in ${_str}; do
32 if [ -z "${_out}" ]; then
35 _out="${_out}${_dst}${_com}"
43 case "${gbde_devices-auto}" in
57 fstab=$(mktemp /tmp/mtab.XXXXXX)
63 # We can't use "mount -p | while ..." because when a shell loop
64 # is the target of a pipe it executes in a subshell, and so can't
65 # modify variables in the script.
67 while read device mountpt type options dump pass; do
79 if checkyesno gbde_autoattach_all; then
80 gbde_devices="${gbde_devices} ${device}"
84 gbde_devices="${gbde_devices} ${device}"
102 for device in $gbde_devices; do
103 parent=${device%.bde}
104 parent=${parent#/dev/}
105 parent_=`local_tr ${parent} '/' '_'`
106 eval "lock=\${gbde_lock_${parent_}-\"${gbde_lockdir}/${parent_}.lock\"}"
107 if [ -e "/dev/${parent}" -a ! -e "/dev/${parent}.bde" ]; then
108 echo "Configuring Disk Encryption for ${parent}."
111 while [ ${count} -le ${gbde_attach_attempts} ]; do
112 if [ -e "${lock}" ]; then
113 gbde attach ${parent} -l ${lock}
115 gbde attach ${parent}
117 if [ -e "/dev/${parent}.bde" ]; then
120 echo "Attach failed; attempt ${count} of ${gbde_attach_attempts}."
121 count=$((${count} + 1))
129 for device in $gbde_devices; do
130 parent=${device%.bde}
131 parent=${parent#/dev/}
132 if [ -e "/dev/${parent}.bde" ]; then
133 umount "/dev/${parent}.bde" 2>/dev/null
134 gbde detach "${parent}"