diff --git a/README.md b/README.md index d131c7a..12042a5 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ This addon can be used to easily up- and downgrade the RaspberryMatic system. * Download adjusted RaspberryMatic image: * [RaspberryMatic-2.27.8.20170615-rpi0.rmupdate.img.zip](https://www.dropbox.com/s/cikwkap0e1yxly0/RaspberryMatic-2.27.8.20170615-rpi0.rmupdate.img.zip) SHA256 sum: 904edb9c4a565d65a9dfdd3ffe05ed4bc24f9f909b602d6de7cbcb5560418dfb * [RaspberryMatic-2.27.8.20170615-rpi3.rmupdate.img.zip](https://www.dropbox.com/s/6mzz9l6h4460we5/RaspberryMatic-2.27.8.20170615-rpi3.rmupdate.img.zip) SHA256 sum: c665667beb68d7d25b6f4210ea6c23471e1c0834ffc53a1abd2f917a9620322a - * [RaspberryMatic-2.29.23.20171216-tinkerboard.rmupdate.img.zip](https://www.dropbox.com/s/59oay0bz08quvf9/RaspberryMatic-2.29.23.20171216-tinkerboard.rmupdate.img.zip) SHA256 sum: b4ee09cf16214d9bb3033537f4a96704fdebf022af32d9352707762e04aeec8f * Install adjusted RaspberryMatic image like described at [RaspberryMatic project](https://github.com/jens-maus/RaspberryMatic) * Download [addon package](https://github.com/j-a-n/raspberrymatic-addon-rmupdate/raw/master/rmupdate.tar.gz) * Install addon package on RaspberryMatic via system control diff --git a/adjust_image.sh b/adjust_image.sh index dc8b32b..872c8a8 100755 --- a/adjust_image.sh +++ b/adjust_image.sh @@ -50,10 +50,30 @@ for line in $(parted $image_file unit B print | grep primary); do done echo "*** Resizing / creating filesystems ***" +umount /tmp/rmupdate.mnt 2>/dev/null || true +rmdir /tmp/rmupdate.mnt 2>/dev/null || true +rm /tmp/rmupdate.boot.tar 2>/dev/null || true rm /dev/mapper/loop${LOOP_DEV}p 2>/dev/null || true kpartx -d /dev/loop${LOOP_DEV} 2>/dev/null || true losetup -d /dev/loop${LOOP_DEV} 2>/dev/null || true +losetup /dev/loop${LOOP_DEV} $image_file +kpartx -a /dev/loop${LOOP_DEV} +ln -s /dev/loop${LOOP_DEV} /dev/mapper/loop${LOOP_DEV}p + +sleep 3 + +mkdir /tmp/rmupdate.mnt +mount /dev/mapper/loop${LOOP_DEV}p1 /tmp/rmupdate.mnt +(cd /tmp/rmupdate.mnt; tar cf /tmp/rmupdate.boot.tar .) +umount /tmp/rmupdate.mnt + +rm /dev/mapper/loop${LOOP_DEV}p 2>/dev/null || true +kpartx -d /dev/loop${LOOP_DEV} 2>/dev/null || true +losetup -d /dev/loop${LOOP_DEV} 2>/dev/null || true + +sleep 3 + losetup /dev/loop${LOOP_DEV} $new_image_file kpartx -a /dev/loop${LOOP_DEV} ln -s /dev/loop${LOOP_DEV} /dev/mapper/loop${LOOP_DEV}p @@ -62,12 +82,9 @@ sleep 3 partuuid=$(blkid -s PARTUUID -o value /dev/mapper/loop${LOOP_DEV}p2) echo "PARTUUID=${partuuid}" -mkdir /tmp/rmupdate.mnt -mount /dev/mapper/loop${LOOP_DEV}p1 /tmp/rmupdate.mnt -(cd /tmp/rmupdate.mnt; tar cf /tmp/rmupdate.boot.tar .) -umount /tmp/rmupdate.mnt mkfs.vfat -F32 -n bootfs /dev/mapper/loop${LOOP_DEV}p1 +sleep 3 mount /dev/mapper/loop${LOOP_DEV}p1 /tmp/rmupdate.mnt (cd /tmp/rmupdate.mnt; tar xf /tmp/rmupdate.boot.tar .) sed -i -r s"/root=\S+/root=PARTUUID=${partuuid}/" /tmp/rmupdate.mnt/cmdline.txt