From a3eba1e97b8ce123dca3c4404dfd47d48f6df854 Mon Sep 17 00:00:00 2001 From: Giso Grimm Date: Fri, 19 Jul 2024 16:06:35 +0200 Subject: [PATCH] add installer for debian bookworm / Raspberry Pi 5 --- tools/build_and_install_debian.sh | 34 +++++++++++++++++ tools/prepareimage_pi5.sh | 62 +++++++++++++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 tools/prepareimage_pi5.sh diff --git a/tools/build_and_install_debian.sh b/tools/build_and_install_debian.sh index cbd81e0..a2ef44d 100755 --- a/tools/build_and_install_debian.sh +++ b/tools/build_and_install_debian.sh @@ -38,5 +38,39 @@ echo "install new debian packages:" sudo -E apt-get install --assume-yes --no-install-recommends ./ov-client/packaging/deb/debian/*/ovbox-cli_*.deb + echo "install rtirq-init:" + sudo -E apt-get install --assume-yes --no-install-recommends rtirq-init + + echo "update real-time priority priviledges:" + sudo sed -i -e '/.audio.*rtprio/ d' -e '/.audio.*memlock/ d' /etc/security/limits.conf + echo "@audio - rtprio 99"|sudo tee -a /etc/security/limits.conf + echo "@audio - memlock unlimited"|sudo tee -a /etc/security/limits.conf + + echo "install user to run the scripts - do not provide root priviledges:" + sudo useradd -m -G audio,dialout ov || echo "user ov already exists." + + echo "register autorun script in /etc/rc.local:" + sudo sed -i -e '/exit 0/ d' -e '/.*autorun.*autorun/ d' -e '/.*home.pi.install.*home.pi.install/ d' -i /etc/rc.local + echo "test -x /home/pi/autorun && su -l pi /home/pi/autorun &"|sudo tee -a /etc/rc.local + echo "exit 0"|sudo tee -a /etc/rc.local + + echo "setup host name:" + HOSTN=$(ov-client_hostname) + echo "ovbox${HOSTN}" | sudo tee /etc/hostname + sudo sed -i "s/127\.0\.1\.1.*/127.0.1.1\tovbox${HOSTN}/g" /etc/hosts + sync + + echo "configure country code and prepare WiFi config:" + sudo touch /boot/ovclient-wifi.txt + sync + + echo "activate overlay image to avoid damage of the SD card upon power off:" + sudo raspi-config nonint enable_overlayfs + sync + + echo "ready, reboot:" + sudo shutdown -r now + + sync echo "successfully installed ovbox system!" ) diff --git a/tools/prepareimage_pi5.sh b/tools/prepareimage_pi5.sh new file mode 100644 index 0000000..409bc51 --- /dev/null +++ b/tools/prepareimage_pi5.sh @@ -0,0 +1,62 @@ +#!/bin/bash +if [ "$#" -ne 2 ]; then + echo "Usage: $0 imagefile mount-directory" >&2 + exit 1 +fi +if ! [ -e "$1" ]; then + echo "image file $1 not found." >&2 + exit 1 +fi +if ! [ -e "$2" ]; then + echo "mount directory $2 not found." >&2 + exit 1 +fi +if ! [ -d "$2" ]; then + echo "$2 is not a directory" >&2 + exit 1 +fi +# minimal error handling: +trap "echo an error occured.;exit 1" ERR +# +SUFFIX=ovinstaller +IMGBASE=$(basename "$1") +sudo losetup -f -P "$1" +DEVNAME=$(losetup -l|grep -F -e "${IMGBASE}"|tail -1|sed -e 's/[[:blank:]].*//1') +echo "----------" +echo "mounting $1 ($DEVNAME) on $2" +# Mount boot partition: +sudo mount ${DEVNAME}p1 "$2" +cat "$2"/firmware/cmdline.txt | grep -e 'init=.*/init_resize.sh' -e 'init=.*/firstboot' || (echo "The image was booted already."; ls "/$2";cat "$2"/firmware/cmdline.txt;exit 1;) +echo 'pi:$6$BfzNyd/.tlSynCad$HX/TpdQ35vqP2ahCHIrQbUXxzc8ld3CSW.Nb6pwIqP5/vSIxtO3IunfIiI/mmgzSulbbDwIO9jORU6n/wdbsB0' | sudo tee "$2"/userconf.txt +sudo umount "$2" +# Now mount rootfs partition: +sudo mount ${DEVNAME}p2 "$2" +SRCPATH=`dirname $0` +( + cd ${SRCPATH} + sudo cp build_and_install_debian.sh "$2/home/pi/install" + sudo cp install_ovclient.sh "$2/usr/lib/raspi-config/install_ovclient.sh" + sudo chmod a+x "$2/usr/lib/raspi-config/install_ovclient.sh" + if test -e "$2/usr/lib/raspi-config/init_resize.sh"; then + # In /mnt/usr/lib/raspi-config/init_resize.sh line 187 modify line + sudo sed -i -e "\+init=/usr/lib/raspi-config/init_resize+ s/.*/sed -i \'s| init=\/usr\/lib\/raspi-config\/init_resize\\\.sh| init=\/usr\/lib\/raspi-config\/install_ovclient\\\.sh|\' \/boot\/firmware\/cmdline.txt/1" "$2/usr/lib/raspi-config/init_resize.sh" + fi + if test -e "$2/usr/lib/raspberrypi-sys-mods/firstboot"; then + sudo sed -i -e "\+init=/usr/lib/raspberrypi-sys-mods/firstboot+ s/.*/sed -i \'s| init=\/usr\/lib\/raspberrypi-sys-mods\/firstboot| init=\/usr\/lib\/raspi-config\/install_ovclient\\\.sh|\' \/boot\/firmware\/cmdline.txt/1" "$2/usr/lib/raspberrypi-sys-mods/firstboot" + fi +) +sudo umount "$2" +if [ "${DIGITALSTAGE}" = "yes" ]; then + # add config file to /boot partition + SUFFIX=ds-ovinstaller + sudo mount ${DEVNAME}p1 "$2" + echo '{"protocol":"ov","ui":"https://digital-stage.ovbox.de/","url":"http://digital-stage-device.ovbox.de/"}' | sudo tee "$2/ov-client.cfg" + sudo umount "$2" +fi +sync +sudo losetup -d ${DEVNAME} +SRC="${1}" +echo "renaming to ${SRC/.img}-${SUFFIX}.img" +mv "${SRC}" "${SRC/.img}-${SUFFIX}.img" +echo "compressing to ${IMGBASE/.img}-${SUFFIX}.zip" +zip "${IMGBASE/.img}-${SUFFIX}.zip" "${SRC/.img}-${SUFFIX}.img"