Adding Users by the Bunches

Status
Not open for further replies.

Barajiqal

Cadet
Joined
Aug 29, 2011
Messages
3
Not sure if this should go here, but here goes. Is there a way to automate the addition of users to freenas. I have about a 100 or so users split into different groups that would need to be added and would like to automate as much of this as possible. Is there a script I can feed a text file or something to that would add these users? Also as a side note how would a back-up and restoration of said users be done?

Thanks in Advance,
-Bar
 

Durkatlon

Patron
Joined
Aug 19, 2011
Messages
414
Backup and restoration of the user credentials can be done by backing up and restoring the configuration file (essentially a SQLite database). Of course all other configuration settings are in there as well, so it's more of an all-or-nothing kind of restore.

I'm not aware there's a batch mode right now to add users, although writing a script that interacts with the SQLite database to do this shouldn't be too hard. You could then call it from the command line and feed it a user list.
 

Barajiqal

Cadet
Joined
Aug 29, 2011
Messages
3
Hmm

Thanks for the reply, I want to do a little poking in the sqlite shell, but it seems that it won't open the database. I'm ssh'd into the server with root. When I go into sqlite3 it shows there being a database main, but I cannot get into this database to look at its tables. This is my first attempt at any of this sort of thing so any pointers or helpful links would be much appreciated :)

Thanks,
-bar
 

Durkatlon

Patron
Joined
Aug 19, 2011
Messages
414
Sorry, I can't really help you there. I've never used SQLite before. The database is /data/freenas-v1.db. /If you take a look at the /etc/rc.d/ix-passwd script you can see how it is used to create the /etc/passwd and /etc/group files during boot. You should be able to get some ideas from that one.
 

ProtoSD

MVP
Joined
Jul 1, 2011
Messages
3,348
You can also dump the database to a text file and edit it that way if you know what you're doing (I don't). I've made minor text substitutions, but not adding any data. Here's the command to dump the freenas database:

sqlite3 freenas-v1.db ".dump" > database.txt (the database.txt file should be somewhere other than your /data directory, like /mnt/tank/database.txt)
 

Barajiqal

Cadet
Joined
Aug 29, 2011
Messages
3
So after looking through the dump file it looks like I can just add groups and users in the .txt, then delete the existing database and restore it using the modified text file and they should show up. The next question I have is I see the user passwords are hashed, is there a way I could generate those hashes out side of the GUI? Also as a side note would restoring a dump to an alternate system work just the same, as in would the passwords still be the same hash?

Thanks in advance
-bar
 
Status
Not open for further replies.
Top