Sync template branch infrastructure with master.

Change a few things to make it compatible with r151006 though.

Refs Github issue #22
Sync templates from master as well.

Refs Github issue #22
Merge remote-tracking branch 'omnios/template'

Conflicts:
	lib/config.sh
	lib/functions.sh