mtes-scripts/scripts/module/del_zephir.zephir

57 lines
1.7 KiB
Python

#!/usr/bin/env python
# -*- coding: utf-8 -*-
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:
from zephir.zephir_conf import zephir_conf
except:
zephir_conf = None
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:
print("\n !! le fichier %s/zephir_conf/zephir_conf.py n'a pas pu être supprimé !!\n" % zephir_path)
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)