The script doesn't like /dev/mmcblk0 as the microsd card. It then tries to access individual partitions as /dev/mmcblk3 instead of /dev/mmcblk0p3, and everyting break. Had to put the hard in my phone and then go through usb cable: the card is then visible as /dev/sdc. If one does not specify the size of the FAT partition, then there's no sdc3 on device and the whole thing breaks. The script requires parted, but it's not listed amongst the prerequisites.
ls: cannot access