Differences

This shows you the differences between two versions of the page.

Link to this comparison view

help:sysnews:isohome.script [2008/05/06 22:42] (current)
Line 1: Line 1:
 +====== isohome ======
  
 +Isohome is a simple script that tries to make an image of your CS home directory that is suitable for burning onto a CD or DVD. 
 +
 +It will confirm that you are running it from the machine where your home directory is actually a local disk.  If not it will tell you which machine you need to run the script from.
 +
 +So, bring a blank CD into the lab and give it a go.
 +
 +For the curious, here is the script.
 +
 +-Greg
 +
 +<code>
 +#!/usr/bin/bash
 +#
 +# isohome: a script to make an iso image of a users home
 +# directory in a users home directory by Greg Priest-Dorman
 +#
 +# $Id: isohome,v 1.7 2004/05/15 06:42:11 priestdo Exp $
 +#
 +IFS="
 +"
 +ECHO=/usr/bin/echo
 +MKISOFS=/bin/mkisofs
 +BKUPNAME=$HOME/$USER-home-`/usr/bin/date +%Y-%m-%d`.iso
 +DU=/usr/local/bin/du
 +MAIL=/usr/ucb/mail
 +DF=/usr/local/bin/df
 +AWK=/usr/local/bin/awk
 +#
 +# Get the name of the system that the users home directory lives on from the nis auto.home map
 +#
 +HomeHost=`ypcat -k auto.home|grep $USER|$AWK '{ print $2 }'|cut -f1 -d:`
 +#
 +if [ $HOST == $HomeHost ] ; then
 +    $ECHO "\n Checking available space...\n"
 +    HomeUsed=`$DU -sk $HOME |$AWK '{ print int(($1  / 1024) + .5)}'`
 +    HomeFree=`$DF -k|grep $HOME | $AWK '{ print int(($3 / 1024) + -99.5)}'`
 +    if [ ${HomeUsed} -lt ${HomeFree} ] ; then
 + $ECHO "\n There is enough free space to create the backup image.\n"
 + MEDIA=""
 + if [ ${HomeUsed} -lt 650 ] ; then 
 +     $ECHO " Your backup image will fit on a single CD\n"
 +     MEDIA="CD"
 + else 
 +     if  [ ${HomeUsed} -lt 4000 ] ; then
 + $ECHO " Your backup image may not fit on a single CD, but will fit on a DVD.\n"
 + MEDIA="DVD"
 +     fi
 + fi
 + if [ ${MEDIA} != "" ] ; then 
 +     $ECHO " It will use around $HomeUsed Meg.\n"
 +     $ECHO " If you choose to proceed an iso9660 image of your home directory"
 +     $ECHO " will be created and a log message will be sent to Greg.  Once"
 +     $ECHO " complete you will have to copy the backup image to a machine"
 +     $ECHO " that has a $MEDIA burner in order to make your $MEDIA.\n"
 +     $ECHO " Please remove your image from the suns once you"
 +     $ECHO " have burned your $MEDIA.  Should you forget to"
 +     $ECHO " remove it, it will be removed once it is more than"
 +     $ECHO " a day old.\n"
 +     $ECHO " The image will skip anything ending in"
 +     $ECHO ' ".iso", "~", "#" or containing the word'
 +     $ECHO ' "cache" in its name or its directory name.\n'
 +     $ECHO "Do you wish to proceed? (y/n):"
 +     read YN
 +     case $YN in
 + y|Y|yes|Yes|YES|yep)
 + $ECHO "\nHere we go...\n"
 + for FOUND in `find $HOME -print |egrep  'cache|.iso'
 +   do
 +   $ECHO "Ignoring $FOUND"
 + done
 +#
 +# options to mkisofs explained:
 +#     -J Joliet directory records in addition to iso9660 file names
 +#     -x exclude pattern(seems to like '*' better than -m)
 +#     -m exclude glob 
 +#     -r generates additional Rock Ridge protocol records with intelligent uid and gid
 +#     -T Generate a TRANS.TBL in each directory for use in non-Rock Ridge system
 +#     -o output file name
 +#
 +#  put all togethe and you get a cd that should be readable on a very wide varity of systems
 +#  HOWEVER,  consider changing the "-r" to "-R" which will not mess with the uid 
 +#  and gid - see man page
 +#
 +
 + $MKISOFS  -J -x '*cache*' -m '*.iso' -m '~' -m '#' -r -T -o  $BKUPNAME  $HOME && $ECHO " $0 run as $USER\n free before = ($HomeFree +100)Meg\n `$DU -sh $BKUPNAME`" |$MAIL -s "$0 run as $USER" priestdo@cs.vassar.edu  && $ECHO "* * * $BKUPNAME created * * *"
 +        ;;
 + *)
 + $ECHO "\n If thats the way you feel about it...\n ... script aborting"
 + ;;
 +     esac
 + fi
 +    else
 + $ECHO "\n There is not enough free space in your home directory"
 + $ECHO " to do the backup.  Please ask Greg for assistance."
 + $ECHO "... script aborting\n"
 +    fi
 +#
 +else
 +    $ECHO "\n You need to run $0 from ${HomeHost}. "
 +    $ECHO " When this script exits issue the command: \n"
 +    $ECHO "   ssh ${USER}@${HomeHost}\n"
 +    $ECHO "... script aborting\n"
 +fi
 +</code>