summaryrefslogtreecommitdiff
path: root/share/hooks/normal/0030-enable-cryptsetup.hook.chroot
blob: 0dc4aaa3eb2af774e47e136f643588c22d4299b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh

set -e

# Enable cryptsetup

if [ -e /sbin/cryptsetup ]
then
	if [ ! -e /etc/initramfs-tools/conf.d/cryptsetup ]
	then
		mkdir -p /etc/initramfs-tools/conf.d

		cat > /etc/initramfs-tools/conf.d/cryptsetup <<-EOF
		# /etc/initramfs-tools/conf.d/cryptsetup

		CRYPTSETUP=yes
		export CRYPTSETUP
		EOF

	fi

	if [ -e /etc/cryptsetup-initramfs/conf-hook ]; then
		if grep -q '^#CRYPTSETUP=' /etc/cryptsetup-initramfs/conf-hook; then
			sed -i -e 's/^#CRYPTSETUP=.*/CRYPTSETUP=y/' \
			    /etc/cryptsetup-initramfs/conf-hook
		else
			echo "CRYPTSETUP=y" >>/etc/cryptsetup-initramfs/conf-hook
		fi
	fi
fi