Skip to content

Commit

Permalink
continue to work on installer for pi5 / bookworm
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Sep 27, 2024
1 parent 4fa893a commit 7b00e26
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 22 deletions.
35 changes: 23 additions & 12 deletions tools/build_and_install_debian.sh → tools/install_pi5
Original file line number Diff line number Diff line change
@@ -1,21 +1,32 @@
#!/bin/bash

# This script will compile and install the ovbox software from
# source. It expects to be running on a Raspberry Pi, with the user
# "pi" in the home folder "/home/pi". It will create an additional
# user "ov" to run the actual ovbox process.
#
# Important: Do not run this script on a system that is not intended
# to be used solely as an ovbox.

(
# minimal error handling:
trap "echo An error occured.;exit 1" ERR

cd

export DEBIAN_FRONTEND=noninteractive

echo "update apt database:"
sudo -E apt-get update --assume-yes
sudo -E apt-get update --assume-yes || sudo -E apt-get update --assume-yes

echo "Install CA certificates:"
sudo -E apt-get install --no-install-recommends --assume-yes ca-certificates
sudo -E apt-get install --no-install-recommends --assume-yes ca-certificates || sudo -E apt-get install --no-install-recommends --assume-yes ca-certificates

echo "install git, build-essential and other basic stuff:"
sudo -E apt-get install --no-install-recommends --assume-yes git build-essential xxd gettext-base lsb-release
sudo -E apt-get install --no-install-recommends --assume-yes git build-essential cmake xxd gettext-base lsb-release || sudo -E apt-get install --no-install-recommends --assume-yes git build-essential cmake xxd gettext-base lsb-release

echo "install dependencies of cli tool:"
sudo -E apt-get install --no-install-recommends --assume-yes liblo-dev libcurl4-openssl-dev libasound2-dev libeigen3-dev libfftw3-dev libfftw3-single3 libgsl-dev libjack-jackd2-dev libltc-dev libmatio-dev libsndfile1-dev libsamplerate0-dev nlohmann-json3-dev libxerces-c-dev libgtkmm-3.0-dev libcairomm-1.0-dev
sudo -E apt-get install --no-install-recommends --assume-yes liblo-dev libcurl4-openssl-dev libasound2-dev libeigen3-dev libfftw3-dev libfftw3-single3 libgsl-dev libjack-jackd2-dev libltc-dev libmatio-dev libsndfile1-dev libsamplerate0-dev nlohmann-json3-dev libxerces-c-dev libgtkmm-3.0-dev libcairomm-1.0-dev libcunit1-dev

echo "clone or update git repo:"
(cd ov-client && git clean -ffx && git pull) || git clone https://github.com/gisogrimm/ov-client
Expand All @@ -30,7 +41,7 @@
make -C ov-client clean

echo "build tools:"
make -j 5 -C ov-client
make -j `nproc` -C ov-client

echo "package tools:"
make -C ov-client packaging
Expand All @@ -50,7 +61,7 @@
sudo useradd -m -G audio,dialout ov || echo "user ov already exists."

echo "install autorun script:"
sudo cp ov-client/tools/pi/autorun /home/pi/
sudo cp ov-client/tools/pi/autorun_pi5 /home/pi/autorun
sudo chmod a+x /home/pi/autorun
sudo chown pi:pi /home/pi/autorun

Expand All @@ -69,12 +80,12 @@
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
#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!"
Expand Down
153 changes: 153 additions & 0 deletions tools/pi/autorun_pi5
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
#!/bin/sh

# deactivate power saving:
for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo -n performance \
| sudo tee $cpu/cpufreq/scaling_governor; done

## Stop the ntp service
#sudo service ntp stop

## Stop the triggerhappy service
sudo service triggerhappy stop

## Stop the dbus service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo service dbus stop

## Stop the console-kit-daemon service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo killall console-kit-daemon

## Stop the polkitd service. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
sudo killall polkitd

## Kill the usespace gnome virtual filesystem daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall gvfsd

## Kill the userspace D-Bus daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall dbus-daemon

## Kill the userspace dbus-launch daemon. Warning: this can cause unpredictable behaviour when running a desktop environment on the RPi
killall dbus-launch

## Stop all wifi/bluetooth devices
rfkill block all

# activate WiFi if required:
if test -e /boot/ovclient-wifi.txt; then
# remove DOS line ends: -e 's/\r//1'
# the first line contains the SSID:
SSID=$(cat /boot/ovclient-wifi.txt|sed -e '1 ! d' -e 's/\r//1')
# the second line the WIFI password:
PW=$(cat /boot/ovclient-wifi.txt|sed -e '2 ! d' -e 's/\r//1')
COUNTRYCODE=DE
test -e /boot/ovclient-country.txt && COUNTRYCODE=$(cat /boot/ovclient-country.txt)
echo "connecting to WiFi ${SSID}"
if test -n "${SSID}"; then
sudo raspi-config nonint do_wifi_country "${COUNTRYCODE}"
sleep 2
rfkill unblock wifi
sleep 10
sudo raspi-config nonint do_wifi_ssid_passphrase "${SSID}" "${PW}"
sleep 20
fi
fi

if test ! -e /boot/ovclient-noupdate; then
# if not on overlayfs then update/reinstall:
if (cat /proc/mounts | grep -e " / ")|grep -q -e overlay; then
echo "overlay fs, not updating"
else
# get the latest installer script:
./install
# test for openMHA install request:
if test -e /boot/ov-client-instmha; then
rm -f /boot/ov-client-instmha
sudo apt install --no-install-recommends --assume-yes openmha openmha-examples
fi
# activate overlay image in case the installation script failed, and try the best we can:
sudo raspi-config nonint enable_overlayfs
# ready, reboot:
sudo shutdown -r now
fi
fi


# start client:
while true; do

sudo su -l ov -c "ov-client"
# test for modified configuration:
if test -e ~ov/ov-client.cfg; then
sudo mv ~ov/ov-client.cfg /boot/
sync
fi
# test for firmware update:
if test -e ~ov/ov-client.firmwareupdate; then
# firmware update requested: disable overlayfs and restart
sudo rm -f ~ov/ov-client.firmwareupdate
sudo raspi-config nonint disable_overlayfs
sudo shutdown -r now
fi
# test for openMHA install request:
if test -e ~ov/ov-client.installopenmha; then
# firmware update requested: disable overlayfs and restart
sudo rm -f ~ov/ov-client.installopenmha
sudo touch /boot/ov-client-instmha
sudo raspi-config nonint disable_overlayfs
sudo shutdown -r now
fi
# check for development version:
if test -e ~ov/ov-client.usedevversion; then
echo "switching to development version"
# switch to development version:
sudo rm -f ~ov/ov-client.usedevversion
# identify OS release code name:
OSREL=`lsb_release -a|grep Codename|sed 's/Codename:[[:blank:]]*//1'`
OSRELHTCH="$OSREL"
if test "$OSREL" = "buster"; then
OSRELHTCH=bionic
fi
# identify OS architecture:
OSARCH=`dpkg-architecture | grep -e 'DEB_BUILD_ARCH='|sed 's/[^=]*=//1'`
(echo "";echo "deb [arch=${OSARCH]´}] http://aptdev.hoertech.de ${OSRELHTCH} universe")|sudo tee -a /etc/apt/sources.list
sudo apt update --assume-yes
sudo apt install --no-install-recommends --assume-yes ov-client
fi
if test -e ~ov/ov-client.wificfg; then
echo "switching wifi"
sudo mv ~ov/ov-client.wificfg /boot/ovclient-wifi.txt
sync
# activate WiFi if required:
# remove DOS line ends: -e 's/\r//1'
# the first line contains the SSID:
SSID=$(cat /boot/ovclient-wifi.txt|sed -e '1 ! d' -e 's/\r//1')
# the second line the WIFI password:
PW=$(cat /boot/ovclient-wifi.txt|sed -e '2 ! d' -e 's/\r//1')
COUNTRYCODE=DE
test -e /boot/ovclient-country.txt && COUNTRYCODE=$(cat /boot/ovclient-country.txt)
echo "connecting to WiFi ${SSID}"
if test -n "${SSID}"; then
sudo raspi-config nonint do_wifi_country "${COUNTRYCODE}"
sleep 1
rfkill unblock wifi
sleep 5
sudo raspi-config nonint do_wifi_ssid_passphrase "${SSID}" "${PW}"
sleep 20
fi
fi
if test -e ~ov/ov-client.hifiberry; then
HBERRY=$(cat ~ov/ov-client.hifiberry)
sudo rm -f ~ov/ov-client.hifiberry
sudo sed -i -e 's/[^#]*hifiberry-/#&/g' /boot/config.txt|| echo "unable to disable hifiberry modules"
if test "${HBERRY}" != "none"; then
sudo sed -i -e "/dtoverlay*.hifiberry-${HBERRY}/ d" /boot/config.txt|| echo "unable to add new hifiberry entry"
(
echo ""
echo "dtoverlay=hifiberry-${HBERRY}"
) | sudo tee /boot/config.txt
fi
sudo sed -i -e '/^$/N;/^\n$/D' /boot/config.txt||echo "unable to remove multiple empty lines"
sync
sudo shutdown -r now
fi
sleep 7
done
31 changes: 21 additions & 10 deletions tools/prepareimage_pi5.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,27 @@ 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${SEDFIRMW}\/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${SEDFIRMW}\/cmdline.txt/1" "$2/usr/lib/raspberrypi-sys-mods/firstboot"
fi
sudo cp install_pi5 "$2/home/pi/install"
sudo chmod a+x "$2/home/pi/install"
#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${SEDFIRMW}\/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${SEDFIRMW}\/cmdline.txt/1" "$2/usr/lib/raspberrypi-sys-mods/firstboot"
#fi

echo "install autorun script:"
sudo cp pi/autorun_pi5 "$2/home/pi/autorun"
sudo chmod a+x "$2/home/pi/autorun"
sudo chown pi:pi "$2/home/pi/autorun"

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 "$2/etc/rc.local"
echo "test -x /home/pi/autorun && su -l pi /home/pi/autorun &"|sudo tee -a "$2/etc/rc.local"
echo "exit 0"|sudo tee -a "$2/etc/rc.local"


)
sudo umount "$2"
if [ "${DIGITALSTAGE}" = "yes" ]; then
Expand Down

0 comments on commit 7b00e26

Please sign in to comment.