2 # auto-unmount floppy/cd directory before ejecting device
3 # script taken from Debian Linux's amd
5 # Package: am-utils-6.x
6 # (Additional) author: Erez Zadok <ezk@cs.columbia.edu>
10 exec_prefix
=@exec_prefix@
11 PATH
=@sbindir@
:@bindir@
:/usr
/ucb
:/usr
/bin
:/bin
:${PATH}
15 echo "Usage: $0 cd|cdrom|fd|floppy"
19 # determine toplevel mount point of amd
20 fs
=`amq | grep ' toplvl ' | cut -d' ' -f1`
21 if [ "$fs" = "" ]; then
22 echo "Cannot determine amd toplevel directory"
26 # append name of medium
29 *) echo "Usage: $0 cd|cdrom|fd|floppy"; exit 2;;
32 # is the medium mounted?
33 if amq |
grep -q "^$fs" >/dev
/null
2>&1; then
34 # if yes, try to unmount it
38 if amq |
grep -q "^$fs" >/dev
/null
2>&1; then
40 echo -n "Cannot unmount $fs; in use by:"
46 echo "$fs not mounted"
50 cd|cdrom
) eject cdrom || eject
;; # eject CD-ROM
51 fd|floppy
) eject floppy || eject
52 echo "Ok to remove disk" ;;