I don’t feel comfortable automating it but I tried to write up a very detailed guide of what worked for me to resize my organelle-m SD card. I stuck it in a gist https://gist.github.com/rupa/9ee4d2f3f00c06c722b1ccd4ed58c50f hope it helps
You can definitely screw things up if you get something wrong but the worst case scenario is you have to reimage the sdcard so, you know, backup yer stuff etc etc …