[tools] Wrapper pour créer un home quand generate échoue

(On appel la même fonction que générate)
This commit is contained in:
Valentin Samir 2013-08-30 16:02:50 +02:00
parent 9c1cfbe8d1
commit 8828e9697a
3 changed files with 35 additions and 2 deletions

View file

@ -134,9 +134,11 @@ class home:
print OK print OK
### Mail ### Mail
os.mkdir(home + '/Mail', 0700) if not os.path.exists(home + '/Mail'):
os.mkdir(home + '/Mail', 0700)
os.chown(home + '/Mail', int(uid), config.gid) os.chown(home + '/Mail', int(uid), config.gid)
os.mkdir('/home-adh/mail/' + login, 0770) if not os.path.exists('/home-adh/mail/' + login):
os.mkdir('/home-adh/mail/' + login, 0770)
os.chown('/home-adh/mail/' + login, int(uid), 8) os.chown('/home-adh/mail/' + login, int(uid), 8)
### Redirection ### Redirection

2
gestion/tools/mkhome Executable file
View file

@ -0,0 +1,2 @@
#!/bin/sh
sudo /usr/scripts/gestion/tools/mkhome.py $@

29
gestion/tools/mkhome.py Executable file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import socket
sys.path.append('/usr/scripts')
sys.path.append('/etc/crans')
import services
if not 'crans-nfs' in services.services or not socket.gethostname() in services.services['crans-nfs']:
sys.stderr.write("Devrait être exécuté sur une machine du groupe 'crans-nfs'\n")
exit(1)
import lc_ldap.shortcuts
import gestion.gen_confs.adherents
conn=lc_ldap.shortcuts.lc_ldap_readonly()
l=[]
for user in sys.argv[1:]:
a=conn.search(u'uid=%s' % user)
if a and a[0]['homeDirectory'] and a[0]['uidNumber'] and a[0]['uid']:
l.append("%s,%s,%s" % (a[0]['homeDirectory'][0], a[0]['uidNumber'][0], a[0]['uid'][0]))
if l:
h=gestion.gen_confs.adherents.home(l)
h.reconfigure()