| |
|
| ebegin "Starting crypto loop devices" |
ebegin "Starting crypto loop devices" |
| |
|
| if [[ -e /etc/conf.d/crypto-loop ]] ; then |
if [ -e /etc/conf.d/crypto-loop ] ; then |
| egrep "^loop" /etc/conf.d/crypto-loop | \ |
egrep "^loop" /etc/conf.d/crypto-loop | \ |
| while read loopline ; do |
while read loopline ; do |
| eval ${loopline} |
eval ${loopline} |
| local configured=$(awk -v MOUNT="${device}" \ |
local configured=$(awk -v MOUNT="${device}" \ |
| '($2 == MOUNT) { print "yes" }' /proc/mounts) |
'($2 == MOUNT) { print "yes" }' /proc/mounts) |
| |
|
| if [[ ${configured} != "yes" ]] ; then |
if [ "${configured}" != "yes" ] ; then |
| einfo " Loop ${loop} on device ${device} (cipher ${cipher}, key size ${keysize}): " |
einfo " Loop ${loop} on device ${device} (cipher ${cipher}, key size ${keysize}): " |
| |
|
| if [[ -n ${hash} ]] ; then |
if [ -n "${hash}" ] ; then |
| /usr/sbin/hashalot -n ${keysize} ${hash} </dev/tty|\ |
/usr/sbin/hashalot -n ${keysize} ${hash} </dev/tty|\ |
| /sbin/losetup -p 0 -e ${cipher}-${keysize} ${loop} ${device} ${other} |
/sbin/losetup -p 0 -e ${cipher}-${keysize} ${loop} ${device} ${other} |
| else |
else |
| /sbin/losetup -e ${cipher}-${keysize} ${loop} ${device} ${other} |
/sbin/losetup -e ${cipher}-${keysize} ${loop} ${device} ${other} |
| fi |
fi |
| |
|
| if [[ $? -ne 0 ]] ; then |
if [ $? -ne 0 ] ; then |
| ewarn "Failure configuring ${loop}. Skipping." |
ewarn "Failure configuring ${loop}. Skipping." |
| status=1 |
status=1 |
| fi |
fi |
| |
|
| stop() { |
stop() { |
| local status="0" |
local status="0" |
| for loop in $(ls /dev/loop[0-9]) ; do |
for loop in $(ls /dev/loop[0-9] 2>/dev/null) ; do |
| losetup ${loop} &> /dev/null |
losetup ${loop} > /dev/null 2>&1 |
| if [[ $? == 0 ]] ; then |
if [ $? -eq 0 ] ; then |
| umount ${loop} &>/dev/null || swapoff "${loop}" &>/dev/null |
( umount ${loop} || swapoff "${loop}" ) >/dev/null 2>&1 |
| if ! /sbin/losetup -d ${loop} &> /dev/null ; then |
if ! /sbin/losetup -d ${loop} > /dev/null 2>&1; then |
| ewarn "Failure deconfiguring ${loop}." |
ewarn "Failure deconfiguring ${loop}." |
| status=1 |
status=1 |
| fi |
fi |