also rename user's group
parent
b25ad2de8e
commit
169df3e84d
|
@ -9,6 +9,8 @@ import subprocess
|
|||
def rename_user(old_username, new_username):
|
||||
"""Given an old and a new username, renames user on disk with usermod.
|
||||
Raises if the usermod call fails."""
|
||||
|
||||
# Rename user
|
||||
args = [
|
||||
'usermod',
|
||||
'-l',
|
||||
|
@ -20,6 +22,15 @@ def rename_user(old_username, new_username):
|
|||
]
|
||||
subprocess.run(args, check=True)
|
||||
|
||||
# Rename their group
|
||||
args = [
|
||||
'groupmod',
|
||||
'-n',
|
||||
new_username,
|
||||
old_username
|
||||
]
|
||||
subprocess.run(args, check=True)
|
||||
|
||||
|
||||
def main(argv):
|
||||
if len(argv) < 3:
|
||||
|
|
Loading…
Reference in New Issue