I changed $ROOT_PART to get its value from findmnt, which will give us /dev/sdaX in the event we are booting off of a USB. This will still work for when booting of a microSD card in the microSD card slot, as findmnt will give us /dev/mmcblk0pX.
Since I can't predict how many partitions someone might have before their root partition, I used lsblk to find the name of the root device (/dev/sda2 -> /dev/sda and /dev/mmcblk0p2 -> /dev/mmcblk0)
I've tested this out booting off USB, and off of a microSD card in the microSD card slot, and it's worked every time so far.
I did remove the portion checking if PART_NUM == ROOT_PART, but since we can expand a bootable USB, I don't see why it's necessary.
I believe this should fix#63
while not having to rely on the raspi-config tool does make the pishrink utility more portable, the raspi-config tool is already properly maintained. rather than being forced to maintain the autosizing utility in this script (which has already been broken for several months due to a linux kernal change), it just makes more sense to not have to rewrite properly maintained code.
The indentation was introduced in cad2e0e11a, not when the safety hash check was added in 2c6f069c2f, my first guess.
The indentations makes the rc.local begin with spaces instead of `#!/bin/bash` and will not run. But it gets better.
The md5 safety check is based on rc.local without indents, so after the added indentations the if-block will never be skipped. If the script is run a second time, the original rc.local backed up in rc.local.bak will be overwritten, and on boot result in a never ending loop, trying to expand the filesystem each time. A user could run the pishrink.sh a second time on a disk image, e.g. after making more edits.
The awks being used were not reliably giving the correct data across different distros. They were
replaced with cut and tr, this should give the script better stability.