also rename user's group

feature/enhanced-ticket-view
nate 2018-02-24 18:34:55 -08:00
parent b25ad2de8e
commit 169df3e84d
1 changed files with 11 additions and 0 deletions

View File

@ -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: