I can't get adduser to work in batch mode

Status
Not open for further replies.

ROT Tom

Dabbler
Joined
Sep 28, 2017
Messages
15
Per the man page for adduser:
-f file

Get the list of accounts to create from file. If file is “-”,

then get the list from standard input. If this option is

specified, adduser will operate in batch mode and will not seek

any user input. If an error is encountered while processing an

account, it will write a message to standard error and move to

the next account. The format of the input file is described

below.

So I read the formatting carefully, I created a plain text file, with the following contents (one line only as a test, I need to add 30 users)
Code:
testuser::1006::::Mr Test:/nonexistent:csh:SomePassword

I save that text file as TestAccountCreate.txt, I cd to the directory it's in, and I run:
Code:
adduser -f TestAccountCreate.txt

I get no error.
But I run:
Code:
awk -F":" '{print $1}' /etc/passwd

And there's no "testuser"
I also checked the FreeNAS Web GUI and tried to change the password via
Code:
passwd -l testuser

And the account just doesn't exist.

I was sure it was something about syntax or an invalid argument... I googled up this page:
https://wiki.pacbsd.org/index.php/Users_and_groups
Which provides an example. It seems to me that I'm consistent, but just to be sure, I changed the contents of text file to exactly their example:
Code:
jsmith:::wheel:::John Smith:/home/jsmith:bash:CorrectHorseBatteryStaple

Saved it, ran
Code:
adduser -f TestAccountCreate.txt
again, and again, there is no jsmith user on the system.

Any ideas?

I mean, other than adding 30 users one by one though the GUI or interactive adduser?

Thanks,

Tom.
 

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
The passwd file is generated on the fly by the FreeNAS middleware. Traditional utilities, such as adduser, will not work. You can however use the API to perform automated tasks.
 

ROT Tom

Dabbler
Joined
Sep 28, 2017
Messages
15
Thanks for letting me know. Maybe the FreeNAS team could modify the man page for any standard BSD utilities they're disabling, so they start off with "*** Notice- disabled under FreeNAS ****" or something, to prevent people from wasting so much time on command line utilities that don't work.
 

m0nkey_

MVP
Joined
Oct 27, 2015
Messages
2,739
It's not expected to use anything other than the UI for FreeNAS, since it is an appliance OS. If the use of the shell was expected, it would be included in the documentation.
 

ROT Tom

Dabbler
Joined
Sep 28, 2017
Messages
15
That's funny, because we've had support on our FreeNAS through iXsystems and an external consultant, and it was extremely rare for either of them to even look at the GUI, much less change a setting there. Everything was done through shell. You can't even set file permissions or view files through the GUI. There's probably 1/100 the functionality in the FreeNAS GUI that there is on a Synology. Almost anything you need to do other than some parts of basic setup isn't there.

On bug reports, nearly everything the FreeNAS developers ask people to check or change is done through shell. On these forums, the answers to most questions I've seen involve the shell.

This isn't a complaint about how shell-heavy FreeNAS administration is. But I think most FreeNAS admins spend most of their time administrating the system in the shell. So they might expect FreeBSD commands to work, or possibly a note explaining otherwise. They are shipping a system with a "man" page on a command they've disabled. I wouldn't think it would be good practice to include incorrect manual pages on any system.
 

SweetAndLow

Sweet'NASty
Joined
Nov 6, 2013
Messages
6,421
All the normal command work just fine. But any modifications made will not survive a reboot and especially an upgrade. This is clearly documented in the manual and posted all over the forums. Debugging stuff is done via the command line because it's read only and your not changing anything. If you know enough about the system you can make changes and restart things correctly in the cli like some of the FreeNAS developers can do but that is unsupported behavior. Ideally there is a FreeNAS specific command line that working along side the web. This is what all other major Enterprise nas solutions do.

Also if you have enough users that require a script for user creation you should probably be using a ldap server of some kind.
 
Last edited by a moderator:

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
They are shipping a system with a "man" page on a command they've disabled. I wouldn't think it would be good practice to include incorrect manual pages on any system.
Commands have not been disabled. They do the same thing as always. What is different is the way configuration information is saved and applied on a FreeNAS system. It is normal for an appliance to be different in this regard from a general-purpose system.
 
Status
Not open for further replies.
Top