jabber.py
1 |
#!/usr/bin/env python
|
---|---|
2 |
"""Module jabber"""
|
3 |
from pyeole.process import system_code |
4 |
from pyeole.service import service_out |
5 |
from pyeole.bacularestore import bacula_restore_one_file, exit_if_running_jobs |
6 |
from shutil import copyfile |
7 |
from creole.eosfunc import load_container_var |
8 |
|
9 |
jabfile = '/home/backup/ejabberd'
|
10 |
|
11 |
def execute(option, opt_str, value, parser, jobid, test_jobs=True): |
12 |
"""jabber helper"""
|
13 |
if len(parser.rargs) > 0: |
14 |
option = parser.rargs[0]
|
15 |
if option == 'pre': |
16 |
pre() |
17 |
elif option == 'post': |
18 |
post() |
19 |
else:
|
20 |
if test_jobs:
|
21 |
exit_if_running_jobs() |
22 |
job(jobid) |
23 |
|
24 |
def pre(): |
25 |
print "pre jabber" |
26 |
|
27 |
def post(): |
28 |
print "post jabber" |
29 |
container_conf = load_container_var() |
30 |
path = container_conf.get('container_path_jabber', '') |
31 |
destdir = path + '/tmp'
|
32 |
copyfile(jabfile, destdir + '/ejabberd')
|
33 |
system_code(["/bin/chown", "ejabberd", "/tmp/ejabberd"], container='jabber') |
34 |
system_code(["/usr/sbin/ejabberdctl", "install_fallback", "/tmp/ejabberd"], container='jabber') |
35 |
service_out('ejabberd', 'restart', 'jabber') |
36 |
|
37 |
def job(jobid): |
38 |
print "Restauration de la base ejabberd" |
39 |
bacula_restore_one_file(jabfile, jobid) |
40 |
|
41 |
priority=20
|