home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / hal / scripts / linux / hal-luks-remove-linux < prev    next >
Encoding:
Text File  |  2009-07-05  |  1.6 KB  |  53 lines

  1. #!/bin/bash
  2.  
  3. # Copyright (C) 2005 W. Michael Petullo <mike@flyn.org>
  4. # Copyright (C) 2006 David Zeuthen <davidz@redhat.com>
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License version 2.
  7.  
  8. CRYPTSETUP=/sbin/cryptsetup
  9.  
  10. if [ ! -f $CRYPTSETUP ]; then
  11.     echo org.freedesktop.Hal.Device.Volume.Crypto.CryptSetupMissing >&2
  12.     echo Error remove $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
  13.     exit 1
  14. fi
  15.  
  16. echo LUKS cryptotext device $HAL_PROP_INFO_UDI is going away
  17.  
  18. # make sure that the cleartext volume is unmounted
  19. CLEARTEXT_VOLUME_UDI=`hal-find-by-property --key volume.crypto_luks.clear.backing_volume --string $HAL_PROP_INFO_UDI`
  20. RET=$?
  21. if [ x$RET = x0 ]; then
  22.     echo Attempting unmount of corresponding LUKS cleartext volume $CLEARTEXT_VOLUME_UDI
  23.     # lazy unmount via D-BUS
  24.     dbus-send --print-reply --system \
  25.           --dest=org.freedesktop.Hal \
  26.           $CLEARTEXT_VOLUME_UDI \
  27.           org.freedesktop.Hal.Device.Volume.Unmount \
  28.           array:string:lazy
  29. fi
  30.  
  31. echo Tearing down LUKS cryptotext volume
  32.  
  33. if [ ! -f $CRYPTSETUP ]; then
  34.     echo org.freedesktop.Hal.Device.Volume.Crypto.RemoveError >&2
  35.     echo Error removing $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
  36.     exit 1
  37. fi
  38.  
  39. if [ -z $HAL_PROP_VOLUME_UUID ]; then
  40.     echo org.freedesktop.Hal.Device.Volume.Crypto.RemoveError >&2
  41.     echo Error determining UUID of $HAL_PROP_BLOCK_DEVICE >&2
  42.     exit 1
  43. fi
  44.  
  45. if ! $CRYPTSETUP luksClose luks_crypto_$HAL_PROP_VOLUME_UUID 2> /dev/null; then
  46.     echo org.freedesktop.Hal.Device.Volume.Crypto.RemoveError >&2
  47.     echo Error removing luks_crypto_$HAL_PROP_VOLUME_UUID >&2
  48.     exit 1
  49. fi
  50.  
  51. exit 0
  52.