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