added backup 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
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
19
20# LDAP
21sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
22 uid=$USER,ou=People,dc=hcoop,dc=net
23sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
24 uid=$USER.cgi,ou=People,dc=hcoop,dc=net
25sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
26 uid=$USER.mailfilter,ou=People,dc=hcoop,dc=net
27sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
28 cn=$USER,ou=Group,dc=hcoop,dc=net
29sudo ldapdelete -v -x -D cn=admin,dc=hcoop,dc=net -y /etc/ldap.secret \
30 cn=$USER.cgi,ou=Group,dc=hcoop,dc=net
31sudo 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
35sudo nscd -i passwd
36sudo nscd -i group
37
38# Remove from databases
39sudo -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
43fs rm $MAILPATH
44fs rm $HOMEPATH
45#fs rm $LOGSPATH
46fs rm $DBPATH
47fs rm /afs/hcoop.net/old/user/$PATHBITS
48fs rm /afs/hcoop.net/old/mail/$PATHBITS
49vos remove deleuze.hcoop.net /vicepa user.$USER
50vos remove deleuze.hcoop.net /vicepa mail.$USER
51vos remove deleuze.hcoop.net /vicepa db.$USER
52#vos remove deleuze.hcoop.net /vicepa logs.$USER
53
54vos release common.databases
55#vos release common.logs
56
57sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
58sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
59sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
60
61pts delete $USER
62pts delete $USER.mailfilter
63pts 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
69vos syncserv deleuze
70vos syncvldb deleuze
71fs checkvolumes
72