2022-01-06 00:34:40 +00:00
|
|
|
#!/usr/bin/python
|
2021-08-03 03:23:02 +00:00
|
|
|
|
2022-01-06 00:09:54 +00:00
|
|
|
from sys import argv
|
2022-01-05 23:26:51 +00:00
|
|
|
from subprocess import run
|
2021-08-03 03:23:02 +00:00
|
|
|
|
2022-01-06 00:34:40 +00:00
|
|
|
|
2022-01-05 23:26:51 +00:00
|
|
|
def deluser(username):
|
2022-01-14 00:21:28 +00:00
|
|
|
"""Delete a user"""
|
|
|
|
|
|
|
|
# Delete from LDAP server
|
2022-01-06 00:04:23 +00:00
|
|
|
run(['ldapdelete', '-W', '-D', 'cn=Manager,dc=exozy,dc=me', 'uid=' + username +
|
|
|
|
',ou=People,dc=exozy,dc=me', 'cn=' + username + ',ou=Group,dc=exozy,dc=me'])
|
2021-12-11 20:45:12 +00:00
|
|
|
# Cleanup
|
2022-01-06 00:04:23 +00:00
|
|
|
run(['sudo', 'rm', '-rf', '/home/' + username])
|
2022-01-05 23:26:51 +00:00
|
|
|
|
2022-01-06 00:34:40 +00:00
|
|
|
|
2022-01-05 23:26:51 +00:00
|
|
|
# Running as script
|
|
|
|
if __name__ == "__main__":
|
2022-01-06 00:09:54 +00:00
|
|
|
deluser(argv[1])
|