clarify variables in rename script

pull/28/head
nate 2018-02-23 14:31:25 -08:00
parent 0d8b370b5d
commit 7da85faeed
1 changed files with 6 additions and 4 deletions

View File

@ -1,12 +1,14 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
"""This script wraps the usermod command to allow user account renames via sudoers.""" """This script wraps the usermod command to allow user account renames via
sudoers."""
import os import os
import sys import sys
import subprocess import subprocess
def rename_user(username, new_username): def rename_user(old_username, new_username):
# usermod -l new_username -m -d /home/{new_username} username """Given an old and a new username, renames user on disk with usermod.
Raises if the usermod call fails."""
args = [ args = [
'usermod', 'usermod',
'-l', '-l',
@ -14,7 +16,7 @@ def rename_user(username, new_username):
'-m', '-m',
'-d', '-d',
os.path.join('/home', new_username), os.path.join('/home', new_username),
username old_username
] ]
subprocess.run(args, check=True) subprocess.run(args, check=True)