Sync new-user fix from common area
[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 sudo rm -f /etc/keytabs/user.daemon/$USER
20
21 # LDAP
22 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
23 uid=$USER,ou=People,dc=hcoop,dc=net
24 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
25 uid=$USER.cgi,ou=People,dc=hcoop,dc=net
26 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
27 uid=$USER.mailfilter,ou=People,dc=hcoop,dc=net
28 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
29 cn=$USER,ou=Group,dc=hcoop,dc=net
30 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
31 cn=$USER.cgi,ou=Group,dc=hcoop,dc=net
32 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
33 cn=$USER.mailfilter,ou=Group,dc=hcoop,dc=net
34 sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
35 cn=$USER.daemon,ou=Group,dc=hcoop,dc=net
36
37 # Remove from domtool
38 domtool-rmuser $USER
39
40 # Invalidate nscd cache
41 sudo nscd -i passwd
42 sudo nscd -i group
43
44 # Remove from databases
45 sudo -u postgres psql -c "DROP TABLESPACE user_$USER"
46 #sudo -u postgres psql -c "DROP USER $USER"
47 #sudo -H mysql -e "DROP USER $USER@localhost"
48
49 fs rm $MAILPATH
50 fs rm $HOMEPATH
51 #fs rm $LOGSPATH
52 fs rm $DBPATH
53 fs rm /afs/hcoop.net/old/user/$PATHBITS
54 fs rm /afs/hcoop.net/old/mail/$PATHBITS
55 vos remove deleuze.hcoop.net /vicepa user.$USER
56 vos remove deleuze.hcoop.net /vicepa mail.$USER
57 vos remove deleuze.hcoop.net /vicepa db.$USER
58 #vos remove deleuze.hcoop.net /vicepa logs.$USER
59
60 vos release common.databases
61 #vos release common.logs
62
63 sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
64 sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
65 sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
66 sudo kadmin.local -q "delprinc -force $USER/daemon@HCOOP.NET"
67
68 pts delete $USER
69 pts delete $USER.mailfilter
70 pts delete $USER.cgi
71 pts delete $USER.daemon
72
73 #fs rm /afs/hcoop.net/old/user/$PATHBITS
74 #fs rm /afs/hcoop.net/old/mail/$PATHBITS
75 #fs rm /afs/hcoop.net/old/logs/$PATHBITS
76
77 vos syncserv deleuze
78 vos syncvldb deleuze
79 fs checkvolumes
80
81 # Remove user from all of our mailing lists
82 echo $USER@hcoop.net | sudo -u list \
83 /var/lib/mailman/bin/remove_members --fromall -f -