##// END OF EJS Templates
a
Unknown -
r512:1a81d60fec0b
parent child
Show More
@@ -1,99 +1,96
1 #
1 #
2 # Setup fstab and initramfs
2 # Setup fstab and initramfs
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 # Install and setup fstab
8 # Install and setup fstab
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
9 install_readonly files/mount/fstab "${ETC_DIR}/fstab"
10
10
11 if [ "$ENABLE_UBOOTUSB" = true ] ; then
11 if [ "$ENABLE_UBOOTUSB" = true ] ; then
12 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
12 sed -i "s/mmcblk0p1/sda1/" "${ETC_DIR}/fstab"
13 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
13 sed -i "s/mmcblk0p2/sda2/" "${ETC_DIR}/fstab"
14 fi
14 fi
15
15
16 # Add usb/sda disk root partition to fstab
16 # Add usb/sda disk root partition to fstab
17 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
17 if [ "$ENABLE_SPLITFS" = true ] && [ "$ENABLE_CRYPTFS" = false ] ; then
18 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
18 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/fstab"
19 fi
19 fi
20
20
21 # Add encrypted root partition to fstab and crypttab
21 # Add encrypted root partition to fstab and crypttab
22 if [ "$ENABLE_CRYPTFS" = true ] ; then
22 if [ "$ENABLE_CRYPTFS" = true ] ; then
23 # Replace fstab root partition with encrypted partition mapping
23 # Replace fstab root partition with encrypted partition mapping
24 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
24 sed -i "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING}/" "${ETC_DIR}/fstab"
25
25
26 # Add encrypted partition to crypttab and fstab
26 # Add encrypted partition to crypttab and fstab
27 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
27 install_readonly files/mount/crypttab "${ETC_DIR}/crypttab"
28 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
28 echo "${CRYPTFS_MAPPING} /dev/mmcblk0p2 none luks,initramfs" >> "${ETC_DIR}/crypttab"
29
29
30 if [ "$ENABLE_SPLITFS" = true ] ; then
30 if [ "$ENABLE_SPLITFS" = true ] ; then
31 # Add usb/sda disk to crypttab
31 # Add usb/sda disk to crypttab
32 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
32 sed -i "s/mmcblk0p2/sda1/" "${ETC_DIR}/crypttab"
33 fi
33 fi
34 fi
34 fi
35
35
36 # Generate initramfs file
36 # Generate initramfs file
37 if [ "$ENABLE_INITRAMFS" = true ] ; then
37 if [ "$ENABLE_INITRAMFS" = true ] ; then
38 if [ "$ENABLE_CRYPTFS" = true ] ; then
38 if [ "$ENABLE_CRYPTFS" = true ] ; then
39 # Include initramfs scripts to auto expand encrypted root partition
39 # Include initramfs scripts to auto expand encrypted root partition
40 if [ "$EXPANDROOT" = true ] ; then
40 if [ "$EXPANDROOT" = true ] ; then
41 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
41 install_exec files/initramfs/expand_encrypted_rootfs "${ETC_DIR}/initramfs-tools/scripts/init-premount/expand_encrypted_rootfs"
42 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
42 install_exec files/initramfs/expand-premount "${ETC_DIR}/initramfs-tools/scripts/local-premount/expand-premount"
43 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
43 install_exec files/initramfs/expand-tools "${ETC_DIR}/initramfs-tools/hooks/expand-tools"
44 fi
44 fi
45
45
46 if [ "$CRYPTFS_DROPBEAR" = true ]; then
46 if [ "$CRYPTFS_DROPBEAR" = true ]; then
47 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
47 if [ -n "$CRYPTFS_DROPBEAR_PUBKEY" ] && [ -f "$CRYPTFS_DROPBEAR_PUBKEY" ] ; then
48 install_readonly "${CRYPTFS_DROPBEAR_PUBKEY}" "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
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
49 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub >> "${ETC_DIR}"/dropbear-initramfs/authorized_keys
50 else
50 else
51 # Create key
51 # Create key
52 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
52 chroot_exec /usr/bin/dropbearkey -t rsa -f /etc/dropbear-initramfs/id_rsa.dropbear
53
53
54 # Convert dropbear key to openssh key
54 # Convert dropbear key to openssh key
55 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
55 chroot_exec /usr/lib/dropbear/dropbearconvert dropbear openssh /etc/dropbear-initramfs/id_rsa.dropbear /etc/dropbear-initramfs/id_rsa
56
56
57 # Get Public Key Part
57 # Get Public Key Part
58 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
58 chroot_exec /usr/bin/dropbearkey -y -f /etc/dropbear-initramfs/id_rsa.dropbear | chroot_exec tee /etc/dropbear-initramfs/id_rsa.pub
59
59
60 # Delete unwanted lines
60 # Delete unwanted lines
61 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
61 sed -i '/Public/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
62 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
62 sed -i '/Fingerprint/d' "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub
63
63
64 # Trust the new key
64 # Trust the new key
65 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
65 cat "${ETC_DIR}"/dropbear-initramfs/id_rsa.pub > "${ETC_DIR}"/dropbear-initramfs/authorized_keys
66
66
67 # Save Keys - convert with putty from rsa/openssh to puttkey
67 # Save Keys - convert with putty from rsa/openssh to puttkey
68 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
68 cp -f "${ETC_DIR}"/dropbear-initramfs/id_rsa "${BASEDIR}"/dropbear_initramfs_key.rsa
69
69
70 # Get unlock script
70 # Get unlock script
71 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
72
72
73 # Enable Dropbear inside initramfs
73 # Enable Dropbear inside initramfs
74 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
74 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=y\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
75
75
76 # Enable Dropbear inside initramfs
76 # Enable Dropbear inside initramfs
77 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
77 sed -i "54 i sleep 5" "${R}"/usr/share/initramfs-tools/scripts/init-premount/dropbear
78 fi
78 fi
79 else
79 else
80 # Disable SSHD inside initramfs
80 # Disable SSHD inside initramfs
81 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
81 printf "#\n# DROPBEAR: [ y | n ]\n#\n\nDROPBEAR=n\n" >> "${ETC_DIR}/initramfs-tools/initramfs.conf"
82 fi
82 fi
83
83
84 # Add cryptsetup modules to initramfs
84 # Add cryptsetup modules to initramfs
85 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
85 printf "#\n# CRYPTSETUP: [ y | n ]\n#\n\nCRYPTSETUP=y\n" >> "${ETC_DIR}/initramfs-tools/conf-hook"
86
86
87 # Dummy mapping required by mkinitramfs
87 # Dummy mapping required by mkinitramfs
88 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
88 echo "0 1 crypt $(echo "${CRYPTFS_CIPHER}" | cut -d ':' -f 1) ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 0 7:0 4096" | chroot_exec dmsetup create "${CRYPTFS_MAPPING}"
89
89
90 # Generate initramfs with encrypted root partition support
91 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
92
93 # Remove dummy mapping
90 # Remove dummy mapping
94 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
91 chroot_exec cryptsetup close "${CRYPTFS_MAPPING}"
95 else
96 # Generate initramfs without encrypted root partition support
97 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
98 fi
92 fi
93
94 # Generate initramfs
95 chroot_exec mkinitramfs -o "/boot/firmware/initramfs-${KERNEL_VERSION}" "${KERNEL_VERSION}"
99 fi
96 fi
@@ -1,271 +1,271
1 #
1 #
2 # Setup RPi2/3 config and cmdline
2 # Setup RPi2/3 config and cmdline
3 #
3 #
4
4
5 # Load utility functions
5 # Load utility functions
6 . ./functions.sh
6 . ./functions.sh
7
7
8 #if [ "$BUILD_KERNEL" = true ] ; then
8 #if [ "$BUILD_KERNEL" = true ] ; then
9 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
9 if [ -n "$RPI_FIRMWARE_DIR" ] && [ -d "$RPI_FIRMWARE_DIR" ] ; then
10 # Install boot binaries from local directory
10 # Install boot binaries from local directory
11 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
11 cp "${RPI_FIRMWARE_DIR}"/boot/bootcode.bin "${BOOT_DIR}"/bootcode.bin
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
12 cp "${RPI_FIRMWARE_DIR}"/boot/fixup.dat "${BOOT_DIR}"/fixup.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
13 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_cd.dat "${BOOT_DIR}"/fixup_cd.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
14 cp "${RPI_FIRMWARE_DIR}"/boot/fixup_x.dat "${BOOT_DIR}"/fixup_x.dat
15 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
15 cp "${RPI_FIRMWARE_DIR}"/boot/start.elf "${BOOT_DIR}"/start.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
16 cp "${RPI_FIRMWARE_DIR}"/boot/start_cd.elf "${BOOT_DIR}"/start_cd.elf
17 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
17 cp "${RPI_FIRMWARE_DIR}"/boot/start_x.elf "${BOOT_DIR}"/start_x.elf
18 else
18 else
19 # Create temporary directory for boot binaries
19 # Create temporary directory for boot binaries
20 temp_dir=$(as_nobody mktemp -d)
20 temp_dir=$(as_nobody mktemp -d)
21
21
22 # Install latest boot binaries from raspberry/firmware github
22 # Install latest boot binaries from raspberry/firmware github
23 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
23 as_nobody wget -q -O "${temp_dir}/bootcode.bin" "${FIRMWARE_URL}/bootcode.bin"
24 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
24 as_nobody wget -q -O "${temp_dir}/fixup.dat" "${FIRMWARE_URL}/fixup.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
25 as_nobody wget -q -O "${temp_dir}/fixup_cd.dat" "${FIRMWARE_URL}/fixup_cd.dat"
26 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
26 as_nobody wget -q -O "${temp_dir}/fixup_x.dat" "${FIRMWARE_URL}/fixup_x.dat"
27 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
27 as_nobody wget -q -O "${temp_dir}/start.elf" "${FIRMWARE_URL}/start.elf"
28 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
28 as_nobody wget -q -O "${temp_dir}/start_cd.elf" "${FIRMWARE_URL}/start_cd.elf"
29 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
29 as_nobody wget -q -O "${temp_dir}/start_x.elf" "${FIRMWARE_URL}/start_x.elf"
30
30
31 # Move downloaded boot binaries
31 # Move downloaded boot binaries
32 mv "${temp_dir}/"* "${BOOT_DIR}/"
32 mv "${temp_dir}/"* "${BOOT_DIR}/"
33
33
34 # Remove temporary directory for boot binaries
34 # Remove temporary directory for boot binaries
35 rm -fr "${temp_dir}"
35 rm -fr "${temp_dir}"
36
36
37 # Set permissions of the boot binaries
37 # Set permissions of the boot binaries
38 chown -R root:root "${BOOT_DIR}"
38 chown -R root:root "${BOOT_DIR}"
39 chmod -R 600 "${BOOT_DIR}"
39 chmod -R 600 "${BOOT_DIR}"
40 fi
40 fi
41 #fi
41 #fi
42
42
43 # Setup firmware boot cmdline
43 # Setup firmware boot cmdline
44 if [ "$ENABLE_UBOOTUSB" = true ] ; then
44 if [ "$ENABLE_UBOOTUSB" = true ] ; then
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
45 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
46 else
46 else
47 if [ "$ENABLE_SPLITFS" = true ] ; then
47 if [ "$ENABLE_SPLITFS" = true ] ; then
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
48 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/sda1 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
49 else
49 else
50 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
50 CMDLINE="dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2 rootfstype=ext4 rootflags=commit=100,data=writeback elevator=deadline rootwait console=tty1 init=/bin/systemd"
51 fi
51 fi
52 fi
52 fi
53
53
54 # Add encrypted root partition to cmdline.txt
54 # Add encrypted root partition to cmdline.txt
55 if [ "$ENABLE_CRYPTFS" = true ] ; then
55 if [ "$ENABLE_CRYPTFS" = true ] ; then
56 if [ "$ENABLE_SPLITFS" = true ] ; then
56 if [ "$ENABLE_SPLITFS" = true ] ; then
57 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
57 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda1/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda1:${CRYPTFS_MAPPING}/")
58 else
58 else
59 if [ "$ENABLE_UBOOTUSB" = true ] ; then
59 if [ "$ENABLE_UBOOTUSB" = true ] ; then
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
60 CMDLINE=$(echo "${CMDLINE}" | sed "s/sda2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/sda2:${CRYPTFS_MAPPING}/")
61 else
61 else
62 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
62 CMDLINE=$(echo "${CMDLINE}" | sed "s/mmcblk0p2/mapper\/${CRYPTFS_MAPPING} cryptdevice=\/dev\/mmcblk0p2:${CRYPTFS_MAPPING}/")
63 fi
63 fi
64 fi
64 fi
65 fi
65 fi
66
66
67 # Enable Kernel messages on standard output
67 # Enable Kernel messages on standard output
68 if [ "$ENABLE_PRINTK" = true ] ; then
68 if [ "$ENABLE_PRINTK" = true ] ; then
69 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
69 install_readonly files/sysctl.d/83-rpi-printk.conf "${ETC_DIR}/sysctl.d/83-rpi-printk.conf"
70 fi
70 fi
71
71
72 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
72 # Install udev rule for serial alias - serial0 = console serial1=bluetooth
73 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
73 install_readonly files/etc/99-com.rules "${LIB_DIR}/udev/rules.d/99-com.rules"
74
74
75 # Remove IPv6 networking support
75 # Remove IPv6 networking support
76 if [ "$ENABLE_IPV6" = false ] ; then
76 if [ "$ENABLE_IPV6" = false ] ; then
77 CMDLINE="${CMDLINE} ipv6.disable=1"
77 CMDLINE="${CMDLINE} ipv6.disable=1"
78 fi
78 fi
79
79
80 # Automatically assign predictable network interface names
80 # Automatically assign predictable network interface names
81 if [ "$ENABLE_IFNAMES" = false ] ; then
81 if [ "$ENABLE_IFNAMES" = false ] ; then
82 CMDLINE="${CMDLINE} net.ifnames=0"
82 CMDLINE="${CMDLINE} net.ifnames=0"
83 else
83 else
84 CMDLINE="${CMDLINE} net.ifnames=1"
84 CMDLINE="${CMDLINE} net.ifnames=1"
85 fi
85 fi
86
86
87 # Install firmware config
87 # Install firmware config
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
88 install_readonly files/boot/config.txt "${BOOT_DIR}/config.txt"
89
89
90 # Locks CPU frequency at maximum
90 # Locks CPU frequency at maximum
91 if [ "$ENABLE_TURBO" = true ] ; then
91 if [ "$ENABLE_TURBO" = true ] ; then
92 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
92 echo "force_turbo=1" >> "${BOOT_DIR}/config.txt"
93 # helps to avoid sdcard corruption when force_turbo is enabled.
93 # helps to avoid sdcard corruption when force_turbo is enabled.
94 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
94 echo "boot_delay=1" >> "${BOOT_DIR}/config.txt"
95 fi
95 fi
96
96
97 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
97 if [ "$RPI_MODEL" = 0 ] || [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ] ; then
98
98
99 # Bluetooth enabled
99 # Bluetooth enabled
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
100 if [ "$ENABLE_BLUETOOTH" = true ] ; then
101 # Create temporary directory for Bluetooth sources
101 # Create temporary directory for Bluetooth sources
102 temp_dir=$(as_nobody mktemp -d)
102 temp_dir=$(as_nobody mktemp -d)
103
103
104 # Fetch Bluetooth sources
104 # Fetch Bluetooth sources
105 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
105 as_nobody git -C "${temp_dir}" clone "${BLUETOOTH_URL}"
106
106
107 # Copy downloaded sources
107 # Copy downloaded sources
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
108 mv "${temp_dir}/pi-bluetooth" "${R}/tmp/"
109
109
110 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
110 # Bluetooth firmware from arch aur https://aur.archlinux.org/packages/pi-bluetooth/
111 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
111 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" https://aur.archlinux.org/cgit/aur.git/plain/LICENCE.broadcom_bcm43xx?h=pi-bluetooth
112 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
112 as_nobody wget -q -O "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" https://aur.archlinux.org/cgit/aur.git/plain/BCM43430A1.hcd?h=pi-bluetooth
113
113
114 # Set permissions
114 # Set permissions
115 chown -R root:root "${R}/tmp/pi-bluetooth"
115 chown -R root:root "${R}/tmp/pi-bluetooth"
116
116
117 # Install tools
117 # Install tools
118 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
118 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/btuart" "${R}/usr/bin/btuart"
119 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
119 install_readonly "${R}/tmp/pi-bluetooth/usr/bin/bthelper" "${R}/usr/bin/bthelper"
120
120
121 # make scripts executable
121 # make scripts executable
122 chmod +x "${R}/usr/bin/bthelper"
122 chmod +x "${R}/usr/bin/bthelper"
123 chmod +x "${R}/usr/bin/btuart"
123 chmod +x "${R}/usr/bin/btuart"
124
124
125 # Install bluetooth udev rule
125 # Install bluetooth udev rule
126 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
126 install_readonly "${R}/tmp/pi-bluetooth/lib/udev/rules.d/90-pi-bluetooth.rules" "${LIB_DIR}/udev/rules.d/90-pi-bluetooth.rules"
127
127
128 # Install Firmware Flash file and apropiate licence
128 # Install Firmware Flash file and apropiate licence
129 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
129 mkdir -p "$BLUETOOTH_FIRMWARE_DIR"
130 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
130 install_readonly "${R}/tmp/pi-bluetooth/LICENCE.broadcom_bcm43xx" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
131 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
131 install_readonly "${R}/tmp/pi-bluetooth/BCM43430A1.hcd" "${BLUETOOTH_FIRMWARE_DIR}/LICENCE.broadcom_bcm43xx"
132 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
132 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.bthelper@.service" "${ETC_DIR}/systemd/system/pi-bluetooth.bthelper@.service"
133 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
133 install_readonly "${R}/tmp/pi-bluetooth/debian/pi-bluetooth.hciuart.service" "${ETC_DIR}/systemd/system/pi-bluetooth.hciuart.service"
134
134
135 # Remove temporary directories
135 # Remove temporary directories
136 rm -fr "${temp_dir}"
136 rm -fr "${temp_dir}"
137 rm -fr "${R}"/tmp/pi-bluetooth
137 rm -fr "${R}"/tmp/pi-bluetooth
138
138
139 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
139 # Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore UART0/ttyAMA0 over GPIOs 14 & 15. Slow Bluetooth and slow cpu. Use /dev/ttyS0 instead of /dev/ttyAMA0
140 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
140 if [ "$ENABLE_MINIUART_OVERLAY" = true ] ; then
141
141
142 # set overlay to swap ttyAMA0 and ttyS0
142 # set overlay to swap ttyAMA0 and ttyS0
143 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
143 echo "dtoverlay=pi3-miniuart-bt" >> "${BOOT_DIR}/config.txt"
144
144
145 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
145 # if force_turbo didn't lock cpu at high speed, lock it at low speed (XOR logic) or miniuart will be broken
146 if [ "$ENABLE_TURBO" = false ] ; then
146 if [ "$ENABLE_TURBO" = false ] ; then
147 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
147 echo "core_freq=250" >> "${BOOT_DIR}/config.txt"
148 fi
148 fi
149 fi
149 fi
150
150
151 # Activate services
151 # Activate services
152 chroot_exec systemctl enable pi-bluetooth.hciuart.service
152 chroot_exec systemctl enable pi-bluetooth.hciuart.service
153
153
154 else # if ENABLE_BLUETOOTH = false
154 else # if ENABLE_BLUETOOTH = false
155 # set overlay to disable bluetooth
155 # set overlay to disable bluetooth
156 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
156 echo "dtoverlay=pi3-disable-bt" >> "${BOOT_DIR}/config.txt"
157 fi # ENABLE_BLUETOOTH end
157 fi # ENABLE_BLUETOOTH end
158 fi
158 fi
159
159
160 # may need sudo systemctl disable hciuart
160 # may need sudo systemctl disable hciuart
161 if [ "$ENABLE_CONSOLE" = true ] ; then
161 if [ "$ENABLE_CONSOLE" = true ] ; then
162 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
162 echo "enable_uart=1" >> "${BOOT_DIR}/config.txt"
163 # add string to cmdline
163 # add string to cmdline
164 CMDLINE="${CMDLINE} console=serial0,115200"
164 CMDLINE="${CMDLINE} console=serial0,115200"
165
165
166 # Enable serial console systemd style
166 # Enable serial console systemd style
167 chroot_exec systemctl enable serial-getty@serial0.service
167 chroot_exec systemctl enable serial-getty@serial0.service
168 else
168 else
169 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
169 echo "enable_uart=0" >> "${BOOT_DIR}/config.txt"
170 fi
170 fi
171
171
172 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
172 if [ "$ENABLE_SYSTEMDSWAP" = true ] ; then
173 # Create temporary directory for systemd-swap sources
173 # Create temporary directory for systemd-swap sources
174 temp_dir=$(as_nobody mktemp -d)
174 temp_dir=$(as_nobody mktemp -d)
175
175
176 # Fetch systemd-swap sources
176 # Fetch systemd-swap sources
177 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
177 as_nobody git -C "${temp_dir}" clone "${SYSTEMDSWAP_URL}"
178
178
179 # Copy downloaded systemd-swap sources
179 # Copy downloaded systemd-swap sources
180 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
180 mv "${temp_dir}/systemd-swap" "${R}/tmp/"
181
181
182 # Set permissions of the systemd-swap sources
183 chown -R root:root "${R}/tmp/systemd-swap"
184
185 # Remove temporary directory for systemd-swap sources
186 rm -fr "${temp_dir}"
187
188 # Change into downloaded src dir
182 # Change into downloaded src dir
189 cd "${R}/tmp/systemd-swap" || exit
183 cd "${R}/tmp/systemd-swap" || exit
190
184
191 # Build package
185 # Build package
192 bash ./package.sh debian
186 bash ./package.sh debian
193
187
188 # Change back into script root dir
189 cd "${WORKDIR}" || exit
190
191 # Set permissions of the systemd-swap sources
192 chown -R root:root "${R}/tmp/systemd-swap"
193
194 # Install package
194 # Install package
195 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_*_any.deb
195 chroot_exec dpkg -i /tmp/systemd-swap/systemd-swap_*_any.deb
196
196
197 # Enable service
197 # Enable service
198 chroot_exec systemctl enable systemd-swap
198 chroot_exec systemctl enable systemd-swap
199
199
200 # Change back into script root dir
200 # Remove temporary directory for systemd-swap sources
201 cd "${WORKDIR}" || exit
201 rm -fr "${temp_dir}"
202 else
202 else
203 # Enable ZSWAP in cmdline if systemd-swap is not used
203 # Enable ZSWAP in cmdline if systemd-swap is not used
204 if [ "$KERNEL_ZSWAP" = true ] ; then
204 if [ "$KERNEL_ZSWAP" = true ] ; then
205 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
205 CMDLINE="${CMDLINE} zswap.enabled=1 zswap.max_pool_percent=25 zswap.compressor=lz4"
206 fi
206 fi
207 fi
207 fi
208 if [ "$KERNEL_SECURITY" = true ] ; then
208 if [ "$KERNEL_SECURITY" = true ] ; then
209 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
209 CMDLINE="${CMDLINE} apparmor=1 security=apparmor"
210 fi
210 fi
211
211
212 # Install firmware boot cmdline
212 # Install firmware boot cmdline
213 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
213 echo "${CMDLINE}" > "${BOOT_DIR}/cmdline.txt"
214
214
215 # Setup minimal GPU memory allocation size: 16MB (no X)
215 # Setup minimal GPU memory allocation size: 16MB (no X)
216 if [ "$ENABLE_MINGPU" = true ] ; then
216 if [ "$ENABLE_MINGPU" = true ] ; then
217 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
217 echo "gpu_mem=16" >> "${BOOT_DIR}/config.txt"
218 fi
218 fi
219
219
220 # Setup boot with initramfs
220 # Setup boot with initramfs
221 if [ "$ENABLE_INITRAMFS" = true ] ; then
221 if [ "$ENABLE_INITRAMFS" = true ] ; then
222 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
222 echo "initramfs initramfs-${KERNEL_VERSION} followkernel" >> "${BOOT_DIR}/config.txt"
223 fi
223 fi
224
224
225 # Create firmware configuration and cmdline symlinks
225 # Create firmware configuration and cmdline symlinks
226 ln -sf firmware/config.txt "${R}/boot/config.txt"
226 ln -sf firmware/config.txt "${R}/boot/config.txt"
227 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
227 ln -sf firmware/cmdline.txt "${R}/boot/cmdline.txt"
228
228
229 # Install and setup kernel modules to load at boot
229 # Install and setup kernel modules to load at boot
230 mkdir -p "${LIB_DIR}/modules-load.d/"
230 mkdir -p "${LIB_DIR}/modules-load.d/"
231 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
231 install_readonly files/modules/rpi2.conf "${LIB_DIR}/modules-load.d/rpi2.conf"
232
232
233 # Load hardware random module at boot
233 # Load hardware random module at boot
234 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
234 if [ "$ENABLE_HWRANDOM" = true ] && [ "$BUILD_KERNEL" = false ] ; then
235 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
235 sed -i "s/^# bcm2708_rng/bcm2708_rng/" "${LIB_DIR}/modules-load.d/rpi2.conf"
236 fi
236 fi
237
237
238 # Load sound module at boot
238 # Load sound module at boot
239 if [ "$ENABLE_SOUND" = true ] ; then
239 if [ "$ENABLE_SOUND" = true ] ; then
240 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
240 sed -i "s/^# snd_bcm2835/snd_bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
241 else
241 else
242 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
242 echo "dtparam=audio=off" >> "${BOOT_DIR}/config.txt"
243 fi
243 fi
244
244
245 # Enable I2C interface
245 # Enable I2C interface
246 if [ "$ENABLE_I2C" = true ] ; then
246 if [ "$ENABLE_I2C" = true ] ; then
247 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
247 echo "dtparam=i2c_arm=on" >> "${BOOT_DIR}/config.txt"
248 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
248 sed -i "s/^# i2c-bcm2708/i2c-bcm2708/" "${LIB_DIR}/modules-load.d/rpi2.conf"
249 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
249 sed -i "s/^# i2c-dev/i2c-dev/" "${LIB_DIR}/modules-load.d/rpi2.conf"
250 fi
250 fi
251
251
252 # Enable SPI interface
252 # Enable SPI interface
253 if [ "$ENABLE_SPI" = true ] ; then
253 if [ "$ENABLE_SPI" = true ] ; then
254 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
254 echo "dtparam=spi=on" >> "${BOOT_DIR}/config.txt"
255 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
255 echo "spi-bcm2708" >> "${LIB_DIR}/modules-load.d/rpi2.conf"
256 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
256 if [ "$RPI_MODEL" = 3 ] || [ "$RPI_MODEL" = 3P ]; then
257 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
257 sed -i "s/spi-bcm2708/spi-bcm2835/" "${LIB_DIR}/modules-load.d/rpi2.conf"
258 fi
258 fi
259 fi
259 fi
260
260
261 # Disable RPi2/3 under-voltage warnings
261 # Disable RPi2/3 under-voltage warnings
262 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
262 if [ -n "$DISABLE_UNDERVOLT_WARNINGS" ] ; then
263 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
263 echo "avoid_warnings=${DISABLE_UNDERVOLT_WARNINGS}" >> "${BOOT_DIR}/config.txt"
264 fi
264 fi
265
265
266 # Install kernel modules blacklist
266 # Install kernel modules blacklist
267 mkdir -p "${ETC_DIR}/modprobe.d/"
267 mkdir -p "${ETC_DIR}/modprobe.d/"
268 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
268 install_readonly files/modules/raspi-blacklist.conf "${ETC_DIR}/modprobe.d/raspi-blacklist.conf"
269
269
270 # Install sysctl.d configuration files
270 # Install sysctl.d configuration files
271 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
271 install_readonly files/sysctl.d/81-rpi-vm.conf "${ETC_DIR}/sysctl.d/81-rpi-vm.conf"
General Comments 0
Vous devez vous connecter pour laisser un commentaire. Se connecter maintenant