Have a look at gluon.main.save_password and gluon.validators.CRYPT to see how this works.
(BTW, Massimo, password_file currently depends on cwd, which ought to be fixed. Also, we could offer a cli option for exiting after setting the password, so scripts like Rik's could invoke something like "web2py -a password --exit" to set the initial password, and then store "web2py -a <recycle>" as the normal script startup. I think that'd be better than the script having independent knowledge of how web2py hashes its passwords, since that could change.)
Thanks. I have an unrelated patch in the works that affects main.py, so I'll include it unless Massimo gets around to fixing it first.
That looks about right, perhaps with some minor wording changes:
help='exit after saving password' (no sense in confusing the user about file names, and there's really no other initialization involved)
print 'no password to save; exiting'
(remove the "Creating..." print)
print 'password saved; exiting'
Almost. It requires a web2py patch first, and for the two web2py.py commands to work, you'll have to know the full path.
And that's assuming that firstboot.d runs interactively....
I don't see the problem.
I keep forgetting you can reach inside and do this stuff.
Yes, the second command, at least, works very nicely. I don't quite follow what the console() run is intended to do, though. The script could use one or two more comments.