Set +x on create-user-database script
[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
d2462e94 17# We don't use separate partitions for logs
18#LOGSPATH=/afs/.hcoop.net/common/.logs/$USER
19
20sudo rm -f /etc/keytabs/mailfilter/$USER
21sudo rm -f /etc/keytabs/cgi/$USER
03807e61 22sudo rm -f /etc/keytabs/user.daemon/$USER
d2462e94 23
24# LDAP
25sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
26 uid=$USER,ou=People,dc=hcoop,dc=net
27sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
28 uid=$USER.cgi,ou=People,dc=hcoop,dc=net
29sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
30 uid=$USER.mailfilter,ou=People,dc=hcoop,dc=net
31sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
32 cn=$USER,ou=Group,dc=hcoop,dc=net
33sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
34 cn=$USER.cgi,ou=Group,dc=hcoop,dc=net
35sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
36 cn=$USER.mailfilter,ou=Group,dc=hcoop,dc=net
03807e61 37sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
38 cn=$USER.daemon,ou=Group,dc=hcoop,dc=net
d2462e94 39
8791f670 40# Remove from domtool
41domtool-rmuser $USER
42
d2462e94 43# Invalidate nscd cache
44sudo nscd -i passwd
45sudo nscd -i group
46
47# Remove from databases
e3f713a3 48#sudo -u postgres psql -c "DROP TABLESPACE user_$USER"
d2462e94 49#sudo -u postgres psql -c "DROP USER $USER"
50#sudo -H mysql -e "DROP USER $USER@localhost"
51
e3f713a3 52# Remove privs before rm
53fs sa $HOMEPATH -clear system:anyuser none
54fs sa $MAILPATH -clear system:anyuser none
55#XXX see what to do with db volume
56
d2462e94 57fs rm $MAILPATH
58fs rm $HOMEPATH
59#fs rm $LOGSPATH
e3f713a3 60#fs rm $DBPATH
1311d6b0 61fs rm /afs/.hcoop.net/old/user/$PATHBITS
62fs rm /afs/.hcoop.net/old/mail/$PATHBITS
e3f713a3 63
64# Don't delete volumes, rename them.
2639c68f 65#vos remove deleuze.hcoop.net /vicepa user.$USER
66#vos remove deleuze.hcoop.net /vicepa mail.$USER
67#vos remove deleuze.hcoop.net /vicepa db.$USER
d2462e94 68#vos remove deleuze.hcoop.net /vicepa logs.$USER
e3f713a3 69vos rename user.$USER user.$USER.d
70vos rename mail.$USER mail.$USER.d
71#XXX vos rename db.$USER db.$USER.d
d2462e94 72
82cda9f8 73#vos release common.databases
d2462e94 74#vos release common.logs
75
76sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
77sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
78sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
03807e61 79sudo kadmin.local -q "delprinc -force $USER/daemon@HCOOP.NET"
d2462e94 80
81pts delete $USER
82pts delete $USER.mailfilter
83pts delete $USER.cgi
03807e61 84pts delete $USER.daemon
d2462e94 85
86#fs rm /afs/hcoop.net/old/user/$PATHBITS
87#fs rm /afs/hcoop.net/old/mail/$PATHBITS
88#fs rm /afs/hcoop.net/old/logs/$PATHBITS
89
487d87d3
CE
90vos syncserv fritz
91vos syncvldb fritz
d2462e94 92fs checkvolumes
93
2a2fcc8e 94# Remove user from all of our mailing lists
95echo $USER@hcoop.net | sudo -u list \
96 /var/lib/mailman/bin/remove_members --fromall -f -
1311d6b0 97