daemon: initial functional daemon

This has a number of commits but ca5f0f3 is the meat of it.