#! /bin/sh
set -e

if grep -q " device-mapper$" /proc/misc; then
	# We can't check the root node directly because root could be
	# on an LVM LV on top of an encrypted device
	if type dmsetup >/dev/null 2>&1 && \
	   dmsetup table | cut -d' ' -f4 | grep -q "crypt" 2>/dev/null; then
		apt-install cryptsetup
	fi
fi
