For Arch Linux users (if any Arch users read here?) wishing to do this, fastboot needs root to run, so if you get stuck at '< waiting for device >' at any point in the script, just change every occurrence of 'fastboot' with 'sudo fastboot' in the script. Everything ran smoothly from there :)