#!/bin/sh # Loopback mount interesting ISO images. Also add them to /etc/fstab for # mounting at bootup and add them to /etc/exports, so that other machines # can nfs-mount them, too. # verify this script is ok for you and comment out the next line: exit 0 exclude="old" fstab=/etc/fstab exports=/etc/exports d=/home/data nfsnetwork="192.168.123.0/255.255.255.0" cd $d || exit 1 grep -v ^$d < $fstab > $fstab.new mv -f $fstab.new $fstab grep -v ^$d < $exports > $exports.new mv -f $exports.new $exports for i in `mount | grep ^$d | awk '{ print $3 }'` ; do umount $i rmdir $i done #rmdir */* 2>/dev/null >/dev/null I=`ls $d/*/*.iso $d/*/*/*.iso $d/*/*/*/*.iso 2>/dev/null` for i in $exclude ; do I=`echo "$I" | grep -v $i` done for iso in $I ; do test -f $iso || continue dir=`echo $iso | sed 's#.iso$##'` test -f `dirname $dir`/.skip && continue test -d $dir || mkdir $dir echo "$iso $dir iso9660 loop 0 0" >> $fstab echo "$dir $nfsnetwork(ro)" >> $exports done mount -a #/etc/rc.d/init.d/nfs reload