~ubuntu-branches/ubuntu/oneiric/partman-crypto/oneiric

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/sh
#
# This script is run by finish-install after the kernel was chosen.
# It installs a corresponding loop-aes-$KVERS module if any loop-AES
# encrypted partitions have been configured.
#

. /usr/share/debconf/confmodule

loop_AES=no
loop_AES_root=no

for dev in /var/lib/partman/devices/*; do
	[ -d "$dev" ] || continue
	cd $dev
	for id in *; do
		[ -f $id/crypto_type ] || continue
		[ -f $id/crypt_active ] || continue

		type=$(cat $id/crypto_type)
		if [ "$type" = loop-AES ]; then
			loop_AES=yes
		fi
	done

	if [ -f crypt_realdev ]; then
		r=$(cat crypt_realdev)
		set -- $(IFS=: && echo $r)
		cpart=$3

		for id in *; do
			[ -f $id/mountpoint ] || continue
			mnt=$(cat $id/mountpoint)
			if [ "$mnt" = / ]; then
				[ -f $cpart/crypto_type ] || continue
				type=$(cat $cpart/crypto_type)
				if [ "$type" = loop-AES ]; then
					loop_AES_root=yes
					break
				fi
			fi
		done
	fi
done

if [ $loop_AES = yes ]; then
	cat > /target/etc/default/checkfs-loop <<END
# Check loop-backed file systems at startup?
CHECKFS_LOOP_ENABLE=yes
END

	db_get base-installer/kernel/image
	KVERS=${RET#*-image-}

	if ! apt-install loop-aes-modules-$KVERS; then
		templ="partman-crypto/module_package_missing"
		db_fset $templ seen false
		db_subst $templ PACKAGE loop-aes-modules-$KVERS
		db_input critical $templ
		db_go
		exit 1
	fi

	if [ "$loop_AES_root" = yes ]; then
		# We need to regenerate the initramfs because
		# loop-aes-utils + loop-aes-modules-$KVERS were
		# installed after the kernel
		in-target update-initramfs -u -k all
	fi
fi