#!/sbin/runscript # Copyright 1999-2004 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 # $Header: /var/cvsroot/gentoo-src/rc-scripts/init.d/crypto-loop,v 1.3 2004/04/21 17:09:18 vapier Exp $ cryptoconf="/etc/conf.d/cryptomount" depend() { need checkroot before localmount } start() { local status="0" ebegin "Setting up dm-crypt mappings" if [ -e ${cryptconf} ] then /bin/egrep "^(mount|swap)" ${cryptoconf} | \ while read mountline do local mount= local swap= local options= local makefs= eval ${mountline} if [ -n "${mount}" ] then local target=${mount} [ -z "${options}" ] && options="-y" elif [ -n "${swap}" ] then local target=${swap} [ -z "${options}" ] && options="-d /dev/random" else ewarn "Invalid line in /etc/conf.d/cryptomount: ${mountline}" fi ! /bin/cryptsetup status ${target}|egrep '\ /dev/null local configured=$? if [ ${configured} -eq 0 ] then einfo " dm-crypt map ${target}" if ! /bin/cryptsetup ${options} create ${target} ${source} >/dev/console /dev/null then ewarn "Failed to create filesystem on ${target}" status=1 fi fi fi else ewarn " dm-crypt mapping ${target} is already configured" status=1 fi done fi ewend ${status} "Failed to setup a mapping or swap device." # We do not fail if some loop devices did not start ... return 0 } # vim:ts=4