grain file was acting quirky because it was being called before php had been installed. made it a module instead and this appears to work. database now creates a lock file so it doesn't run multiple times.
added the _modules dir because the -a switch adds everything except everything. grr, git.