Skip to content

Commit

Permalink
update installation and autorun scripts for pi5
Browse files Browse the repository at this point in the history
  • Loading branch information
gisogrimm committed Sep 29, 2024
1 parent 2cc7c1c commit c9bdc1d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
2 changes: 1 addition & 1 deletion packaging/deb/ov-client.csv
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,5 @@ ovclient.css,usr/share/ovclient/
ovclient.js,usr/share/ovclient/
sounds/2138735723541465742.flac,usr/share/ovclient/sounds/
sounds/4180150583.flac,usr/share/ovclient/sounds/
tools/pi/autorun,usr/share/ovclient/tools/
tools/pi/autorun*,usr/share/ovclient/tools/
webmixer.js,usr/share/ovclient/
20 changes: 14 additions & 6 deletions tools/install_pi5
Original file line number Diff line number Diff line change
Expand Up @@ -28,32 +28,41 @@
cnt=10
while test $cnt -gt 0; do
echo counter: $cnt
sudo -E apt update && cnt=-1 || ( sleep 7; let cnt=$cnt-1 )
sudo -E apt update && cnt=-1 || sleep 7; let cnt=$cnt-1
sync
done

echo "upgrade system:"
# install dependencies:
# retry 10 times because the raspios servers are not very stable:
cnt=10
while test $cnt -gt 0; do
echo counter: $cnt
sudo -E apt upgrade && cnt=-1 || sleep 7; let cnt=$cnt-1
sync
done
#sudo -E apt-get update --assume-yes || sudo -E apt-get update --assume-yes

echo "Install CA certificates:"
cnt=10
while test $cnt -gt 0; do
echo counter: $cnt
sudo -E apt-get install --no-install-recommends --assume-yes ca-certificates && cnt=-1 || ( sleep 7; let cnt=$cnt-1)
sudo -E apt-get install --no-install-recommends --assume-yes ca-certificates && cnt=-1 || sleep 7; let cnt=$cnt-1
sync
done

echo "install git, build-essential and other basic stuff:"
cnt=10
while test $cnt -gt 0; do
echo counter: $cnt
sudo -E apt-get install --no-install-recommends --assume-yes git build-essential cmake xxd gettext-base lsb-release && cnt=-1 || ( sleep 7; let cnt=$cnt-1 )
sudo -E apt-get install --no-install-recommends --assume-yes git build-essential cmake xxd gettext-base lsb-release && cnt=-1 || sleep 7; let cnt=$cnt-1
sync
done

echo "install dependencies of cli tool:"
cnt=10
while test $cnt -gt 0; do
echo counter: $cnt
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 && cnt=-1 || ( sleep 7; let cnt=$cnt-1 )
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 && cnt=-1 || sleep 7; let cnt=$cnt-1
sync
done

Expand Down Expand Up @@ -92,7 +101,6 @@
echo "install autorun script:"
sudo cp ov-client/tools/pi/autorun_pi5 /home/pi/autorun
sudo chmod a+x /home/pi/autorun
# the next line needs a fix because it works only on the correct system:
sudo chown pi:pi /home/pi/autorun

echo "register autorun script in /etc/rc.local:"
Expand Down
37 changes: 20 additions & 17 deletions tools/pi/autorun_pi5
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/sh

#BOOTFS=/boot
BOOTFS=`mount | grep /boot | sed -e 's/.*\/boot/\/boot/1' -e 's/ .*//1'`

# deactivate power saving:
for cpu in /sys/devices/system/cpu/cpu[0-9]*; do echo -n performance \
| sudo tee $cpu/cpufreq/scaling_governor; done
Expand Down Expand Up @@ -32,14 +35,14 @@ killall dbus-launch
rfkill block all

# activate WiFi if required:
if test -e /boot/ovclient-wifi.txt; then
if test -e ${BOOTFS}/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')
SSID=$(cat ${BOOTFS}/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')
PW=$(cat ${BOOTFS}/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)
test -e ${BOOTFS}/ovclient-country.txt && COUNTRYCODE=$(cat ${BOOTFS}/ovclient-country.txt)
echo "connecting to WiFi ${SSID}"
if test -n "${SSID}"; then
sudo raspi-config nonint do_wifi_country "${COUNTRYCODE}"
Expand All @@ -51,16 +54,16 @@ if test -e /boot/ovclient-wifi.txt; then
fi
fi

if test ! -e /boot/ovclient-noupdate; then
if test ! -e ${BOOTFS}/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 2>&1 | tee -a ${HOME}/install.log
# test for openMHA install request:
if test -e /boot/ov-client-instmha; then
rm -f /boot/ov-client-instmha
if test -e ${BOOTFS}/ov-client-instmha; then
rm -f ${BOOTFS}/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:
Expand All @@ -77,7 +80,7 @@ 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/
sudo mv ~ov/ov-client.cfg ${BOOTFS}/
sync
fi
# test for firmware update:
Expand All @@ -91,7 +94,7 @@ while true; do
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 touch ${BOOTFS}/ov-client-instmha
sudo raspi-config nonint disable_overlayfs
sudo shutdown -r now
fi
Expand All @@ -114,16 +117,16 @@ while true; do
fi
if test -e ~ov/ov-client.wificfg; then
echo "switching wifi"
sudo mv ~ov/ov-client.wificfg /boot/ovclient-wifi.txt
sudo mv ~ov/ov-client.wificfg ${BOOTFS}/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')
SSID=$(cat ${BOOTFS}/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')
PW=$(cat ${BOOTFS}/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)
test -e ${BOOTFS}/ovclient-country.txt && COUNTRYCODE=$(cat ${BOOTFS}/ovclient-country.txt)
echo "connecting to WiFi ${SSID}"
if test -n "${SSID}"; then
sudo raspi-config nonint do_wifi_country "${COUNTRYCODE}"
Expand All @@ -137,15 +140,15 @@ while true; do
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"
sudo sed -i -e 's/[^#]*hifiberry-/#&/g' ${BOOTFS}/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"
sudo sed -i -e "/dtoverlay*.hifiberry-${HBERRY}/ d" ${BOOTFS}/config.txt|| echo "unable to add new hifiberry entry"
(
echo ""
echo "dtoverlay=hifiberry-${HBERRY}"
) | sudo tee -a /boot/config.txt
) | sudo tee -a ${BOOTFS}/config.txt
fi
sudo sed -i -e '/^$/N;/^\n$/D' /boot/config.txt||echo "unable to remove multiple empty lines"
sudo sed -i -e '/^$/N;/^\n$/D' ${BOOTFS}/config.txt||echo "unable to remove multiple empty lines"
sync
sudo shutdown -r now
fi
Expand Down

0 comments on commit c9bdc1d

Please sign in to comment.