#!/bin/bash # This file must be executable to work! chmod 755! # # This script will close LUKS filesystem if not in use # # Install in cron to run regularly CRYPTSETUP=/sbin/cryptsetup shopt -s nullglob for dev in /dev/mapper/*_autocrypt do match=`mount|grep $dev` if [ -z "$match" ]; then # fs is not mounted, LUKS fs can be closed dm_file=${dev##*/} $CRYPTSETUP luksClose $dm_file fi done