##// END OF EJS Templates
fix?
Unknown -
r614:c58e74227b89
parent child
Show More
@@ -1,111 +1,115
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 # Add usb/sda disk root partition to fstab
12 12 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
13 13 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
14 14 fi
15 15
16 16 # Add encrypted root partition to fstab and crypttab
17 17 if [ "$ENABLE_CRYPTFS" = true ] ; then
18 18 # Replace fstab root partition with encrypted partition mapping
19 19 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
20 20
21 21 # Add encrypted partition to crypttab and fstab
22 22 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
23 23 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
24 24
25 25 if [ "$ENABLE_SPLITFS" = true ] ; then
26 26 # Add usb/sda1 disk to crypttab
27 27 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
28 28 fi
29 29 fi
30 30
31 31 if [ "$ENABLE_USBBOOT" = true ] ; then
32 32 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
33 33 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
34 34
35 35 # Add usb/sda2 disk to crypttab
36 36 if [ "$ENABLE_CRYPTFS" = true ] ; then
37 37 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/crypttab"
38 38 fi
39 39 fi
40 40
41 41 # Generate initramfs file
42 42 if [ "$ENABLE_INITRAMFS" = true ] ; then
43 # Generate initramfs without encrypted root partition support
44 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
45
43 46 if [ "$ENABLE_CRYPTFS" = true ] ; then
44 47 # Include initramfs scripts to auto expand encrypted root partition
45 48 if [ "$EXPANDROOT" = true ] ; then
46 49 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
47 50 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
48 51 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
49 52 fi
50 53
51 54 if [ "$ENABLE_DHCP" = false ] ; then
52 55 # Get cdir from NET_ADDRESS e.g. 24
53 56 cdir=$(printf ${NET_ADDRESS} | cut -d '/' -f2)
54 57
55 58 # Convert cdir ro netmask e.g. 24 to 255.255.255.0
56 59 NET_MASK=$(cdr2mask "$cdir")
57 60
58 61 # Write static ip settings to "${ETC_DIR}"/initramfs-tools/initramfs.conf
59 62 sed -i "\$aIP=${NET_ADDRESS}::${NET_GATEWAY}:${NET_MASK}:${HOSTNAME}:" "${ETC_DIR}"/initramfs-tools/initramfs.conf
60 63 fi
61 64
62 65 if [ "$CRYPTFS_DROPBEAR" = true ]; then
63 66 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
64 67 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
65 68 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
66 69 else
67 70 # Create key
68 71 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
69 72
70 73 # Convert dropbear key to openssh key
71 74 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
72 75
73 76 # Get Public Key Part
74 77 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
75 78
76 79 # Delete unwanted lines
77 80 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
78 81 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
79 82
80 83 # Trust the new key
81 84 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
82 85
83 86 # Save Keys - convert with putty from rsa/openssh to puttkey
84 87 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
85 88 fi
86 89
87 90 # Get unlock script
88 91 install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}"/initramfs-tools/hooks/crypt_unlock.sh
89 92
90 93 # Enable Dropbear inside initramfs
91 94 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
92 95
93 96 # Enable Dropbear inside initramfs
94 97 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
95 98 else
96 99 # Disable SSHD inside initramfs
97 100 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
98 101 fi
99 102
100 103 # Add cryptsetup modules to initramfs
101 104 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
102 105
103 106 # Dummy mapping required by mkinitramfs
104 107 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
105 108
109 # Generate initramfs without encrypted root partition support
110 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
111
106 112 # Remove dummy mapping
107 113 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
108 114 fi
109 # Generate initramfs without encrypted root partition support
110 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
111 115 fi
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant