let make-account-for-fyodor-user work for non-megacz admins
[clinton/scripts.git] / destroy-user
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
8 USER=$1
9
10 PATHBITS=`echo $USER | head -c 1`/`echo $USER | head -c 2`/$USER
11 HOMEPATH=/afs/hcoop.net/user/$PATHBITS
12 MAILPATH=/afs/hcoop.net/common/email/$PATHBITS
13 DBPATH=/afs/.hcoop.net/common/.databases/$PATHBITS
14 # We don't use separate partitions for logs
15 #LOGSPATH=/afs/.hcoop.net/common/.logs/$USER
16
17 sudo rm -f /etc/keytabs/mailfilter/$USER
18 sudo rm -f /etc/keytabs/cgi/$USER
19
20 # LDAP
21 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
22 uid=$USER,ou=People,dc=hcoop,dc=net
23 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
24 uid=$USER.cgi,ou=People,dc=hcoop,dc=net
25 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
26 uid=$USER.mailfilter,ou=People,dc=hcoop,dc=net
27 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
28 cn=$USER,ou=Group,dc=hcoop,dc=net
29 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
30 cn=$USER.cgi,ou=Group,dc=hcoop,dc=net
31 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
32 cn=$USER.mailfilter,ou=Group,dc=hcoop,dc=net
33
34 # Invalidate nscd cache
35 sudo nscd -i passwd
36 sudo nscd -i group
37
38 # Remove from databases
39 sudo -u postgres psql -c "DROP TABLESPACE user_$USER"
40 #sudo -u postgres psql -c "DROP USER $USER"
41 #sudo -H mysql -e "DROP USER $USER@localhost"
42
43 fs rm $MAILPATH
44 fs rm $HOMEPATH
45 #fs rm $LOGSPATH
46 fs rm $DBPATH
47 fs rm /afs/hcoop.net/old/user/$PATHBITS
48 fs rm /afs/hcoop.net/old/mail/$PATHBITS
49 vos remove deleuze.hcoop.net /vicepa user.$USER
50 vos remove deleuze.hcoop.net /vicepa mail.$USER
51 vos remove deleuze.hcoop.net /vicepa db.$USER
52 #vos remove deleuze.hcoop.net /vicepa logs.$USER
53
54 vos release common.databases
55 #vos release common.logs
56
57 sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
58 sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
59 sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
60
61 pts delete $USER
62 pts delete $USER.mailfilter
63 pts delete $USER.cgi
64
65 #fs rm /afs/hcoop.net/old/user/$PATHBITS
66 #fs rm /afs/hcoop.net/old/mail/$PATHBITS
67 #fs rm /afs/hcoop.net/old/logs/$PATHBITS
68
69 vos syncserv deleuze
70 vos syncvldb deleuze
71 fs checkvolumes
72