Detabification
darcs-hash:20050429145423-d1718-6918a85270b55df7ae9b838316aeee53213a336b.gz
This commit is contained in:
parent
5b003d8768
commit
69f0a20bb1
2 changed files with 223 additions and 223 deletions
|
@ -46,9 +46,9 @@ make_lock('auto_generate','Big lock',nowait=1)
|
||||||
##### Options fournies ?
|
##### Options fournies ?
|
||||||
try :
|
try :
|
||||||
if len(sys.argv) > 1 :
|
if len(sys.argv) > 1 :
|
||||||
options, arg = getopt.getopt(sys.argv[1:], 'h', args_autorises)
|
options, arg = getopt.getopt(sys.argv[1:], 'h', args_autorises)
|
||||||
else :
|
else :
|
||||||
options, arg = ( [],'')
|
options, arg = ( [],'')
|
||||||
except getopt.error, msg :
|
except getopt.error, msg :
|
||||||
sys.stderr.write('%s\n' % msg)
|
sys.stderr.write('%s\n' % msg)
|
||||||
sys.exit(255)
|
sys.exit(255)
|
||||||
|
@ -58,54 +58,54 @@ to_do = {}
|
||||||
|
|
||||||
for opt, val in options :
|
for opt, val in options :
|
||||||
if opt == '--quiet' :
|
if opt == '--quiet' :
|
||||||
debug = 0
|
debug = 0
|
||||||
|
|
||||||
elif opt == '--remove' :
|
elif opt == '--remove' :
|
||||||
for serv in val.split('&') :
|
for serv in val.split('&') :
|
||||||
print 'Supression de %s' % serv
|
print 'Supression de %s' % serv
|
||||||
db.services_to_restart('-%s' % serv)
|
db.services_to_restart('-%s' % serv)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif opt == '--list' :
|
elif opt == '--list' :
|
||||||
print 'Services à redémarrer :'
|
print 'Services à redémarrer :'
|
||||||
print db.services_to_restart()
|
print db.services_to_restart()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif opt == '--reconnect' :
|
elif opt == '--reconnect' :
|
||||||
# Personnes à reconnecter
|
# Personnes à reconnecter
|
||||||
print 'Recheche personnes en fin de sanction.'
|
print 'Recheche personnes en fin de sanction.'
|
||||||
hier = strftime('%d/%m/%Y %H:%M'.split()[0],localtime(time()-60*60*24))
|
hier = strftime('%d/%m/%Y %H:%M'.split()[0],localtime(time()-60*60*24))
|
||||||
c = db.search('blacklist=*,%s*' % hier)
|
c = db.search('blacklist=*,%s*' % hier)
|
||||||
services = []
|
services = []
|
||||||
for a_reco in c['adherent'] + c['machine'] + c['club'] :
|
for a_reco in c['adherent'] + c['machine'] + c['club'] :
|
||||||
for bl in a_reco.blacklist() :
|
for bl in a_reco.blacklist() :
|
||||||
fin, sanction = bl.split(',')[1:3]
|
fin, sanction = bl.split(',')[1:3]
|
||||||
if fin.split()[0] == hier and sanction not in services :
|
if fin.split()[0] == hier and sanction not in services :
|
||||||
services.append(sanction)
|
services.append(sanction)
|
||||||
for s in services :
|
for s in services :
|
||||||
print "Ajout de blacklist_%s pour reconfiguration" % s
|
print "Ajout de blacklist_%s pour reconfiguration" % s
|
||||||
db.services_to_restart('blacklist_%s' % s.encode())
|
db.services_to_restart('blacklist_%s' % s.encode())
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif opt=='--add' :
|
elif opt=='--add' :
|
||||||
# Ajout d'un item dans les services à redémarrer
|
# Ajout d'un item dans les services à redémarrer
|
||||||
for serv in val.split('&') :
|
for serv in val.split('&') :
|
||||||
if serv.find(',')!=-1 :
|
if serv.find(',')!=-1 :
|
||||||
serv, arg = serv.split(',',1)
|
serv, arg = serv.split(',',1)
|
||||||
arg = arg.split(',')
|
arg = arg.split(',')
|
||||||
else :
|
else :
|
||||||
arg = []
|
arg = []
|
||||||
|
|
||||||
print 'Ajout de %s (%s)' % ( serv, arg )
|
print 'Ajout de %s (%s)' % ( serv, arg )
|
||||||
db.services_to_restart(serv, arg)
|
db.services_to_restart(serv, arg)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif opt =='-h' or opt == '--help' :
|
elif opt =='-h' or opt == '--help' :
|
||||||
print __doc__ % { 'prog' : sys.argv[0].split('/')[-1] , 'options' : '\n\t'.join(args_autorises) }
|
print __doc__ % { 'prog' : sys.argv[0].split('/')[-1] , 'options' : '\n\t'.join(args_autorises) }
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
elif len(opt)>2 and opt[:2]=='--' :
|
elif len(opt)>2 and opt[:2]=='--' :
|
||||||
to_do[opt[2:]] = val.split('&')
|
to_do[opt[2:]] = val.split('&')
|
||||||
|
|
||||||
##### Lecture de la base LDAP si besion ce qu'il y a a faire et préparation
|
##### Lecture de la base LDAP si besion ce qu'il y a a faire et préparation
|
||||||
if not to_do :
|
if not to_do :
|
||||||
|
@ -123,32 +123,32 @@ if hostname == 'zamok':
|
||||||
if auto : db.services_to_restart('-del_user')
|
if auto : db.services_to_restart('-del_user')
|
||||||
cprint('Archivage fichiers utilisateur','gras')
|
cprint('Archivage fichiers utilisateur','gras')
|
||||||
for args in to_do['del_user'] :
|
for args in to_do['del_user'] :
|
||||||
anim('\t' + args)
|
anim('\t' + args)
|
||||||
try :
|
try :
|
||||||
login, home = args.split(',')
|
login, home = args.split(',')
|
||||||
if not login or not home :
|
if not login or not home :
|
||||||
raise ValueError('Argument invalide')
|
raise ValueError('Argument invalide')
|
||||||
warn = ''
|
warn = ''
|
||||||
f = config.cimetiere + '/files/' + strftime('%Y-%m-%d-%Hh%Mm_') + login + '.tar.bz2'
|
f = config.cimetiere + '/files/' + strftime('%Y-%m-%d-%Hh%Mm_') + login + '.tar.bz2'
|
||||||
status, output = commands.getstatusoutput("tar cjf '%s' '%s' /var/spool/mail/%s" % ( f,home,login) )
|
status, output = commands.getstatusoutput("tar cjf '%s' '%s' /var/spool/mail/%s" % ( f,home,login) )
|
||||||
if ( status != 512 and status!=0 ) or not os.path.isfile(f) :
|
if ( status != 512 and status!=0 ) or not os.path.isfile(f) :
|
||||||
# La 512 est si un des paths n'exite pas.
|
# La 512 est si un des paths n'exite pas.
|
||||||
raise OSError(output)
|
raise OSError(output)
|
||||||
if os.path.isdir(home) and os.stat(home)[4] >= 500 :
|
if os.path.isdir(home) and os.stat(home)[4] >= 500 :
|
||||||
shutil.rmtree(home)
|
shutil.rmtree(home)
|
||||||
else :
|
else :
|
||||||
warn += '%s incorrect\n' % home
|
warn += '%s incorrect\n' % home
|
||||||
if os.path.isfile('/var/spool/mail/' + login ) :
|
if os.path.isfile('/var/spool/mail/' + login ) :
|
||||||
os.unlink('/var/spool/mail/' + login)
|
os.unlink('/var/spool/mail/' + login)
|
||||||
else :
|
else :
|
||||||
warn += '/var/spool/mail/%s incorrect\n' % login
|
warn += '/var/spool/mail/%s incorrect\n' % login
|
||||||
|
|
||||||
if warn :
|
if warn :
|
||||||
print WARNING
|
print WARNING
|
||||||
if debug :
|
if debug :
|
||||||
sys.stderr.write(warn)
|
sys.stderr.write(warn)
|
||||||
else :
|
else :
|
||||||
print OK
|
print OK
|
||||||
except :
|
except :
|
||||||
print ERREUR
|
print ERREUR
|
||||||
# On devra le refaire la prochaine fois
|
# On devra le refaire la prochaine fois
|
||||||
|
@ -163,30 +163,30 @@ if hostname == 'zamok':
|
||||||
for args in to_do['home'] :
|
for args in to_do['home'] :
|
||||||
anim('\t' + args)
|
anim('\t' + args)
|
||||||
try :
|
try :
|
||||||
home, uid, login = args.split(',')
|
home, uid, login = args.split(',')
|
||||||
### Home
|
### Home
|
||||||
if not os.path.exists(home) :
|
if not os.path.exists(home) :
|
||||||
# Le home n'existe pas
|
# Le home n'existe pas
|
||||||
os.mkdir(home, 0755)
|
os.mkdir(home, 0755)
|
||||||
os.chown(home, int(uid) ,config.gid)
|
os.chown(home, int(uid) ,config.gid)
|
||||||
elif os.path.isdir(home) :
|
elif os.path.isdir(home) :
|
||||||
# Il y un répertoire existant
|
# Il y un répertoire existant
|
||||||
# Bon UID ?
|
# Bon UID ?
|
||||||
stat = os.stat(home)
|
stat = os.stat(home)
|
||||||
if stat[4] != int(uid) or stat[5] != config.gid :
|
if stat[4] != int(uid) or stat[5] != config.gid :
|
||||||
# Le home n'est pas à la bonne personne
|
# Le home n'est pas à la bonne personne
|
||||||
raise OSError('home existant')
|
raise OSError('home existant')
|
||||||
|
|
||||||
### Mail
|
### Mail
|
||||||
try :
|
try :
|
||||||
os.mkdir(home + '/Mail', 0700)
|
os.mkdir(home + '/Mail', 0700)
|
||||||
os.chown(home + '/Mail', int(uid) ,config.gid)
|
os.chown(home + '/Mail', int(uid) ,config.gid)
|
||||||
except :
|
except :
|
||||||
# Pas grave
|
# Pas grave
|
||||||
pass
|
pass
|
||||||
|
|
||||||
### Quota
|
### Quota
|
||||||
status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login )
|
status, output = commands.getstatusoutput('/usr/sbin/edquota -p pauget %s' % login )
|
||||||
if status :
|
if status :
|
||||||
print WARNING
|
print WARNING
|
||||||
if debug :
|
if debug :
|
||||||
|
@ -200,12 +200,12 @@ if hostname == 'zamok':
|
||||||
if debug :
|
if debug :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if 'mail_bienvenue' in to_do.keys() :
|
if 'mail_bienvenue' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-mail_bienvenue')
|
if auto : db.services_to_restart('-mail_bienvenue')
|
||||||
cprint('Envoi mail de bienvenue','gras')
|
cprint('Envoi mail de bienvenue','gras')
|
||||||
for mail in to_do['mail_bienvenue'] :
|
for mail in to_do['mail_bienvenue'] :
|
||||||
anim('\t' + mail)
|
anim('\t' + mail)
|
||||||
try :
|
try :
|
||||||
From = "respbats@crans.org"
|
From = "respbats@crans.org"
|
||||||
To = mail
|
To = mail
|
||||||
|
@ -216,11 +216,11 @@ if hostname == 'zamok':
|
||||||
print OK
|
print OK
|
||||||
except Exception, c:
|
except Exception, c:
|
||||||
print ERREUR
|
print ERREUR
|
||||||
if auto : db.services_to_restart('mail_bienvenue',[mail])
|
if auto : db.services_to_restart('mail_bienvenue',[mail])
|
||||||
if debug :
|
if debug :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if 'ML-ENS' in to_do.keys() :
|
if 'ML-ENS' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-ML-ENS')
|
if auto : db.services_to_restart('-ML-ENS')
|
||||||
cprint('Inscription ML-ENS','gras')
|
cprint('Inscription ML-ENS','gras')
|
||||||
|
@ -239,27 +239,27 @@ if hostname == 'zamok':
|
||||||
if 'droits' in to_do.keys() :
|
if 'droits' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-droits')
|
if auto : db.services_to_restart('-droits')
|
||||||
db.services_to_restart('droits-nectaris')
|
db.services_to_restart('droits-nectaris')
|
||||||
try:
|
try:
|
||||||
from gen_confs.droits import droits
|
from gen_confs.droits import droits
|
||||||
a = droits()
|
a = droits()
|
||||||
a.uids = to_do['droits']
|
a.uids = to_do['droits']
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('droits',to_do['droits'])
|
if auto : db.services_to_restart('droits',to_do['droits'])
|
||||||
|
|
||||||
if 'blacklist_upload' in to_do.keys() :
|
if 'blacklist_upload' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-blacklist_upload')
|
if auto : db.services_to_restart('-blacklist_upload')
|
||||||
db.services_to_restart('bl_squid_upload')
|
db.services_to_restart('bl_squid_upload')
|
||||||
db.services_to_restart('firewall-komaz-blacklist')
|
db.services_to_restart('firewall-komaz-blacklist')
|
||||||
try:
|
try:
|
||||||
from gen_confs.firewall import bl_upload_fw
|
from gen_confs.firewall import bl_upload_fw
|
||||||
a = bl_upload_fw()
|
a = bl_upload_fw()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('blacklist_upload')
|
if auto: db.services_to_restart('blacklist_upload')
|
||||||
|
|
||||||
if 'switch' in to_do.keys() :
|
if 'switch' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-switch')
|
if auto : db.services_to_restart('-switch')
|
||||||
try:
|
try:
|
||||||
|
@ -268,44 +268,44 @@ if hostname == 'zamok':
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('switch',to_do['switch'])
|
if auto : db.services_to_restart('switch',to_do['switch'])
|
||||||
sys.stdout.write('Erreur dans la config des switchs.\n')
|
sys.stdout.write('Erreur dans la config des switchs.\n')
|
||||||
if debug :
|
if debug :
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
|
|
||||||
if 'mail_modification_machine' in to_do.keys() :
|
if 'mail_modification_machine' in to_do.keys() :
|
||||||
|
|
||||||
cprint('Modification d\'une machine : envoi d\'un mail à roots@crans.org','gras')
|
cprint('Modification d\'une machine : envoi d\'un mail à roots@crans.org','gras')
|
||||||
|
|
||||||
try :
|
try :
|
||||||
from mail import mail_details
|
from mail import mail_details
|
||||||
|
|
||||||
# liste des machines
|
# liste des machines
|
||||||
machines = []
|
machines = []
|
||||||
for ip in to_do['mail_modification_machine'] :
|
for ip in to_do['mail_modification_machine'] :
|
||||||
anim('\t' + ip)
|
anim('\t' + ip)
|
||||||
print OK
|
print OK
|
||||||
machines += db.search('ipHostNumber=%s' % ip)['machine']
|
machines += db.search('ipHostNumber=%s' % ip)['machine']
|
||||||
|
|
||||||
# envoi du mail
|
# envoi du mail
|
||||||
mail_details(machines, Subject = 'Modification d\'une machine de l\'association')
|
mail_details(machines, Subject = 'Modification d\'une machine de l\'association')
|
||||||
|
|
||||||
if auto : db.services_to_restart('-mail_modification_machine')
|
if auto : db.services_to_restart('-mail_modification_machine')
|
||||||
print OK
|
print OK
|
||||||
|
|
||||||
except :
|
except :
|
||||||
print ERREUR
|
print ERREUR
|
||||||
|
|
||||||
if 'autostatus' in to_do.keys() :
|
if 'autostatus' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-autostatus')
|
if auto : db.services_to_restart('-autostatus')
|
||||||
try:
|
try:
|
||||||
from autostatus import autostatus
|
from autostatus import autostatus
|
||||||
a = autostatus()
|
a = autostatus()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('autostatus')
|
if auto : db.services_to_restart('autostatus')
|
||||||
|
|
||||||
# Les services suivants ont besoin de la liste des machines
|
# Les services suivants ont besoin de la liste des machines
|
||||||
# On va donc la lire une seule fois pour leur passer ensuite
|
# On va donc la lire une seule fois pour leur passer ensuite
|
||||||
|
@ -346,7 +346,7 @@ elif hostname == 'nectaris':
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('conf_wifi')
|
if auto : db.services_to_restart('conf_wifi')
|
||||||
sys.stdout.write('Erreur dans la config du wifi.\n')
|
sys.stdout.write('Erreur dans la config du wifi.\n')
|
||||||
|
|
||||||
if 'dhcp-nectaris' in to_do.keys() :
|
if 'dhcp-nectaris' in to_do.keys() :
|
||||||
from gen_confs.dhcpd import dhcp
|
from gen_confs.dhcpd import dhcp
|
||||||
inst.append([dhcp(),"dhcp-nectaris"])
|
inst.append([dhcp(),"dhcp-nectaris"])
|
||||||
|
@ -365,7 +365,7 @@ elif hostname == 'nectaris':
|
||||||
# Pas terrible : on va redemarrer les bornes qui ont redemarré correctement
|
# Pas terrible : on va redemarrer les bornes qui ont redemarré correctement
|
||||||
if auto : db.services_to_restart('bornes_wifi', to_do['bornes_wifi'])
|
if auto : db.services_to_restart('bornes_wifi', to_do['bornes_wifi'])
|
||||||
sys.stdout.write('Erreur dans la config des bornes wifi.\n')
|
sys.stdout.write('Erreur dans la config des bornes wifi.\n')
|
||||||
|
|
||||||
if 'droits-nectaris' in to_do.keys():
|
if 'droits-nectaris' in to_do.keys():
|
||||||
if auto : db.services_to_restart('-droits-nectaris')
|
if auto : db.services_to_restart('-droits-nectaris')
|
||||||
try:
|
try:
|
||||||
|
@ -375,97 +375,97 @@ elif hostname == 'nectaris':
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto : db.services_to_restart('droits-nectaris')
|
if auto : db.services_to_restart('droits-nectaris')
|
||||||
sys.stdout.write('Erreur dans la config des droits sur nectaris.\n')
|
sys.stdout.write('Erreur dans la config des droits sur nectaris.\n')
|
||||||
|
|
||||||
if restart_wifi_update:
|
if restart_wifi_update:
|
||||||
os.system("cd / ; systrace -d /etc/systrace/wifi-update -A /usr/local/bin/twistd --syslog -o -y /usr/scripts/gestion/wifi-update.py --pidfile=/var/run/wifi-update.pid")
|
os.system("cd / ; systrace -d /etc/systrace/wifi-update -A /usr/local/bin/twistd --syslog -o -y /usr/scripts/gestion/wifi-update.py --pidfile=/var/run/wifi-update.pid")
|
||||||
|
|
||||||
elif hostname == 'sila' :
|
elif hostname == 'sila' :
|
||||||
if 'bl_carte_etudiant' in to_do.keys() :
|
if 'bl_carte_etudiant' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-bl_carte_etudiant')
|
if auto : db.services_to_restart('-bl_carte_etudiant')
|
||||||
try:
|
try:
|
||||||
from gen_confs.squid import squid_carte
|
from gen_confs.squid import squid_carte
|
||||||
a = squid_carte()
|
a = squid_carte()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('bl_carte_etudiant')
|
if auto: db.services_to_restart('bl_carte_etudiant')
|
||||||
|
|
||||||
if 'blacklist_virus' in to_do.keys() :
|
if 'blacklist_virus' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-blacklist_virus')
|
if auto : db.services_to_restart('-blacklist_virus')
|
||||||
try:
|
try:
|
||||||
from gen_confs.squid import squid_virus
|
from gen_confs.squid import squid_virus
|
||||||
a = squid_virus()
|
a = squid_virus()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('blacklist_virus')
|
if auto: db.services_to_restart('blacklist_virus')
|
||||||
|
|
||||||
if 'blacklist_warez' in to_do.keys() :
|
if 'blacklist_warez' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-blacklist_warez')
|
if auto : db.services_to_restart('-blacklist_warez')
|
||||||
try:
|
try:
|
||||||
from gen_confs.squid import squid_warez
|
from gen_confs.squid import squid_warez
|
||||||
a = squid_warez()
|
a = squid_warez()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('blacklist_warez')
|
if auto: db.services_to_restart('blacklist_warez')
|
||||||
|
|
||||||
if 'bl_squid_upload' in to_do.keys() :
|
if 'bl_squid_upload' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-bl_squid_upload')
|
if auto : db.services_to_restart('-bl_squid_upload')
|
||||||
try:
|
try:
|
||||||
from gen_confs.squid import squid_upload
|
from gen_confs.squid import squid_upload
|
||||||
a = squid_upload()
|
a = squid_upload()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('bl_squid_upload')
|
if auto: db.services_to_restart('bl_squid_upload')
|
||||||
|
|
||||||
if 'bl_chbre_invalide' in to_do.keys() :
|
if 'bl_chbre_invalide' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-bl_chbre_invalide')
|
if auto : db.services_to_restart('-bl_chbre_invalide')
|
||||||
try:
|
try:
|
||||||
from gen_confs.squid import squid_chbre
|
from gen_confs.squid import squid_chbre
|
||||||
a = squid_chbre()
|
a = squid_chbre()
|
||||||
a.debug = debug
|
a.debug = debug
|
||||||
a.reconfigure()
|
a.reconfigure()
|
||||||
except:
|
except:
|
||||||
if auto: db.services_to_restart('bl_chbre_invalide')
|
if auto: db.services_to_restart('bl_chbre_invalide')
|
||||||
|
|
||||||
elif hostname == 'komaz' :
|
elif hostname == 'komaz' :
|
||||||
if 'firewall-komaz' in to_do.keys() or \
|
if 'firewall-komaz' in to_do.keys() or \
|
||||||
'firewall-komaz-ports' in to_do.keys() or \
|
'firewall-komaz-ports' in to_do.keys() or \
|
||||||
'firewall-komaz-blacklist' in to_do.keys() :
|
'firewall-komaz-blacklist' in to_do.keys() :
|
||||||
from firewall_komaz import firewall_komaz
|
from firewall_komaz import firewall_komaz
|
||||||
fw = firewall_komaz()
|
fw = firewall_komaz()
|
||||||
fw.debug = debug
|
fw.debug = debug
|
||||||
|
|
||||||
cprint('Reconfiguration firewall','gras')
|
cprint('Reconfiguration firewall','gras')
|
||||||
if 'firewall-komaz' in to_do.keys() :
|
if 'firewall-komaz' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-firewall-komaz')
|
if auto : db.services_to_restart('-firewall-komaz')
|
||||||
try :
|
try :
|
||||||
fw.mac_ip_maj(to_do['firewall-komaz'])
|
fw.mac_ip_maj(to_do['firewall-komaz'])
|
||||||
except :
|
except :
|
||||||
if auto : db.services_to_restart('firewall-komaz',to_do['firewall-komaz'])
|
if auto : db.services_to_restart('firewall-komaz',to_do['firewall-komaz'])
|
||||||
|
|
||||||
if 'firewall-komaz-ports' in to_do.keys() :
|
if 'firewall-komaz-ports' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-firewall-komaz-ports')
|
if auto : db.services_to_restart('-firewall-komaz-ports')
|
||||||
try :
|
try :
|
||||||
fw.port_maj(to_do['firewall-komaz-ports'])
|
fw.port_maj(to_do['firewall-komaz-ports'])
|
||||||
except :
|
except :
|
||||||
if auto : db.services_to_restart('firewall-komaz-ports',to_do['firewall-komaz-ports'])
|
if auto : db.services_to_restart('firewall-komaz-ports',to_do['firewall-komaz-ports'])
|
||||||
|
|
||||||
if 'firewall-komaz-blacklist' in to_do.keys() :
|
if 'firewall-komaz-blacklist' in to_do.keys() :
|
||||||
if auto : db.services_to_restart('-firewall-komaz-blacklist')
|
if auto : db.services_to_restart('-firewall-komaz-blacklist')
|
||||||
try :
|
try :
|
||||||
fw.blacklist()
|
fw.blacklist()
|
||||||
except :
|
except :
|
||||||
if auto : db.services_to_restart('firewall-komaz-blacklist',to_do['firewall-komaz-blacklist'])
|
if auto : db.services_to_restart('firewall-komaz-blacklist',to_do['firewall-komaz-blacklist'])
|
||||||
|
|
||||||
# On indique que les services seront a priori redemarrés
|
# On indique que les services seront a priori redemarrés
|
||||||
if auto :
|
if auto :
|
||||||
for i in inst:
|
for i in inst:
|
||||||
db.services_to_restart("-%s" % i[1])
|
db.services_to_restart("-%s" % i[1])
|
||||||
## On fait ce qu'il reste à faire
|
## On fait ce qu'il reste à faire
|
||||||
|
|
||||||
if inst :
|
if inst :
|
||||||
# Récolte des données
|
# Récolte des données
|
||||||
|
@ -498,8 +498,8 @@ if inst :
|
||||||
except :
|
except :
|
||||||
# Erreur, il faudra relancer le service la prochaine fois
|
# Erreur, il faudra relancer le service la prochaine fois
|
||||||
if auto : db.services_to_restart('%s' % i[1])
|
if auto : db.services_to_restart('%s' % i[1])
|
||||||
sys.stdout.write('Erreur dans la config de %s.\n' % i[1])
|
sys.stdout.write('Erreur dans la config de %s.\n' % i[1])
|
||||||
|
|
||||||
if debug :
|
if debug :
|
||||||
print 'Non traité ici mais signalé dans la base LDAP : \n\t', db.services_to_restart()
|
print 'Non traité ici mais signalé dans la base LDAP : \n\t', db.services_to_restart()
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ def mail_details (Objets, Subject = "Modifications dans la base LDAP", To = ['ro
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not len(Objets) :
|
if not len(Objets) :
|
||||||
return True
|
return True
|
||||||
|
|
||||||
base_txt_mail = """From: %(From)s
|
base_txt_mail = """From: %(From)s
|
||||||
To: %(To)s
|
To: %(To)s
|
||||||
|
@ -31,20 +31,20 @@ Subject: %(Subject)s
|
||||||
details = []
|
details = []
|
||||||
|
|
||||||
for i in Objets :
|
for i in Objets :
|
||||||
if i.__class__ == machine :
|
if i.__class__ == machine :
|
||||||
details.append(machine_details(i))
|
details.append(machine_details(i))
|
||||||
elif i.__class__ == adherent :
|
elif i.__class__ == adherent :
|
||||||
details.append(adher_details(i))
|
details.append(adher_details(i))
|
||||||
elif i.__class__ == club :
|
elif i.__class__ == club :
|
||||||
details.append(club_details(i))
|
details.append(club_details(i))
|
||||||
else :
|
else :
|
||||||
ok = False
|
ok = False
|
||||||
|
|
||||||
texte = '\n\n- - - - = = = = # # # # # # = = = = - - - -\n\n'.join(details)
|
texte = '\n\n- - - - = = = = # # # # # # = = = = - - - -\n\n'.join(details)
|
||||||
|
|
||||||
if no_ascii :
|
if no_ascii :
|
||||||
import sre
|
import sre
|
||||||
texte = sre.sub('\x1b\[1;([0-9]|[0-9][0-9])m','',texte)
|
texte = sre.sub('\x1b\[1;([0-9]|[0-9][0-9])m','',texte)
|
||||||
|
|
||||||
mail_complet = base_txt_mail % { 'From' : From, 'To' : ','.join(To), 'Subject' : Subject, 'Text' : texte.encode('iso8859-15') }
|
mail_complet = base_txt_mail % { 'From' : From, 'To' : ','.join(To), 'Subject' : Subject, 'Text' : texte.encode('iso8859-15') }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue