Factor scripts

This way, we don't have to mess around with `chmod +x` in configure.  It also deduplicates some logic, and lets us deduplicate other logic, should we choose to do so.