home *** CD-ROM | disk | FTP | other *** search
/ tusportal.tus.k12.pa.us / tusportal.tus.k12.pa.us.tar / tusportal.tus.k12.pa.us / Wyse / latest-image.raw / 0.img / usr / lib / hal / scripts / hal-luks-teardown < prev    next >
Text File  |  2010-05-09  |  2KB  |  60 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. . hal-functions
  9.  
  10. locked_out() {
  11.     echo "org.freedesktop.Hal.Device.InterfaceLocked" >&2
  12.     echo "Enclosing drive/volume is locked" >&2
  13.     exit 1
  14. }
  15.  
  16. unknown_error() {
  17.         echo "org.freedesktop.Hal.Device.UnknownError" >&2
  18.         echo "Missing or empty environment variable(s)." >&2
  19.         echo "This script should be started by hald." >&2
  20.         exit 1
  21. }
  22.  
  23. # Check for environment variables
  24. if [ -z "$HAL_PROP_BLOCK_DEVICE" ] || [ -z "$HAL_PROP_INFO_UDI" ] || [ -z "$HAL_PROP_VOLUME_UUID" ] ; then
  25.     unknown_error
  26. fi
  27.  
  28. # Respect the same locks as Mount()/Unmount() etc.
  29. if [ -n "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME" ] ; then
  30.     hal-is-caller-locked-out --udi $HAL_PROP_INFO_UDI \
  31.         --interface org.freedesktop.Hal.Device.Volume \
  32.         --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
  33.     RET=$?
  34.     if [ "$RET" != "0" ] ; then
  35.         locked_out
  36.     fi
  37.     hal-is-caller-locked-out --udi $HAL_PROP_BLOCK_STORAGE_DEVICE \
  38.         --interface org.freedesktop.Hal.Device.Storage \
  39.         --caller "$HAL_METHOD_INVOKED_BY_SYSTEMBUS_CONNECTION_NAME"
  40.     RET=$?
  41.     if [ "$RET" != "0" ] ; then
  42.         locked_out
  43.     fi
  44. fi
  45.  
  46. # TODO: this is a little sketchy; we should check for hal-storage-crypto-teardown-others?
  47. #
  48. IS_HOTPLUGGABLE=`hal-get-property --udi $HAL_PROP_BLOCK_STORAGE_DEVICE --key storage.hotpluggable`
  49. if [ "$IS_HOTPLUGGABLE" == "true" ] ; then
  50.     ACTION="org.freedesktop.hal.storage.crypto-setup-removable"
  51. elif [ "$IS_HOTPLUGGABLE" == "false" ] ; then
  52.     ACTION="org.freedesktop.hal.storage.crypto-setup-fixed"
  53. else
  54.     unknown_error
  55. fi
  56.  
  57. hal_check_priv $ACTION
  58. hal_exec_backend
  59.