TrueCrypt volumes unmount script on hibernate/sleep added
[truecrypt-extra.git] / etc.pm.sleep-d.20_unmount-truecrypt-containers
diff --git a/etc.pm.sleep-d.20_unmount-truecrypt-containers b/etc.pm.sleep-d.20_unmount-truecrypt-containers
new file mode 100755 (executable)
index 0000000..d5995e6
--- /dev/null
@@ -0,0 +1,31 @@
+#! /bin/sh
+
+### TrueCrypt PM Sleep Unmounter
+### This file is a part of `truecrypt-extra`
+###
+### (c) Andrew Sichevoi, http://thekondor.net
+### Distributed in the terms of GNU GPL v3.0+ license
+###
+### The latest version is available on http://git.thekondor.net
+
+if [ -f /etc/default/truecrypt ]; then
+  . /etc/default/truecrypt
+fi
+
+unmount_all_truecrypt_volumes ()
+{
+  ${TRUECRYPT_BINARY} -d
+}
+
+case $1 in
+  suspend|suspend_hybrid|hibernate)
+    if "${UNMOUNT_ON_SLEEP}"; then
+           unmount_all_truecrypt_volumes
+    fi
+  ;;
+  resume|thaw)
+         ### There is no need to do anything here
+       :
+  ;;
+esac
+