yellowman/flashrd — pull request #15 by paulsuh (2013-05-22 02:22:49+00:00)
Title: Update onetime mechanism for mass deployment and easier updates

I've made some major changes to the way that the onetime mechanism is handled for mass deployment and easier updates.

Everything done onetime is now separated into a new file, /etc/rc.flashrd.onetime. Actions are:

1) Check for a file /flash/myname. If this exists, copy it to /etc/myname.
2) Untar the /flash/onetime.tgz file.
3) Untar a file with the name /flash/`hostname`.onetime.tgz, where hostname is picked up by looking at /etc/myname directly.
4) Append files in the /tmp/APPEND directory to existing files
4) Run a script /flashrd.site -- legacy, deprecated
5) Run a script /flash/flashrd.site.
6) Run a script /flash/`hostname`.flashrd.site

The reasoning behind this is that a maintainer should only have to config a flashimg once per update, then copy over the bsd, openbsd.vnd, and var.tar files and reboot. If the existing /flash/myname and /flash/onetime.tgz files are still in place, then everything will be automatically picked up by the onetime mechanism. In conjunction with nsh, there should be no need for further configuration for an update.

Furthermore, the mechanism is set up to facilitate creating and maintaining a single onetime.tgz file for all machines. I've included a script build_onetime that will put together the necessary structure inside a onetime.tgz for everything from a source tree. The structure of the source tree is in the start of the build_onetime script. In the CommonFiles section I put things like /etc/adduser.conf and /etc/adduser.message, some binaries for /usr/local/bin, etc. Inside /tmp/APPEND are additions to /etc/group, /etc/passwd, /etc/master.passwd, /etc/sudoers, and the like. Also inside the CommonFiles section are all of the host-specific /flash/`hostname`.onetime.tgz files.

The /flash/`hostname`.onetime.tgz files contain things like ssh, iked, and isakmpd keys. It's OK that all of the host information is contained in the single onetime.tgz file, since the script will use the hostname to pick out the appropriate additional file to un-tar.

Deploying a new machine is as simple as running growimg on a new CF card or USB drive, then copying over the onetime.tgz and creating a myname file on the root level of the storage. If running nsh, then copy those pieces into the right place as well.

I also have a separate /flash/flashrd.site file where I run pwd_mkdb, then optionally swap in a new nshrc file.

I'm looking at adding an automated pkg_add mechanism as well, but that's going to be a lot more complex.