2021-05-10 17:47:13 +02:00
|
|
|
#!/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")
|
2021-06-30 16:43:06 +02:00
|
|
|
print("{} [--r realm --d domain --save]".format(sys.argv[0]))
|
2021-05-10 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
def argparser():
|
|
|
|
# récupère l'ID du groupe
|
|
|
|
arglen = len(sys.argv)
|
2021-06-30 16:43:06 +02:00
|
|
|
save = False
|
|
|
|
if "--save" in sys.argv:
|
|
|
|
save = True
|
2021-05-10 17:47:13 +02:00
|
|
|
if arglen == 1:
|
2021-06-30 16:43:06 +02:00
|
|
|
return None, None, save
|
2021-05-10 17:47:13 +02:00
|
|
|
if sys.argv[1] in ['-h', '--help']:
|
|
|
|
display_help()
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
if sys.argv[1] in ['-r', '--realm']:
|
|
|
|
realm = sys.argv[2]
|
2021-06-30 16:43:06 +02:00
|
|
|
return realm, None, save
|
2021-05-10 17:47:13 +02:00
|
|
|
|
|
|
|
if sys.argv[3] in ['-d', '--domain']:
|
|
|
|
domain = sys.argv[4]
|
2021-06-30 16:43:06 +02:00
|
|
|
return realm, domain, save
|
2021-05-10 17:47:13 +02:00
|
|
|
|
2021-06-30 16:43:06 +02:00
|
|
|
return None, None, save
|
2021-05-10 17:47:13 +02:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
# import des fonctions communes de Zéphir client
|
2021-06-30 16:43:06 +02:00
|
|
|
realm, domain, save = argparser()
|
2021-05-10 17:47:13 +02:00
|
|
|
|
|
|
|
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()
|
|
|
|
|
2021-06-30 15:13:29 +02:00
|
|
|
cmd="""CreoleCat -t samba4-vars.conf"""
|
2021-05-10 17:47:13 +02:00
|
|
|
output = os.popen(cmd)
|
|
|
|
res = output.read().strip()
|
|
|
|
output.close()
|
|
|
|
|
2021-06-30 15:13:29 +02:00
|
|
|
cmd="""/usr/share/eole/postservice/25-manage-samba instance"""
|
2021-05-10 17:47:13 +02:00
|
|
|
output = os.popen(cmd)
|
|
|
|
res = output.read().strip()
|
|
|
|
output.close()
|
2021-06-30 16:43:06 +02:00
|
|
|
if save:
|
|
|
|
cmd="""/usr/share/zephir/scripts/zephir_client save_files"""
|
|
|
|
output = os.popen(cmd)
|
|
|
|
output.close()
|
2021-05-10 17:47:13 +02:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|