update change_domain
This commit is contained in:
parent
27bdbf5e4f
commit
401a4f9ef4
@ -10,38 +10,34 @@ from collections import OrderedDict
|
|||||||
|
|
||||||
def display_help():
|
def display_help():
|
||||||
print("Modification de la valeur d'une variable d'un serveur")
|
print("Modification de la valeur d'une variable d'un serveur")
|
||||||
print("{} [--r realm --d domain --save]".format(sys.argv[0]))
|
print("{} [--d domain --integration --save]".format(sys.argv[0]))
|
||||||
|
|
||||||
|
|
||||||
def argparser():
|
def argparser():
|
||||||
# récupère l'ID du groupe
|
# récupère l'ID du groupe
|
||||||
arglen = len(sys.argv)
|
arglen = len(sys.argv)
|
||||||
save = False
|
save = None
|
||||||
|
integration = None
|
||||||
if "--save" in sys.argv:
|
if "--save" in sys.argv:
|
||||||
save = True
|
save = True
|
||||||
|
if "--integration" in sys.argv:
|
||||||
|
integration = True
|
||||||
if arglen == 1:
|
if arglen == 1:
|
||||||
return None, None, save
|
return None, save
|
||||||
if sys.argv[1] in ['-h', '--help']:
|
if sys.argv[1] in ['-h', '--help']:
|
||||||
display_help()
|
display_help()
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
if sys.argv[1] in ['-r', '--realm']:
|
if sys.argv[1] in ['-d', '--domain']:
|
||||||
realm = sys.argv[2]
|
domain = sys.argv[2]
|
||||||
return realm, None, save
|
return domain, save, integration
|
||||||
|
|
||||||
if sys.argv[3] in ['-d', '--domain']:
|
return None, save, integration
|
||||||
domain = sys.argv[4]
|
|
||||||
return realm, domain, save
|
|
||||||
|
|
||||||
return None, None, save
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# import des fonctions communes de Zéphir client
|
# import des fonctions communes de Zéphir client
|
||||||
realm, domain, save = argparser()
|
domain, save, integration = argparser()
|
||||||
|
|
||||||
if realm is None :
|
|
||||||
realm = raw_input("Realm AD : ")
|
|
||||||
|
|
||||||
if domain is None :
|
if domain is None :
|
||||||
domain = raw_input("Domaine AD : ")
|
domain = raw_input("Domaine AD : ")
|
||||||
@ -49,10 +45,8 @@ def main():
|
|||||||
fh = open("/etc/eole/config.eol", 'r')
|
fh = open("/etc/eole/config.eol", 'r')
|
||||||
store = cjson.decode(fh.read(), all_unicode=True)
|
store = cjson.decode(fh.read(), all_unicode=True)
|
||||||
fh.close
|
fh.close
|
||||||
if "ad_realm" in store:
|
if "nom_domaine_local" in store:
|
||||||
store["ad_realm"]['val'] = realm
|
store["nom_domaine_local"]['val'] = domain
|
||||||
if "ad_domain" in store:
|
|
||||||
store["ad_domain"]['val'] = domain
|
|
||||||
|
|
||||||
fh = open("/etc/eole/config.eol", 'w')
|
fh = open("/etc/eole/config.eol", 'w')
|
||||||
fh.write(cjson.encode(store))
|
fh.write(cjson.encode(store))
|
||||||
@ -63,10 +57,25 @@ def main():
|
|||||||
res = output.read().strip()
|
res = output.read().strip()
|
||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
cmd="""/usr/share/eole/postservice/25-manage-samba instance"""
|
if not integration :
|
||||||
output = os.popen(cmd)
|
to_integrate = raw_input("Souhaitez vous intégrer le serveur au domaine ad ? (O/N) ")
|
||||||
res = output.read().strip()
|
if to_integrate == "O":
|
||||||
output.close()
|
integration = True
|
||||||
|
|
||||||
|
if integration:
|
||||||
|
cmd="""rm -f /var/lib/samba/.instance_ok; rm -f *.tdb"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
res = output.read().strip()
|
||||||
|
output.close()
|
||||||
|
cmd="""/usr/share/eole/postservice/25-manage-samba instance"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
res = output.read().strip()
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
if not save :
|
||||||
|
to_save = raw_input("Souhaitez vous sauvegarder la configuration sur Zephir ? (O/N) ")
|
||||||
|
if to_save == "O":
|
||||||
|
save = True
|
||||||
if save:
|
if save:
|
||||||
cmd="""/usr/share/zephir/scripts/zephir_client save_files"""
|
cmd="""/usr/share/zephir/scripts/zephir_client save_files"""
|
||||||
output = os.popen(cmd)
|
output = os.popen(cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user