longjob: Add basic logic for job templates (mostly untested)