scripts/deluser

20 lines
452 B
Text
Raw Normal View History

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):
"""Delete a user"""
# Delete from LDAP server
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'])
# Cleanup
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])