create-user: Add symlink for gitweb hosting
[clinton/scripts.git] / destroy-user
... / ...
CommitLineData
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
19sudo rm -f /etc/keytabs/user.daemon/$USER
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
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
36
37# Remove from domtool
38domtool-rmuser $USER
39
40# Invalidate nscd cache
41sudo nscd -i passwd
42sudo nscd -i group
43
44# Remove from databases
45sudo -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
49fs rm $MAILPATH
50fs rm $HOMEPATH
51#fs rm $LOGSPATH
52fs rm $DBPATH
53fs rm /afs/hcoop.net/old/user/$PATHBITS
54fs rm /afs/hcoop.net/old/mail/$PATHBITS
55vos remove deleuze.hcoop.net /vicepa user.$USER
56vos remove deleuze.hcoop.net /vicepa mail.$USER
57vos remove deleuze.hcoop.net /vicepa db.$USER
58#vos remove deleuze.hcoop.net /vicepa logs.$USER
59
60vos release common.databases
61#vos release common.logs
62
63sudo kadmin.local -q "delprinc -force $USER@HCOOP.NET"
64sudo kadmin.local -q "delprinc -force $USER/mailfilter@HCOOP.NET"
65sudo kadmin.local -q "delprinc -force $USER/cgi@HCOOP.NET"
66sudo kadmin.local -q "delprinc -force $USER/daemon@HCOOP.NET"
67
68pts delete $USER
69pts delete $USER.mailfilter
70pts delete $USER.cgi
71pts 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
77vos syncserv deleuze
78vos syncvldb deleuze
79fs checkvolumes
80