Mise en forme.
darcs-hash:20060406031054-68412-9f7f19f8e8c05e3e550c312a612e89e0c7deda2c.gz
This commit is contained in:
parent
cd8bafd791
commit
3ed8efdd26
1 changed files with 40 additions and 34 deletions
|
@ -15,7 +15,7 @@ class del_user:
|
|||
|
||||
debug = True
|
||||
|
||||
def __init__(self,args):
|
||||
def __init__(self, args):
|
||||
self.args = args
|
||||
|
||||
def reconfigure(self):
|
||||
|
@ -57,84 +57,90 @@ class del_user:
|
|||
|
||||
class home:
|
||||
debug = True
|
||||
def __init__(self,args) :
|
||||
|
||||
def __init__(self, args):
|
||||
self.args = args
|
||||
def reconfigure(self) :
|
||||
|
||||
def reconfigure(self):
|
||||
cprint(u'Création home', 'gras')
|
||||
for args in self.args :
|
||||
for args in self.args:
|
||||
anim('\t' + args)
|
||||
try:
|
||||
home, uid, login = args.split(',')
|
||||
### Home
|
||||
if not os.path.exists(home) :
|
||||
if not os.path.exists(home):
|
||||
# Le home n'existe pas
|
||||
os.mkdir(home, 0755)
|
||||
os.chown(home, int(uid) ,config.gid)
|
||||
elif os.path.isdir(home) :
|
||||
# Il y un répertoire existant
|
||||
os.chown(home, int(uid), config.gid)
|
||||
elif os.path.isdir(home):
|
||||
# Il y un répertoire existant
|
||||
# Bon UID ?
|
||||
stat = os.stat(home)
|
||||
if stat[4] != int(uid) or stat[5] != config.gid :
|
||||
# Le home n'est pas à la bonne personne
|
||||
if stat[4] != int(uid) or stat[5] != config.gid:
|
||||
# Le home n'est pas pas à la bonne personne
|
||||
raise OSError('home existant')
|
||||
|
||||
### Quota
|
||||
status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login )
|
||||
if status :
|
||||
if status:
|
||||
print WARNING
|
||||
if self.debug :
|
||||
if self.debug:
|
||||
sys.stderr.write(output+'\n')
|
||||
else :
|
||||
else:
|
||||
print OK
|
||||
|
||||
### Mail
|
||||
os.mkdir(home + '/Mail', 0700)
|
||||
os.chown(home + '/Mail', int(uid) ,config.gid)
|
||||
os.mkdir('/var/mail/' + login,0770)
|
||||
os.chown('/var/mail/' + login, int(uid) ,8)
|
||||
os.chown(home + '/Mail', int(uid), config.gid)
|
||||
os.mkdir('/var/mail/' + login, 0770)
|
||||
os.chown('/var/mail/' + login, int(uid), 8)
|
||||
|
||||
except :
|
||||
except:
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
if self.debug:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
class mail_bienvenue :
|
||||
|
||||
class mail_bienvenue:
|
||||
debug = True
|
||||
def __init__(self,mails) :
|
||||
|
||||
def __init__(self, mails):
|
||||
self.mails = mails
|
||||
|
||||
def reconfigure(self) :
|
||||
def reconfigure(self):
|
||||
cprint(u'Envoi mail de bienvenue', 'gras')
|
||||
for mail in self.mails :
|
||||
for mail in self.mails:
|
||||
anim('\t' + mail)
|
||||
try:
|
||||
From = "respbats@crans.org"
|
||||
To = mail
|
||||
if To.find('@') == -1 : To += '@crans.org'
|
||||
if To.find('@') == -1: To += '@crans.org'
|
||||
conn=smtplib.SMTP('localhost')
|
||||
conn.sendmail(From, To , config.txt_mail_bienvenue % { 'From' : From, 'To' : To })
|
||||
conn.sendmail(From, To, config.txt_mail_bienvenue % { 'From': From, 'To': To })
|
||||
conn.quit()
|
||||
print OK
|
||||
except Exception, c:
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
if self.debug:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
|
||||
class ML_ens :
|
||||
class ML_ens:
|
||||
debug = True
|
||||
def __init__(self,mails) :
|
||||
|
||||
def __init__(self, mails):
|
||||
self.mails = mails
|
||||
|
||||
def reconfigure(self) :
|
||||
def reconfigure(self):
|
||||
cprint(u'Inscription ML-ENS', 'gras')
|
||||
for mail in self.mails :
|
||||
anim('\t'+mail)
|
||||
for mail in self.mails:
|
||||
anim('\t' + mail)
|
||||
status, output = commands.getstatusoutput("echo '%s' | /usr/sbin/add_members -r - com-ens >/dev/null 2>&1" % mail)
|
||||
if status :
|
||||
if status:
|
||||
print ERREUR
|
||||
if self.debug :
|
||||
sys.stderr.write(output+'\n')
|
||||
else :
|
||||
if self.debug:
|
||||
sys.stderr.write(output + '\n')
|
||||
else:
|
||||
print OK
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue