change example
This commit is contained in:
parent
da45cf4f5a
commit
6a0c42f86b
@ -19,8 +19,10 @@ def main():
|
||||
if (len(elements) != 2):
|
||||
print("Skipping invalid group config string \"" + group + "\"")
|
||||
continue
|
||||
subprocess.check_call(shlex.join(["addgroup", "-g", elements[1], elements[0]]), shell=True)
|
||||
print("Added group " + elements[0] + " with gid " + elements[1])
|
||||
gid = elements[1]
|
||||
gname = elements[0]
|
||||
subprocess.check_call("addgroup -g" + shlex.quote(gid) + " " + shlex.quote(gname), shell=True)
|
||||
print("Added group " + gname + " with gid " + gid)
|
||||
|
||||
|
||||
# username,uid,password,[group]
|
||||
@ -29,13 +31,17 @@ def main():
|
||||
if (len(elements) != 3 and len(elements) != 4):
|
||||
print("Skipping invalid user config string \"" + user + "\"")
|
||||
continue
|
||||
subprocess.check_call(shlex.join(["adduser", "-D", "-H", "-u", elements[1], elements[0]]), shell=True)
|
||||
print("Added user " + elements[0] + " with uid " + elements[1])
|
||||
uname = elements[0]
|
||||
uid = elements[1]
|
||||
passwd = elements[2]
|
||||
subprocess.check_call("adduser -D -H -u ", shlex.quote(uid), shlex.quote(uname), shell=True)
|
||||
print("Added user " + uname + " with uid " + uid)
|
||||
if (len(elements) == 4):
|
||||
subprocess.check_call(shlex.join(["addgroup", elements[0], elements[3]]), shell=True)
|
||||
print("Added user " + elements[0] + " to group " + elements[3])
|
||||
gname = elements[3]
|
||||
subprocess.check_call("addgroup " + shlex.quote(uname) + " " + shlex.quote(gname), shell=True)
|
||||
print("Added user " + uname + " to group " + gname)
|
||||
# set passwd
|
||||
subprocess.check_call(shlex.join(["echo", "-ne", "\"" + elements[2] + "\n" + elements[2] + "\n\""]) + " | " + shlex.join(["smbpasswd", "-a", "-U", elements[0]]), shell=True)
|
||||
print("Set user " + elements[0] + " password to " + elements[2])
|
||||
subprocess.check_call("echo -ne " + shlex.quote("\n" + passwd + "\n" + passwd + "\n") + " | smbpasswd -a -U " + shlex.quote(uname), shell=True)
|
||||
print("Set user " + uname + " password to " + passwd)
|
||||
|
||||
main()
|
Loading…
Reference in New Issue
Block a user