##// END OF EJS Templates
a
Unknown -
r485:6ab6d0f12a3f
parent child
Show More
@@ -1,95 +1,93
1 1 #
2 2 # Setup fstab and initramfs
3 3 #
4 4
5 5 # Load utility functions
6 6 . ./functions.sh
7 7
8 8 # Install and setup fstab
9 9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10 10
11 11 if [ "$ENABLE_UBOOTUSB" = true ] ; then
12 12 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
13 13 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
14 14 fi
15 15
16 16 # Add usb/sda disk root partition to fstab
17 17 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
18 18 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
19 19 fi
20 20
21 21 # Add encrypted root partition to fstab and crypttab
22 22 if [ "$ENABLE_CRYPTFS" = true ] ; then
23 23 # Replace fstab root partition with encrypted partition mapping
24 24 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
25 25
26 26 # Add encrypted partition to crypttab and fstab
27 27 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
28 28 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
29 29
30 30 if [ "$ENABLE_SPLITFS" = true ] ; then
31 31 # Add usb/sda disk to crypttab
32 32 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
33 33 fi
34 34 fi
35 35
36 36 # Generate initramfs file
37 37 if [ "$ENABLE_INITRAMFS" = true ] ; then
38 38 if [ "$ENABLE_CRYPTFS" = true ] ; then
39 39 # Include initramfs scripts to auto expand encrypted root partition
40 40 if [ "$EXPANDROOT" = true ] ; then
41 41 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
42 42 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
43 43 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
44 44 fi
45 45
46 46 if [ "$CRYPTFS_DROPBEAR" = true ]; then
47 47 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
48 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}/dropbear-initramfs/id_rsa.pub"
49 cat /etc/dropbear-initramfs/id_rsa.pub >> /etc/dropbear-initramfs/authorized_keys
48 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
49 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
50 50 else
51 51 # Create key
52 52 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
53 53
54 54 # Convert dropbear key to openssh key
55 55 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
56 56
57 57 # Get Public Key Part
58 touch /etc/dropbear-initramfs/id_rsa.pub
59 58 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
60 59
61 60 # Delete unwanted lines
62 61 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
63 62 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
64 63
65 64 # Trust the new key
66 touch "${ETC_DIR}"/dropbear-initramfs/authorized_keys
67 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub | chroot_exec tee -a "${ETC_DIR}"/dropbear-initramfs/authorized_keys
65 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
68 66
69 67 # Save Keys - convert with putty from rsa/openssh to puttkey
70 68 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
71 69
72 70 #Get unlock script
73 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}/initramfs-tools/hooks/crypt_unlock.sh"
71 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
74 72 fi
75 73 else
76 74 # Disable SSHD inside initramfs
77 75 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
78 76 fi
79 77
80 78 # Add cryptsetup modules to initramfs
81 79 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
82 80
83 81 # Dummy mapping required by mkinitramfs
84 82 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
85 83
86 84 # Generate initramfs with encrypted root partition support
87 85 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
88 86
89 87 # Remove dummy mapping
90 88 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
91 89 else
92 90 # Generate initramfs without encrypted root partition support
93 91 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
94 92 fi
95 93 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant