nethserver-usercsvimport/README.md

31 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

2015-10-18 15:06:28 +00:00
# nethserver-usercsvimport
2018-08-13 07:10:41 +00:00
[![Build Status](https://drone.libreschool.org/api/badges/LibreSchool/nethserver-usercsvimport/status.svg)](https://drone.libreschool.org/LibreSchool/nethserver-usercsvimport)
2015-10-18 15:20:08 +00:00
Batch import a lot of users and groups.
You need a CSV file with this layout:
2016-03-30 21:19:15 +00:00
username Firstname Lastname password group1 [group2] [group3] [groupN]
2015-10-18 15:20:08 +00:00
See test.csv file for a sample.
You can use the TAB as a separator (this is the default), or whatever character you want.
2016-03-30 21:19:15 +00:00
Beware that Microsoft Excel uses the semicolon (;) as a separator instead the comma (,) for a CSV file (COMMA separated value).
2015-10-18 15:20:08 +00:00
2016-03-30 23:25:36 +00:00
To import, simply call the script passing the input file as STDIN or via the --file switch.
2015-10-18 15:20:08 +00:00
2018-08-13 07:02:52 +00:00
/usr/bin/usercsvimport [--file INPUTFILE] [--separator SEPARATOR] [--add_existing_users_to_groups] [--remove_users]
2015-10-18 15:20:08 +00:00
2016-03-30 23:25:36 +00:00
Some examples:
2018-08-13 07:02:52 +00:00
/usr/bin/usercsvimport < test.csv
/usr/bin/usercsvimport --file test.csv --separator ";"
cat test.csv | /usr/bin/usercsvimport --separator "," --add_existing_users_to_groups
2016-03-30 23:25:36 +00:00
You can specify a custom field separator.
The import process will create all non-existing groups. If the user already exists and the "add_existing_users_to_groups" switch is NOT set, then the line is skipped (so if you specify a nonexistent group for this user, the group won't be created). If you enable "add_existing_users_to_groups" and the user is already present, the non-existing groups are created and the user is assigned to all the specified groups.
If you specify a group name which starts with a "-" (dash), then the user will be removed from that group. This feature is working even if you don't enable "add_existing_users_to_groups".
To remove users you can use the same .CSV file you used for creation, or you can provide a file with a users list (one user per line). This file will be parsed for user deletion if you specify the "--remove_users" parameter.