home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / usr / lib / hal / scripts / linux / hal-luks-remove-linux next >
Text File  |  2006-11-29  |  1KB  |  44 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. echo LUKS cryptotext device $HAL_PROP_INFO_UDI is going away
  11.  
  12. # make sure that the cleartext volume is unmounted
  13. CLEARTEXT_VOLUME_UDI=`hal-find-by-property --key volume.crypto_luks.clear.backing_volume --string $HAL_PROP_INFO_UDI`
  14. RET=$?
  15. if [ x$RET = x0 ]; then
  16.     echo Attempting unmount of corresponding LUKS cleartext volume $CLEARTEXT_VOLUME_UDI
  17.     # lazy unmount via D-BUS
  18.     dbus-send --print-reply --system \
  19.           --dest=org.freedesktop.Hal \
  20.           $CLEARTEXT_VOLUME_UDI \
  21.           org.freedesktop.Hal.Device.Volume.Unmount \
  22.           array:string:lazy
  23. fi
  24.  
  25. echo Tearing down LUKS cryptotext volume
  26.  
  27. if [ ! -f $CRYPTSETUP ]; then
  28.     echo Error removing $HAL_PROP_BLOCK_DEVICE - $CRYPTSETUP not found >&2
  29.     exit 1
  30. fi
  31.  
  32. if [ -z $HAL_PROP_VOLUME_UUID ]; then
  33.     echo Error determining UUID of $HAL_PROP_BLOCK_DEVICE >&2
  34.     exit 1
  35. fi
  36.  
  37. if ! $CRYPTSETUP luksClose luks_crypto_$HAL_PROP_VOLUME_UUID 2> /dev/null; then
  38.     echo Error removing luks_crypto_$HAL_PROP_VOLUME_UUID >&2
  39.     exit 1
  40. fi
  41.  
  42. exit 0
  43.