From ae62a7f13d142e48e4a0b9e63c7aa398590e1abc Mon Sep 17 00:00:00 2001 From: bernat Date: Thu, 2 Sep 2004 08:32:57 +0200 Subject: [PATCH] On indique que les services n'ont plus tre relancs uniquement si tout s'est bien pass (Fred boulet) darcs-hash:20040902063257-d1718-1481891b941270c5e9b0175cd9fe713f6a17eaf2.gz --- gestion/gen_confs/generate.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gestion/gen_confs/generate.py b/gestion/gen_confs/generate.py index f04e0c81..af318c4d 100755 --- a/gestion/gen_confs/generate.py +++ b/gestion/gen_confs/generate.py @@ -11,6 +11,11 @@ from affich_tools import anim, cprint, OK, ERREUR, WARNING from time import localtime import config +# On vérifie que l'on es root +if os.getuid() != 0: + sys.stderr.write("Il faut être root\n") + sys.exit(1) + signal.signal(signal.SIGINT,signal.SIG_IGN) # Pas de Ctrl-C db = crans_ldap() @@ -46,7 +51,6 @@ else : inst = [] if 'home' in to_do.keys() : - if auto : db.services_to_restart('-home') cprint('Création home','gras') for args in to_do['home'] : anim('\t' + args) @@ -63,6 +67,7 @@ if 'home' in to_do.keys() : sys.stderr.write(output+'\n') else : print OK + if auto : db.services_to_restart('-home') except : print ERREUR if debug : @@ -70,7 +75,6 @@ if 'home' in to_do.keys() : traceback.print_exc() if 'ML-ENS' in to_do.keys() : - db.services_to_restart('-ML-ENS') cprint('Inscription ML-ENS','gras') for mail in to_do['ML-ENS'] : anim('\t'+mail) @@ -82,20 +86,21 @@ if 'ML-ENS' in to_do.keys() : sys.stderr.write(output+'\n') else : print OK + db.services_to_restart('-ML-ENS') if 'droits' in to_do.keys() : - db.services_to_restart('-droits') from gen_confs.droits import droits a = droits() a.debug = debug a.reconfigure() + db.services_to_restart('-droits') if 'switch' in to_do.keys() : - if auto : db.services_to_restart('-switch') from gen_confs.switchs import switch a = switch(to_do['switch']) a.debug = debug a.reconfigure() + if auto : db.services_to_restart('-switch') # Les services suivants ont besoin de la liste des machines # On va donc la lire une seule fois pour leur passer ensuite @@ -104,9 +109,9 @@ if 'firewall' in to_do.keys() : # Quand sila et komaz liront la base LDAP # db.services_to_restart('firewall-komaz') # db.services_to_restart('firewall-sila') - db.services_to_restart('-firewall') from gen_confs.firewall import firewall inst.append(firewall()) + db.services_to_restart('-firewall') if 'dns' in to_do.keys() : db.services_to_restart('-dns') @@ -115,8 +120,8 @@ if 'dns' in to_do.keys() : if 'dhcp' in to_do.keys() : from gen_confs.dhcpd import dhcp - db.services_to_restart('-dhcp') inst.append(dhcp()) + db.services_to_restart('-dhcp') ##### On fait ce qu'il reste à faire