Skip to content

Commit 3ee6789

Browse files
author
Marius Burkard
committed
- add support for remote backup utils check
1 parent f0f5884 commit 3ee6789

File tree

2 files changed

+152
-17
lines changed

2 files changed

+152
-17
lines changed

interface/web/sites/form/web_vhost_domain.tform.php

Lines changed: 42 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -640,24 +640,49 @@
640640

641641
//* Backup
642642
if ($backup_available) {
643+
644+
$domain_server_id = null;
645+
if(isset($_REQUEST["id"])) {
646+
$domain_id = $app->functions->intval($_REQUEST["id"]);
647+
if($domain_id) {
648+
$domain_data = $app->db->queryOneRecord('SELECT `server_id` FROM `web_domain` WHERE `domain_id` = ?', $domain_id);
649+
if($domain_data) {
650+
$domain_server_id = $domain_data['server_id'];
651+
}
652+
}
653+
}
654+
if(!$domain_server_id) {
655+
$domain_server_id = $conf['server_id'];
656+
}
657+
643658
$missing_utils = array();
644-
$compressors_list = array(
645-
'gzip',
646-
'gunzip',
647-
'zip',
648-
'unzip',
649-
'pigz',
650-
'tar',
651-
'bzip2',
652-
'bunzip2',
653-
'xz',
654-
'unxz',
655-
'7z',
656-
'rar',
657-
);
658-
foreach ($compressors_list as $compressor) {
659-
if (!$app->system->is_installed($compressor)) {
660-
array_push($missing_utils, $compressor);
659+
if($domain_server_id != $conf['server_id']) {
660+
$mon = $app->db->queryOneRecord('SELECT `data` FROM `monitor_data` WHERE `server_id` = ? AND `type` = ? ORDER BY `created` DESC', $domain_server_id, 'backup_utils');
661+
if($mon) {
662+
$missing_utils = unserialize($mon['data']);
663+
if(!$missing_utils) {
664+
$missing_utils = array();
665+
}
666+
}
667+
} else {
668+
$compressors_list = array(
669+
'gzip',
670+
'gunzip',
671+
'zip',
672+
'unzip',
673+
'pigz',
674+
'tar',
675+
'bzip2',
676+
'bunzip2',
677+
'xz',
678+
'unxz',
679+
'7z',
680+
'rar',
681+
);
682+
foreach ($compressors_list as $compressor) {
683+
if (!$app->system->is_installed($compressor)) {
684+
array_push($missing_utils, $compressor);
685+
}
661686
}
662687
}
663688
$app->tpl->setVar("missing_utils", implode(", ",$missing_utils), true);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
<?php
2+
3+
/*
4+
Copyright (c) 2013, Marius Cramer, pixcept KG
5+
All rights reserved.
6+
7+
Redistribution and use in source and binary forms, with or without modification,
8+
are permitted provided that the following conditions are met:
9+
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
18+
19+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
22+
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
23+
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
26+
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
28+
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29+
*/
30+
31+
class cronjob_monitor_backup extends cronjob {
32+
33+
// job schedule
34+
protected $_schedule = '*/5 * * * *';
35+
protected $_run_at_new = true;
36+
37+
private $_tools = null;
38+
39+
/* this function is optional if it contains no custom code */
40+
public function onPrepare() {
41+
parent::onPrepare();
42+
}
43+
44+
/* this function is optional if it contains no custom code */
45+
public function onBeforeRun() {
46+
return parent::onBeforeRun();
47+
}
48+
49+
public function onRunJob() {
50+
global $app, $conf;
51+
52+
/* used for all monitor cronjobs */
53+
$app->load('monitor_tools');
54+
$this->_tools = new monitor_tools();
55+
/* end global section for monitor cronjobs */
56+
57+
/* the id of the server as int */
58+
$server_id = intval($conf['server_id']);
59+
60+
/** The type of the data */
61+
62+
63+
$type = 'backup_utils';
64+
65+
$missing_utils = array();
66+
$compressors_list = array(
67+
'gzip',
68+
'gunzip',
69+
'zip',
70+
'unzip',
71+
'pigz',
72+
'tar',
73+
'bzip2',
74+
'bunzip2',
75+
'xz',
76+
'unxz',
77+
'7z',
78+
'rar',
79+
);
80+
foreach ($compressors_list as $compressor) {
81+
if (!$app->system->is_installed($compressor)) {
82+
$missing_utils[] = $compressor;
83+
}
84+
}
85+
86+
$res = array();
87+
$res['server_id'] = $server_id;
88+
$res['type'] = $type;
89+
$res['data'] = array('missing_utils' => $missing_utils);
90+
$res['state'] = 'ok';
91+
92+
/*
93+
* Insert the data into the database
94+
*/
95+
$sql = 'REPLACE INTO monitor_data (server_id, type, created, data, state) ' .
96+
'VALUES (?, ?, UNIX_TIMESTAMP(), ?, ?)';
97+
$app->dbmaster->query($sql, $res['server_id'], $res['type'], serialize($res['data']), $res['state']);
98+
99+
/* The new data is written, now we can delete the old one */
100+
$this->_tools->delOldRecords($res['type'], $res['server_id']);
101+
102+
parent::onRunJob();
103+
}
104+
105+
/* this function is optional if it contains no custom code */
106+
public function onAfterRun() {
107+
parent::onAfterRun();
108+
}
109+
110+
}

0 commit comments

Comments
 (0)