hcoop-backup: Move logging to backup-wrapper, use UTC date.
[clinton/scripts.git] / destroy-user
CommitLineData
d2462e94 1#!/bin/bash
2
3# MUST be executed:
4# - on deleuze
5# - as a user with an /etc/sudoers line
6# - while holding system:administrator tokens
7
8USER=$1
1311d6b0 9if test -z "$USER"; then
10 echo Usage: destroy-user USERNAME
11 exit 1
12fi
d2462e94 13
14PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
15HOMEPATH=/afs/hcoop.net/user/$PATHBITS
16MAILPATH=/afs/hcoop.net/common/email/$PATHBITS
17DBPATH=/afs/.hcoop.net/common/.databases/$PATHBITS
18# We don't use separate partitions for logs
19#LOGSPATH=/afs/.hcoop.net/common/.logs/$USER
20
21sudo rm -f /etc/keytabs/mailfilter/$USER
22sudo rm -f /etc/keytabs/cgi/$USER
03807e61 23sudo rm -f /etc/keytabs/user.daemon/$USER
d2462e94 24
25# LDAP
26sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
27 uid=$USER,ou=People,dc=hcoop,dc=net
28sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
29 uid=$USER.cgi,ou=People,dc=hcoop,dc=net
30sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
31 uid=$USER.mailfilter,ou=People,dc=hcoop,dc=net
32sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
33 cn=$USER,ou=Group,dc=hcoop,dc=net
34sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
35 cn=$USER.cgi,ou=Group,dc=hcoop,dc=net
36sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
37 cn=$USER.mailfilter,ou=Group,dc=hcoop,dc=net
03807e61 38sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
39 cn=$USER.daemon,ou=Group,dc=hcoop,dc=net
d2462e94 40
8791f670 41# Remove from domtool
42domtool-rmuser $USER
43
d2462e94 44# Invalidate nscd cache
45sudo nscd -i passwd
46sudo nscd -i group
47
48# Remove from databases
49sudo -u postgres psql -c "DROP TABLESPACE user_$USER"
50#sudo -u postgres psql -c "DROP USER $USER"
51#sudo -H mysql -e "DROP USER $USER@localhost"
52
53fs rm $MAILPATH
54fs rm $HOMEPATH
55#fs rm $LOGSPATH
56fs rm $DBPATH
1311d6b0 57fs rm /afs/.hcoop.net/old/user/$PATHBITS
58fs rm /afs/.hcoop.net/old/mail/$PATHBITS
2639c68f 59#vos remove deleuze.hcoop.net /vicepa user.$USER
60#vos remove deleuze.hcoop.net /vicepa mail.$USER
61#vos remove deleuze.hcoop.net /vicepa db.$USER
d2462e94 62#vos remove deleuze.hcoop.net /vicepa logs.$USER
63
64vos release common.databases
65#vos release common.logs
66
67sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
68sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
69sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
03807e61 70sudo kadmin.local -q "delprinc -force $USER/daemon@HCOOP.NET"
d2462e94 71
72pts delete $USER
73pts delete $USER.mailfilter
74pts delete $USER.cgi
03807e61 75pts delete $USER.daemon
d2462e94 76
77#fs rm /afs/hcoop.net/old/user/$PATHBITS
78#fs rm /afs/hcoop.net/old/mail/$PATHBITS
79#fs rm /afs/hcoop.net/old/logs/$PATHBITS
80
81vos syncserv deleuze
82vos syncvldb deleuze
83fs checkvolumes
84
2a2fcc8e 85# Remove user from all of our mailing lists
86echo $USER@hcoop.net | sudo -u list \
87 /var/lib/mailman/bin/remove_members --fromall -f -
1311d6b0 88