@@ -1,95 +1,95 | |||
|
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 |
if |
|
|
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 | 48 | install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}/dropbear-initramfs/id_rsa.pub" |
|
49 | 49 | cat /etc/dropbear-initramfs/id_rsa.pub >> /etc/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 | 58 | touch /etc/dropbear-initramfs/id_rsa.pub |
|
59 | 59 | chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub |
|
60 | 60 | |
|
61 | 61 | # Delete unwanted lines |
|
62 | 62 | sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub |
|
63 | 63 | sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub |
|
64 | 64 | |
|
65 | 65 | # Trust the new key |
|
66 | 66 | touch "${ETC_DIR}"/dropbear-initramfs/authorized_keys |
|
67 | 67 | cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub | chroot_exec tee -a "${ETC_DIR}"/dropbear-initramfs/authorized_keys |
|
68 | 68 | |
|
69 | 69 | # Save Keys - convert with putty from rsa/openssh to puttkey |
|
70 | 70 | cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa |
|
71 | 71 | |
|
72 | 72 | #Get unlock script |
|
73 | 73 | install_exec files/initramfs/crypt_unlock.sh "${ETC_DIR}/initramfs-tools/hooks/crypt_unlock.sh" |
|
74 | 74 | fi |
|
75 | 75 | else |
|
76 | 76 | # Disable SSHD inside initramfs |
|
77 | 77 | printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf" |
|
78 | 78 | fi |
|
79 | 79 | |
|
80 | 80 | # Add cryptsetup modules to initramfs |
|
81 | 81 | printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook" |
|
82 | 82 | |
|
83 | 83 | # Dummy mapping required by mkinitramfs |
|
84 | 84 | echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}" |
|
85 | 85 | |
|
86 | 86 | # Generate initramfs with encrypted root partition support |
|
87 | 87 | chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" |
|
88 | 88 | |
|
89 | 89 | # Remove dummy mapping |
|
90 | 90 | chroot_exec cryptsetup close "${CRYPTFS_MAPPING}" |
|
91 | 91 | else |
|
92 | 92 | # Generate initramfs without encrypted root partition support |
|
93 | 93 | chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}" |
|
94 | 94 | fi |
|
95 | 95 | fi |
@@ -1,107 +1,99 | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | # |
|
3 | 3 | # Build and Setup nexmon with monitor mode patch |
|
4 | 4 | # |
|
5 | 5 | |
|
6 | 6 | # Load utility functions |
|
7 | 7 | . ./functions.sh |
|
8 | 8 | |
|
9 | 9 | if [ "$ENABLE_NEXMON" = true ] && [ "$ENABLE_WIRELESS" = true ]; then |
|
10 | 10 | # Copy existing nexmon sources into chroot directory |
|
11 | 11 | if [ -n "$NEXMONSRC_DIR" ] && [ -d "$NEXMONSRC_DIR" ] ; then |
|
12 | 12 | # Copy local U-Boot sources |
|
13 | 13 | cp -r "${NEXMONSRC_DIR}" "${R}/tmp" |
|
14 | 14 | else |
|
15 | 15 | # Create temporary directory for nexmon sources |
|
16 | 16 | temp_dir=$(as_nobody mktemp -d) |
|
17 | 17 | |
|
18 | 18 | # Fetch nexmon sources |
|
19 | 19 | as_nobody git -C "${temp_dir}" clone "${NEXMON_URL}" |
|
20 | 20 | |
|
21 | 21 | # Copy downloaded nexmon sources |
|
22 | 22 | mv "${temp_dir}/nexmon" "${R}"/tmp/ |
|
23 | 23 | |
|
24 | 24 | # Set permissions of the nexmon sources |
|
25 | 25 | chown -R root:root "${R}"/tmp/nexmon |
|
26 | 26 | |
|
27 | 27 | # Remove temporary directory for nexmon sources |
|
28 | 28 | rm -fr "${temp_dir}" |
|
29 | 29 | fi |
|
30 | 30 | |
|
31 | 31 | # Set script Root |
|
32 | 32 | export NEXMON_ROOT="${R}"/tmp/nexmon |
|
33 | 33 | |
|
34 | 34 | # Build nexmon firmware outside the build system, if we can. |
|
35 | 35 | cd "${NEXMON_ROOT}" || exit |
|
36 | 36 | |
|
37 | 37 | # Make ancient isl build |
|
38 | 38 | cd buildtools/isl-0.10 || exit |
|
39 | 39 | ./configure |
|
40 | 40 | make |
|
41 | 41 | cd ../.. || exit |
|
42 | 42 | |
|
43 | 43 | # Disable statistics |
|
44 | 44 | touch DISABLE_STATISTICS |
|
45 | 45 | |
|
46 | 46 | # Setup Enviroment: see https://github.com/NoobieDog/nexmon/blob/master/setup_env.sh |
|
47 | #ARCH="${KERNEL_ARCH}" | |
|
48 | #SUBARCH="${KERNEL_ARCH}" | |
|
49 | 47 | export KERNEL="${KERNEL_IMAGE}" |
|
50 | 48 | export ARCH=arm |
|
51 | 49 | export SUBARCH=arm |
|
52 | 50 | export CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
53 | 51 | export CC="${CC}"gcc |
|
54 | 52 | export CCPLUGIN="${NEXMON_ROOT}"/buildtools/gcc-nexmon-plugin/nexmon.so |
|
55 | 53 | export ZLIBFLATE="zlib-flate -compress" |
|
56 | 54 | export Q=@ |
|
57 | 55 | export NEXMON_SETUP_ENV=1 |
|
58 | 56 | export HOSTUNAME=$(uname -s) |
|
59 | 57 | export PLATFORMUNAME=$(uname -m) |
|
60 | #. ./setup_env.sh | |
|
61 | 58 |
|
|
62 | 59 | # Make nexmon |
|
63 | 60 | make |
|
64 | 61 | |
|
65 | # Backup stock broadcom wlan driver - "${LIB_DIR}"/modules/${KERNEL_VERSION}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko | |
|
66 | #brcmfmac_path=$(modinfo brcmfmac | grep -m 1 -oP "^filename:(\s*?)(.*)$" | sed -e 's/^filename:\(\s*\)\(.*\)$/\2/g') | |
|
67 | #brcmfmac_path="${LIB_DIR}"/modules/"${KERNEL_VERSION}"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko | |
|
68 | #mv "${brcmfmac_path}" "${brcmfmac_path}".orig | |
|
69 | ||
|
70 | # | |
|
71 | ||
|
72 | 62 | # build patches |
|
73 | 63 | if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] ; then |
|
74 | 64 | cd "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon || exit |
|
65 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43430a1/7_45_41_46/nexmon/Makefile | |
|
75 | 66 | make clean |
|
76 | 67 | |
|
77 | 68 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
78 | 69 | LD_LIBRARY_PATH="${NEXMON_ROOT}"/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
79 | 70 | |
|
80 | 71 | # copy RPi0W & RPi3 firmware |
|
81 | 72 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.org.bin |
|
82 | 73 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.nexmon.bin |
|
83 | 74 | cp -f "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac43430-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43430-sdio.bin |
|
84 | 75 | |
|
85 | 76 | cp "${NEXMON_ROOT}"/patches/bcm43430a1/7_45_41_46/nexmon/brcmfmac_4.14.y-nexmon/brcmfmac.ko "${brcmfmac_path}" |
|
86 | 77 | fi |
|
87 | 78 | |
|
88 | 79 | if [ "$RPI_MODEL" = 3P ] ; then |
|
89 | 80 | cd "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon || exit |
|
81 | sed -i -e 's/all:.*/all: $(RAM_FILE)/g' ${NEXMON_ROOT}/patches/bcm43455c0/7_45_154/nexmon/Makefile | |
|
90 | 82 | make clean |
|
91 | 83 | |
|
92 | 84 | # We do this so we don't have to install the ancient isl version into /usr/local/lib on systems. |
|
93 | 85 | LD_LIBRARY_PATH=${NEXMON_ROOT}/buildtools/isl-0.10/.libs make ARCH="${KERNEL_ARCH}" CC="${NEXMON_ROOT}"/buildtools/gcc-arm-none-eabi-5_4-2016q2-linux-x86/bin/arm-none-eabi- |
|
94 | 86 | |
|
95 | 87 | # RPi3B+ firmware |
|
96 | 88 | mv "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.org.bin |
|
97 | 89 | cp "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.nexmon.bin |
|
98 | 90 | cp -f "${NEXMON_ROOT}"/patches/bcm43455c0/7_45_154/nexmon/brcmfmac43455-sdio.bin "${WLAN_FIRMWARE_DIR}"/brcmfmac43455-sdio.bin |
|
99 | 91 | fi |
|
100 | 92 | |
|
101 | 93 | #Revert to previous directory |
|
102 | 94 | cd "${WORKDIR}" || exit |
|
103 | 95 | |
|
104 | 96 | # Remove nexmon sources |
|
105 | 97 | rm -fr "${NEXMON_ROOT}" |
|
106 | 98 | |
|
107 | 99 | fi |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant