As far as I can tell there is no easy way to set a user's login shell. A Property User.hasLoginShell, which ensures that a user has a specified login shell and that said shell is in /etc/shells would be really helpful. Sadly, I lack the skills to put this together myself
-- weinzwang
Propellor makes it very easy to put together a property like this.
Let's start with a property that combines the two properties you mentioned:
The shellEnabled property can be easily written using propellor's file manipulation properties.
And then, we want to actually change the user's shell. The
chsh(1)
program can do that, so we can simply tell propellor the command line to run:: The only remaining problem with this is that shellSetTo runs chsh every time, and propellor will always display that it's made a change each time it runs, even when it didn't really do much. Now, there's an easy way to avoid that problem, we could just tell propellor to assume it's not made any change:
But, it's not much harder to do this right. Let's make the property check if the user's shell is already set to the desired value and avoid doing anything in that case.
And that will probably all work, although I've not tested it. You might want to throw in some uses of
describe
to give the new properties more useful descriptions.I hope this has been helpful as an explanation of how to add properties to Propellor, and if you get these properties to work, a patch adding them to Propellor.User would be happily merged.