Added delete user support.
This commit is contained in:
parent
88e2428a71
commit
980193c347
5 changed files with 191 additions and 3 deletions
26
scripts/system/delete_user.py
Normal file
26
scripts/system/delete_user.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#!/usr/bin/python3 -u
|
||||
|
||||
import sys
|
||||
import argparse
|
||||
import os
|
||||
#from pastafariutils.unix import add_user, del_user, change_password
|
||||
from pathlib import Path
|
||||
from subprocess import call, DEVNULL
|
||||
import json
|
||||
import time
|
||||
import shutil
|
||||
import pwd
|
||||
import distro
|
||||
import subprocess
|
||||
from pastafariutils import linux
|
||||
|
||||
parser=argparse.ArgumentParser(prog='delete_user.py', description='Delete user in linux system')
|
||||
|
||||
parser.add_argument('--user', help='The unix user', required=True)
|
||||
|
||||
args=parser.parse_args()
|
||||
|
||||
if not linux.shell_command('sudo userdel -r {}'.format(args.user)):
|
||||
linux.json_log('Sorry, cannot delete theuser, please check permissions and the user exists', error=1, status=1, progress=100, no_progress=0, return_message=0, result=None)
|
||||
exit(1)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue