-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add installer for debian bookworm / Raspberry Pi 5
- Loading branch information
Showing
2 changed files
with
96 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |