From 7da85faeed9302756a020f5e44435e63c860a98a Mon Sep 17 00:00:00 2001 From: nate Date: Fri, 23 Feb 2018 14:31:25 -0800 Subject: [PATCH] clarify variables in rename script --- scripts/rename_user.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scripts/rename_user.py b/scripts/rename_user.py index 30497e7..9e657e7 100644 --- a/scripts/rename_user.py +++ b/scripts/rename_user.py @@ -1,12 +1,14 @@ #!/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 sys import subprocess -def rename_user(username, new_username): - # usermod -l new_username -m -d /home/{new_username} username +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.""" args = [ 'usermod', '-l', @@ -14,7 +16,7 @@ def rename_user(username, new_username): '-m', '-d', os.path.join('/home', new_username), - username + old_username ] subprocess.run(args, check=True)