#!/bin/bash #This script checks the disk usage of the current # USB removable drive by executing a df command. #If the used number of blocks is greater than the # user defined high water mark, # Then # If the current USB drive path is /media/usbdisk # Then copy the usbdisk1 file into the default file # Else copy the usbdisk file into the default file # Else log the current disk usage # #David Welsh #April 26, 2005 echo " Start CheckUsbDiskUsage.bash `date -u`" #Set the execution path export PATH=$HOME/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin #Set the SEARCH home path export SHOME=$HOME/search #Set the number of blocks used for the high water mark let bhwm=180000000 #get the USB disk mount point read diskpath < "$SHOME"/diskpath #execute the disk usage command to get the used number of blocks let bused=`df -k "$diskpath" |grep dev|awk '{print $3}'` #Test the number of blocks used verses the high water mark if [ "$bused" -gt "$bhwm" ]; then echo " $bused > $bhwm so switch diskpath" if [ "$diskpath" = '/media/usbdisk' ]; then echo " switching from usbdisk to usbdisk1" cp $SHOME/usbdisk1 $SHOME/diskpath else echo " switching from usbdisk1 to usbdisk" cp $SHOME/usbdisk $SHOME/diskpath fi else echo " $bused <= $bhwm" fi echo " Stop CheckUsbDiskUsage.bash `date -u`"