Abstracted logic into it's own bash script, added headers.

The buildserver is pretty well-configured at this point, just needs a few alterations to make it act like a daemon.