Last change
on this file since 924 was
204,
checked in by presbrey, 18 years ago
|
gems install script
rpms install script
user import signup script
suexec SELinux error bug fix
|
-
Property svn:executable set to
*
|
File size:
1.0 KB
|
Rev | Line | |
---|
[204] | 1 | #!/usr/bin/python |
---|
| 2 | """Add system users from external passwd and group files |
---|
| 3 | Joe Presbrey <presbrey@mit.edu> |
---|
| 4 | |
---|
| 5 | arguments: <passwd-file> <group-file>""" |
---|
| 6 | |
---|
| 7 | |
---|
| 8 | import commands |
---|
| 9 | import os,sys,string |
---|
| 10 | #import athena |
---|
| 11 | |
---|
| 12 | def do_groupfile(f): |
---|
| 13 | for x in f.readlines(): |
---|
| 14 | gname = x.strip().split(':')[0] |
---|
| 15 | gid = x.strip().split(':')[2] |
---|
| 16 | c = commands.getstatusoutput('groupadd -g ' + gid + ' ' + gname) |
---|
| 17 | if c[0] == 0: |
---|
| 18 | print "group " + gname + "/" + gid + " added successfully." |
---|
| 19 | |
---|
| 20 | def do_userfile(f): |
---|
| 21 | for x in f.readlines(): |
---|
| 22 | name = x.strip().split(':')[0] |
---|
| 23 | #uathena = AthenaUser(name) |
---|
| 24 | uid = x.strip().split(':')[2] |
---|
| 25 | gid = x.strip().split(':')[3] |
---|
| 26 | home = x.strip().split(':')[5] |
---|
| 27 | if uid > 100: |
---|
| 28 | c = commands.getstatusoutput('useradd -M -d ' + home + ' -u ' + uid + ' -g ' + gid + ' -G users -s /usr/local/bin/mbash ' + name) |
---|
| 29 | if c[0] == 0: |
---|
| 30 | print "user " + name + "/" + uid + " added successfully." |
---|
| 31 | |
---|
| 32 | if __name__ == "__main__": |
---|
| 33 | if len(sys.argv) != 3: |
---|
| 34 | print __doc__ |
---|
| 35 | else: |
---|
| 36 | do_groupfile(file(sys.argv[2])) |
---|
| 37 | do_userfile(file(sys.argv[1])) |
---|
Note: See
TracBrowser
for help on using the repository browser.