From 914301557100ac31b366809adb3c31e7dac59f33 Mon Sep 17 00:00:00 2001 From: PrincessPi3 Date: Thu, 30 Oct 2025 04:39:18 -0600 Subject: [PATCH] 1.5-rc-3 --- Commands.md | 65 --------------------------------------------- rpi_create_image.sh | 61 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 65 deletions(-) create mode 100644 rpi_create_image.sh diff --git a/Commands.md b/Commands.md index 4468566..9d164e7 100644 --- a/Commands.md +++ b/Commands.md @@ -1,69 +1,4 @@ # Commands -copy image -```bash -#/bin/bash -imgname=`date +"%Y-%m-%d-%H%M-%S"`-grandfatherclock-pi4.img -xzname=$imgname.xz -sizes=sizes-$imgname-$xzame.txt -checksums=sha256sum-$imgname-$xzname.sha256 - -# get real username (not root) if run with sudo -if [ ! -z $SUDO_USER ]; then - username=$SUDO_USER -else - username=$USER -fi - -# get disk -lsblk -echo "Enter disk name (including /dev/) ex /dev/sdb" -read dadisk - -# start -webhook "starting copy $dadisk to $imgname to $xzname at $(date)($(date +%s))" true - -# copy disk -sudo dd if=$dadisk of=$imgname bs=4M status=progress -imgsize=$(du -h $imgname) - -# shrink and compress the image -webhook "Copied the disk to $imgname ($imgsize), compressing to $xzname" -sudo pishrink.sh -v -Z -a $imgname -xzsize=$(du -h $xzname) - -# sha256 checksums -webhook "$imgname ($imgsize) shrunk to $xzname ($xzsize), calculating sha256 checksums..." -sha256sum $imgname | tee $checksums -sha256sum $xzname | tee -a $checksums - -# log filesizes -webhook "saving sizes" -echo -e "imgsize: $imgsize\nxzsize: $xzsize" | tee $sizes - -# change archive to be friendly perms -webhook "changing perms" -sudo chown $username:$username $xzname - -# test archive -webhook "testing archive $xzname" -xz -t $xzname -ret=$? -# if test fails -if [ $ret -gt 0 ]; then - webhook "FAIL! ARCHIVE DES NOT CHECK return code: $ret EXITING" - exit 1 -# if test succeeds -else - webhook "Archive Test SUCCESS" -fi - -# schedule reboot in 1 minute -sudo shutdown -r +1 - -# finish and notify -webhook "DONE\n\tdisk: $dadisk\n\timgname: $imgname ($imgsize)\n\txzname: $xzname ($xzsize)" true -``` - watch file ```bash watch -n $((60 * 5)) "ls -lAh | rg grand | awk '{print \$5,\"/ 238.3G\", \"\\t\", \$9}'" diff --git a/rpi_create_image.sh b/rpi_create_image.sh new file mode 100644 index 0000000..8f48e8a --- /dev/null +++ b/rpi_create_image.sh @@ -0,0 +1,61 @@ +#/bin/bash +imgname=`date +"%Y-%m-%d-%H%M-%S"`-grandfatherclock-pi4.img +xzname=$imgname.xz +sizes=sizes-$imgname-$xzame.txt +checksums=sha256sum-$imgname-$xzname.sha256 + +# get real username (not root) if run with sudo +if [ ! -z $SUDO_USER ]; then + username=$SUDO_USER +else + username=$USER +fi + +# get disk +lsblk +echo "Enter disk name (including /dev/) ex /dev/sdb" +read dadisk + +# start +webhook "starting copy $dadisk to $imgname to $xzname at $(date)($(date +%s))" true + +# copy disk +sudo dd if=$dadisk of=$imgname bs=4M status=progress +imgsize=$(du -h $imgname) + +# shrink and compress the image +webhook "Copied the disk to $imgname ($imgsize), compressing to $xzname" +sudo pishrink.sh -v -Z -a $imgname +xzsize=$(du -h $xzname) + +# sha256 checksums +webhook "$imgname ($imgsize) shrunk to $xzname ($xzsize), calculating sha256 checksums..." +sha256sum $imgname | tee $checksums +sha256sum $xzname | tee -a $checksums + +# log filesizes +webhook "saving sizes" +echo -e "imgsize: $imgsize\nxzsize: $xzsize" | tee $sizes + +# change archive to be friendly perms +webhook "changing perms" +sudo chown $username:$username $xzname + +# test archive +webhook "testing archive $xzname" +xz -t $xzname +ret=$? +# if test fails +if [ $ret -gt 0 ]; then + webhook "FAIL! ARCHIVE DES NOT CHECK return code: $ret EXITING" + exit 1 +# if test succeeds +else + webhook "Archive Test SUCCESS" +fi + +# schedule reboot in 1 minute +sudo shutdown -r +1 + +# finish and notify +webhook "DONE\n\tdisk: $dadisk\n\timgname: $imgname ($imgsize)\n\txzname: $xzname ($xzsize)" true \ No newline at end of file