From 8828e9697ad0817db2a0fa3c7ac4affea56a156b Mon Sep 17 00:00:00 2001 From: Valentin Samir Date: Fri, 30 Aug 2013 16:02:50 +0200 Subject: [PATCH] =?UTF-8?q?[tools]=20Wrapper=20pour=20cr=C3=A9er=20un=20ho?= =?UTF-8?q?me=20quand=20generate=20=C3=A9choue?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit (On appel la même fonction que générate) --- gestion/gen_confs/adherents.py | 6 ++++-- gestion/tools/mkhome | 2 ++ gestion/tools/mkhome.py | 29 +++++++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 2 deletions(-) create mode 100755 gestion/tools/mkhome create mode 100755 gestion/tools/mkhome.py diff --git a/gestion/gen_confs/adherents.py b/gestion/gen_confs/adherents.py index 4638e435..f279ae65 100644 --- a/gestion/gen_confs/adherents.py +++ b/gestion/gen_confs/adherents.py @@ -134,9 +134,11 @@ class home: print OK ### 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.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) ### Redirection diff --git a/gestion/tools/mkhome b/gestion/tools/mkhome new file mode 100755 index 00000000..28e22af9 --- /dev/null +++ b/gestion/tools/mkhome @@ -0,0 +1,2 @@ +#!/bin/sh +sudo /usr/scripts/gestion/tools/mkhome.py $@ diff --git a/gestion/tools/mkhome.py b/gestion/tools/mkhome.py new file mode 100755 index 00000000..01e810d0 --- /dev/null +++ b/gestion/tools/mkhome.py @@ -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() +