#!/bin/sh # $Id: crypthome,v 1.2 2007/11/10 16:52:46 sqrt Exp $ # - # Copyright (c) 2007 Andreas Hein . # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # 3. All advertising materials mentioning features or use of this software # must display the following acknowledgement: # This product includes software developed by Andreas Hein # 4. Neither the name Andreas Hein nor the name of the above copyright # holders may be used to endorse or promote products derived from # this software without specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # - export DISPLAY=":0.0" svnd=svnd2 if [ ${#@} -ne 2 ]; then echo "Usage: $0 " exit 1 fi home=$1 user=$2 file=$home/.sparseimage if [ ! -e $file ]; then echo "no sparseimage found" exit 1 fi retry=0 while [ ${retry} -lt 3 ]; do /sbin/vnconfig -u $svnd >/dev/null 2>&1 xterm -e "/sbin/vnconfig -k $svnd $file" /sbin/disklabel $svnd 2>/dev/null | grep " a:" >/dev/null 2>&1 if [ $? -ne 0 ]; then retry=$(($retry+1)) continue else break; fi done if [ ${retry} -ge 3 ]; then /sbin/vnconfig -u $svnd exit 1 fi xterm -e "/sbin/fsck /dev/${svnd}a" /sbin/mount /dev/${svnd}a $home if [ -x ${home}/.xsession ]; then su - $user -c "$home/.xsession" else su - $user -c "xterm -display :0.0" fi cd /tmp /sbin/umount -f $home /sbin/vnconfig -u $svnd exit 0