Hi I am looking to create a script in bash/sh that can do the following
- Go in to a folder
- Cycles trough a set of img.xz files and if it finds one of the secified ones uses that to invoke
unxz -c (img.xzfile) | dd of=/dev/mmcblk0 bs=4096 status=progress
The folder will at least contain 3-5 img.xz
What I have now
#!bin/bash
$img.xz
$img.xz2
cd /img/
if ./20240317-1928-postmarketOS-edge-i3wm-0.5-microsoft-surface-rt.img.xz -->$img.xz
then unxz -c $img.xz | dd of=/dev/mmcblk0 bs=4096 status=progress
else
./20240317-1346-postmarketOS-edge-mate-7-microsoft-surface-rt.img.xz --> $img.xz2
then unxz -c $img.xz2 | dd of=/dev/mmcblk0 bs=4096 status=progress
I don't know if this works,
hence the question for something like this that can work, or even lists all images in the folder and asks witch one to use by selecting option 1-5 put that in the variable and use the variable in the unxz -c $variable | dd of=/dev/mmcblk0 bs=4096 status=progress to image the to a emmc module build in a device.
This script will be run from a USB booted live Linux image with the images in the /img/ folder
You can achieve your requirement by iterating through the
.img.xzfiles in the folder and providing options to the user to select which image to use. Here's a script that does just that:This script:
/img/folder..img.xzfiles in the current directory./dev/mmcblk0device usingunxzanddd.Make sure to run this script with appropriate permissions and be cautious when writing to the
/dev/mmcblk0device, as it can potentially overwrite data.