add change_domain
This commit is contained in:
parent
78e5ce410b
commit
873862424c
69
scripts/module/change_domain.py
Normal file
69
scripts/module/change_domain.py
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
|
import sys, getpass, socket, cjson, os
|
||||||
|
from pyeole.ihm import print_line
|
||||||
|
from pyeole.ansiprint import print_orange, print_red
|
||||||
|
from creole.client import CreoleClient
|
||||||
|
from collections import OrderedDict
|
||||||
|
|
||||||
|
|
||||||
|
def display_help():
|
||||||
|
print("Modification de la valeur d'une variable d'un serveur")
|
||||||
|
print("{} [--var nom_variable --value valeur]".format(sys.argv[0]))
|
||||||
|
|
||||||
|
|
||||||
|
def argparser():
|
||||||
|
# récupère l'ID du groupe
|
||||||
|
arglen = len(sys.argv)
|
||||||
|
if arglen == 1:
|
||||||
|
return None, None
|
||||||
|
if sys.argv[1] in ['-h', '--help']:
|
||||||
|
display_help()
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
if sys.argv[1] in ['-r', '--realm']:
|
||||||
|
realm = sys.argv[2]
|
||||||
|
return realm, None
|
||||||
|
|
||||||
|
if sys.argv[3] in ['-d', '--domain']:
|
||||||
|
domain = sys.argv[4]
|
||||||
|
return realm, domain
|
||||||
|
|
||||||
|
return None, None
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# import des fonctions communes de Zéphir client
|
||||||
|
realm, domain = argparser()
|
||||||
|
|
||||||
|
if realm is None :
|
||||||
|
realm = raw_input("Realm AD : ")
|
||||||
|
|
||||||
|
if domain is None :
|
||||||
|
domain = raw_input("Domaine AD : ")
|
||||||
|
|
||||||
|
fh = open("/etc/eole/config.eol", 'r')
|
||||||
|
store = cjson.decode(fh.read(), all_unicode=True)
|
||||||
|
fh.close
|
||||||
|
if "ad_realm" in store:
|
||||||
|
store["ad_realm"]['val'] = realm
|
||||||
|
if "ad_domain" in store:
|
||||||
|
store["ad_domain"]['val'] = domain
|
||||||
|
|
||||||
|
fh = open("/etc/eole/config.eol", 'w')
|
||||||
|
fh.write(cjson.encode(store))
|
||||||
|
fh.close()
|
||||||
|
|
||||||
|
cmd="""CreoleCat samba4-vars.conf"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
res = output.read().strip()
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
cmd="""/usr/share/eole/posttemplate/25-manage-samba instance"""
|
||||||
|
output = os.popen(cmd)
|
||||||
|
res = output.read().strip()
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
@ -69,10 +69,10 @@ def main():
|
|||||||
|
|
||||||
# enregistrement de la clef ssh
|
# enregistrement de la clef ssh
|
||||||
|
|
||||||
if res == 1:
|
if res == "UPDATE 1":
|
||||||
print("OK")
|
print("OK")
|
||||||
else:
|
else:
|
||||||
print("Erreur remontée par Zéphir : ", str(res))
|
print("Erreur : ", str(res))
|
||||||
|
|
||||||
def get_pwd(addr, port):
|
def get_pwd(addr, port):
|
||||||
"""lecture d'un login/passwd pour l'application zephir
|
"""lecture d'un login/passwd pour l'application zephir
|
||||||
|
Loading…
Reference in New Issue
Block a user