#!/bin/bash # Name: sleepwell # Purpose: make sure that all the external drives are unmounted before suspending # Syntax: sleepwell #------------------------------------------------------------------------------------- mounts=$(mount | grep "/dev/sd[abcdef]"| sed 's/$/\\n/g') if [ "$mounts" ] ; then export DISPLAY=:0 gdialog --title "Suspending the Laptop" --yesno \ "The following SCSI drives are mounted:\n-----------------------\n$mounts \n-------------------------\nPlease unmount all of them before suspending,\n then click on 'Yes' to suspend laptop or 'No' to abort" \ 20 40 --defaultno # Yes button pressed? if [ $? -eq 0 ] ; then # check if the SCSI drives are still mounted mounts=$(mount | grep "/dev/sd[abcdef]"| sed 's/$/\\n/g') # Loop until no SCSI drives are mounted while [ "$mounts" ] ; do gdialog --title "Suspending the Laptop" --yesno \ "The following SCSI drives are STILL mounted!-----------------------\n$mounts \n-------------------------\nPlease FIRST unmount all of them before suspending,\n then click on 'Yes' to suspend laptop or 'No' to abort" \ 20 40 --defaultno # Get ou if NO button pressed if [ $? -eq 1 ] ; then exit ; fi mounts=$(mount | grep "/dev/sd[abcdef]"| sed 's/$/\\n/g') done # NOW that alls the SCSI are unmounted go to suspend mode echo "/usr/bin/apm -s" | at now fi else echo "/usr/bin/apm -s" | at now fi