mtes-scripts/scripts/module/desenregistrement.zephir

57 lines
1.7 KiB
Plaintext
Raw Normal View History

2021-07-01 09:51:42 +02:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2021-05-11 09:38:10 +02:00
from zephir.lib_zephir import *
import os, shutil
from creole.config import eoledirs, distrib_dir, dicos_dir
from creole.client import CreoleClient, NotFoundError
from pyeole.service import manage_service, unmanaged_service
creole_client = CreoleClient()
try:
eole_module = creole_client.get_creole('eole_module')
eole_version = creole_client.get_creole('eole_release')
except Exception, exc:
print_red("\nErreur d'accès au service creoled :\n\n")
print str(exc)
exit(1)
stats_running = False
stats_service = u'z_stats'
if os.path.isfile('/var/run/z_stats.pid'):
stats_running = True
try:
2021-07-01 09:51:42 +02:00
from zephir.zephir_conf import zephir_conf
except:
zephir_conf = None
2021-05-11 09:38:10 +02:00
if stats_running:
manage_service(u'stop', stats_service)
if eole_module != 'zephir':
if zephir_conf is not None:
# agents de surveillance : on réinitialise le n° de l'agent à 0 pour les stats
# si il existe déjà
stats_dir = '%s/monitor/stats/' % zephir_dir
# ancien répertoire de stockage
old_id = str(zephir_conf.id_serveur)
if os.path.isdir(stats_dir + old_id):
shutil.move(stats_dir + old_id, stats_dir + '0')
try:
os.unlink("%s/zephir_conf/zephir_conf.py" % zephir_path)
except:
2021-07-01 09:51:42 +02:00
print("\n !! le fichier %s/zephir_conf/zephir_conf.py n'a pas pu être supprimé !!\n" % zephir_path)
2021-05-11 09:38:10 +02:00
try:
os.unlink("%s/zephir_conf/zephir_conf.pyc" % zephir_path)
try:
f=file("%s/deffered_logs" % zephir_dir, "w")
f.close()
shutil.rmtree("/var/spool/uucp/zephir")
except:
pass
except:
pass
if stats_running:
manage_service(u'start', stats_service)