|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +# Part of tiny-radioCD project, originally designed & hand-crafted by macmpi |
| 4 | +# check License at project home https://github.com/macmpi/tiny-radioCD |
| 5 | + |
| 6 | + |
| 7 | +# Note: this file is included so all upper variables work |
| 8 | +# do NOT change directory inside here, or cd "$srcdir" at the end!... |
| 9 | + |
| 10 | + |
| 11 | +# Limited Pi-specific customizations regarding rng-tools, pi-bluetooth initd service, |
| 12 | +# swclock & easy-setup |
| 13 | + |
| 14 | +echo "Installing Pi specific tweaks" |
| 15 | + |
| 16 | +apk -u add rng-tools bluez-deprecated@emain --update-cache \ |
| 17 | +|| { echo >&2 "Install failed, exiting! (for clues: apk -s fix)"; exit 1; } |
| 18 | + |
| 19 | +rc-update add rngd boot 2>&1 # same as wpa_supplicant for providing entropy |
| 20 | + |
| 21 | + |
| 22 | +# on Pi no hardware clock |
| 23 | +service hwclock stop 2>&1 |
| 24 | +rc-update del hwclock boot 2>&1 |
| 25 | +service swclock start 2>&1 |
| 26 | +rc-update add swclock boot 2>&1 |
| 27 | + |
| 28 | +# Pi Specific service to load bluetooth firmware until done via device-tree |
| 29 | +install -m755 "$srcdir"/usr/local/bin/btuart /usr/local/bin/btuart |
| 30 | +install -m755 "$srcdir"/etc/init.d/pi-bluetooth /etc/init.d/pi-bluetooth |
| 31 | +rc-update add pi-bluetooth sysinit 2>&1 |
| 32 | + |
| 33 | +# Fix eventually missing brcm NVRAM firmware file for PiZeroW |
| 34 | +# will only work on sys mode (other modes /lib/firmware is not writeable initramfs) |
| 35 | +grep -q "Raspberry Pi" /proc/cpuinfo && \ |
| 36 | +! [ -f /lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.txt ] && \ |
| 37 | +ln -sfn brcmfmac43430-sdio.raspberrypi,3-model-b.txt \ |
| 38 | +/lib/firmware/brcm/brcmfmac43430-sdio.raspberrypi,model-zero-w.txt |
| 39 | + |
| 40 | + |
| 41 | + |
| 42 | +################################# |
| 43 | +# Modify SD content: easy-setup and boot options |
| 44 | +mount -o remount,rw /dev/mmcblk0p1 /media/mmcblk0p1 |
| 45 | + |
| 46 | +# Enable easy-setup on SD and add default config file sample |
| 47 | +mkdir -p /media/mmcblk0p1/_tiny-radioCD |
| 48 | +install "$srcdir"/tiny-radioCD.conf /media/mmcblk0p1/_tiny-radioCD/tiny-radioCD.conf |
| 49 | +ln -sfn /media/mmcblk0p1/_tiny-radioCD /etc/tiny-radioCD |
| 50 | + |
| 51 | + |
| 52 | +# Pi eventual supplements for config.txt or usrcfg.txt |
| 53 | + |
| 54 | +# Disable the rainbow splash screen (will not add if there and commented) |
| 55 | +grep -q "disable_splash=1" /media/mmcblk0p1/usercfg.txt || \ |
| 56 | +echo "disable_splash=1" >> /media/mmcblk0p1/usercfg.txt |
| 57 | + |
| 58 | +# Set the bootloader delay to 0 seconds. Default is 1s if not specified. |
| 59 | +# (will not add if there and commented) |
| 60 | +grep -q "boot_delay=0" /media/mmcblk0p1/usercfg.txt || \ |
| 61 | +echo "boot_delay=0" >> /media/mmcblk0p1/usercfg.txt |
| 62 | + |
| 63 | +# built-in audio, and HDMI audio (will not add if there and commented) |
| 64 | +grep -q "dtparam=audio=on" /media/mmcblk0p1/usercfg.txt || \ |
| 65 | +echo "dtparam=audio=on" >> /media/mmcblk0p1/usercfg.txt |
| 66 | + |
| 67 | +grep -q "force_hdmi_open=1" /media/mmcblk0p1/usercfg.txt || \ |
| 68 | +echo "force_hdmi_open=1" >> /media/mmcblk0p1/usercfg.txt |
| 69 | + |
| 70 | + |
| 71 | +# ON/OFF button on GPIO3 |
| 72 | +#dtoverlay=gpio-shutdown |
| 73 | + |
| 74 | +# External activity LED on GPIO 21 |
| 75 | +#dtparam=act_led_gpio=21 |
| 76 | + |
| 77 | +# gpu_mem MUST be set in original config.txt, not in include |
| 78 | +# https://github.com/raspberrypi/firmware/issues/1332#issuecomment-584166999 |
| 79 | +# gpu_mem=16 (requires _cd files to be installed) |
| 80 | + |
| 81 | +mount -o remount,ro /dev/mmcblk0p1 /media/mmcblk0p1 |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +################################# |
| 87 | +# Preserve local specific stuff according to install modes |
| 88 | + |
| 89 | +if !(grep -q "root=" /proc/cmdline); then #we are not in sys mode (so data or diskless) |
| 90 | + # stuff of matter for diskless or data mode |
| 91 | + lbu include /etc/init.d/pi-bluetooth |
| 92 | + |
| 93 | + if !(grep -q "/var" /etc/fstab); then #we are not in data mode: hence diskless only |
| 94 | + # stuff from /var for diskless mode |
| 95 | + : |
| 96 | + fi |
| 97 | +fi |
| 98 | + |
| 99 | + |
| 100 | +echo "Done with Pi specific tweaks" |
0 commit comments