home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 November (DVD) / PCWELT_11_2006.ISO / casper / filesystem.squashfs / usr / share / hal / scripts / hal-system-storage-cleanup-mountpoints < prev    next >
Encoding:
Text File  |  2006-08-30  |  731 b   |  33 lines

  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2005, Kay Sievers <kay.sievers@vrfy.org>
  4. # Copyright (C) 2006, David Zeuthen <davidz@redhat.com>
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License version 2.
  8.  
  9. MOUNT_ROOT="/media"
  10.  
  11. for DIR in $MOUNT_ROOT/*; do
  12.  
  13.     # /proc/mounts substitute spaces with 040
  14.     DIRMOD=${DIR//[[:space:]]/040}
  15.  
  16.     # check if we created it
  17.     if [ -e "$DIR/.created-by-hal" ]; then
  18.     BUSY=0
  19.     while read dev dir type options; do
  20.         if [ "$dir" = "$DIRMOD" ]; then
  21.         BUSY=1
  22.         break
  23.         fi
  24.     done < /proc/mounts
  25.     if [ "$BUSY" != "1" ]; then
  26.         rm -f "$DIR/.created-by-hal"
  27.         rmdir --ignore-fail-on-non-empty "$DIR"
  28.     fi
  29.     fi
  30. done
  31.  
  32. exit 0
  33.