File: crypto_aptinstall

package info (click to toggle)
partman-crypto 57
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,664 kB
  • sloc: sh: 1,956; ansic: 172; makefile: 33
file content (64 lines) | stat: -rwxr-xr-x 1,197 bytes parent folder | download | duplicates (3)
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
#!/bin/sh

# Installs userspace tools and helper packages in the target system.
#
# Things to install
# * loop-AES: loop-aes-utils, loop-aes-rootfs (TODO) and loop keys
# * cryptsetup: relies on base-installer instead

. /lib/partman/lib/base.sh

loop_AES=no
dm_crypt=no

install_loopkeys () {
	dir=/target/etc/loopkeys
	if [ ! -d $dir ]; then
		mkdir -p $dir
		chmod 0700 $dir
	fi

	for key in $*; do
		name=${key##*/}
		if [ -f $dir/$name ]; then
			: TODO show error
		else
			mv $key $dir/$name
			chmod 0600 $dir/$name
		fi
	done
}

for dev in $DEVICES/*; do
	[ -d "$dev" ] || continue
	cd $dev
	open_dialog PARTITIONS
	while { read_line num id size type fs path name; [ "$id" ]; }; do
		[ "$fs" != free ] || continue
		[ -f $id/method ] || continue
		[ -f $id/crypto_type ] || continue

		method=$(cat $id/method)
		[ $method = crypto ] || continue

		type=$(cat $id/crypto_type)
		case $type in
			loop-AES)
				loop_AES=yes
				if [ -f $id/keyfile ]; then
					key=$(cat $id/keyfile)
					install_loopkeys "$key"
				fi
				;;
			dm-crypt)
				dm_crypt=yes
				;;
		esac
	done
	close_dialog
done

if [ $loop_AES = yes ]; then
	# TODO loop-aes-rootfs
	apt-install loop-aes-utils || true
fi