#!/bin/csh -f # Quick hack to keep any automounted filesystems mounted for some period. # Run this in the background, and no automounted filesystems will be # unmounted for one hour. To change the protected period, specify the number # of seconds on the command line. # daw, 3/19/02 switch (`uname -s``uname -r`) case SunOS5*: breaksw default: exec echo ${0}: does not run on `uname -s` `uname -r` endsw while($#argv) switch ("$1") case -d: set DEBUG # shift # breaksw # fall through to verbose case -v: set VERBOSE shift breaksw case -h: case -help: case --help: goto usage shift breaksw case -*: set DQ = '"' echo ${0}: "What do I do with $DQ$1$DQ?" goto usage default: if (! $?DURATION) then @ DURATION = $1 shift breaksw endif set DQ = '"' exec echo ${0}: "What do I do with $DQ$1$DQ?" endsw end goto doit usage: echo "" echo "usage: $0 [-h] [-v] [duration]" echo "" echo " -h prints this text and exits" echo " -v prints paritions currently NFS mounted" echo " each time it checks" echo " duration time (in seconds) to prevent dismounts" echo " (defaults to 3600 -- one hour)" exec echo "" doit: if (! $?DURATION) set DURATION = 3600 set INTERVAL = 240 set STATFILE = /tmp/`basename $0`.$$ touch $STATFILE if ($?VERBOSE) echo `date +%T` Preventing automount dismounts for $DURATION seconds while ($DURATION) set MPTS = `/bin/df -F nfs | grep ^/ | awk '{print $1}'` if ($?VERBOSE) echo `date +%T` $MPTS foreach MPT ( $MPTS ) # /bin/ls $MPT/. > /dev/null grep '^'$MPT'$' $STATFILE > /dev/null if ($status) then cd $MPT if ($?DEBUG) echo sleeping in `pwd` ( /bin/sleep $DURATION & ) >& /dev/null echo $MPT >> $STATFILE endif end sleep $INTERVAL @ DURATION -= $INTERVAL end /bin/rm -f $STATFILE