Changes by docelic.
[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
e3f713a3 49#sudo -u postgres psql -c "DROP TABLESPACE user_$USER"
d2462e94 50#sudo -u postgres psql -c "DROP USER $USER"
51#sudo -H mysql -e "DROP USER $USER@localhost"
52
e3f713a3 53# Remove privs before rm
54fs sa $HOMEPATH -clear system:anyuser none
55fs sa $MAILPATH -clear system:anyuser none
56#XXX see what to do with db volume
57
d2462e94 58fs rm $MAILPATH
59fs rm $HOMEPATH
60#fs rm $LOGSPATH
e3f713a3 61#fs rm $DBPATH
1311d6b0 62fs rm /afs/.hcoop.net/old/user/$PATHBITS
63fs rm /afs/.hcoop.net/old/mail/$PATHBITS
e3f713a3 64
65# Don't delete volumes, rename them.
2639c68f 66#vos remove deleuze.hcoop.net /vicepa user.$USER
67#vos remove deleuze.hcoop.net /vicepa mail.$USER
68#vos remove deleuze.hcoop.net /vicepa db.$USER
d2462e94 69#vos remove deleuze.hcoop.net /vicepa logs.$USER
e3f713a3 70vos rename user.$USER user.$USER.d
71vos rename mail.$USER mail.$USER.d
72#XXX vos rename db.$USER db.$USER.d
d2462e94 73
74vos release common.databases
75#vos release common.logs
76
77sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
78sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
79sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
03807e61 80sudo kadmin.local -q "delprinc -force $USER/daemon@HCOOP.NET"
d2462e94 81
82pts delete $USER
83pts delete $USER.mailfilter
84pts delete $USER.cgi
03807e61 85pts delete $USER.daemon
d2462e94 86
87#fs rm /afs/hcoop.net/old/user/$PATHBITS
88#fs rm /afs/hcoop.net/old/mail/$PATHBITS
89#fs rm /afs/hcoop.net/old/logs/$PATHBITS
90
91vos syncserv deleuze
92vos syncvldb deleuze
93fs checkvolumes
94
2a2fcc8e 95# Remove user from all of our mailing lists
96echo $USER@hcoop.net | sudo -u list \
97 /var/lib/mailman/bin/remove_members --fromall -f -
1311d6b0 98