Compare commits

...

2 Commits

Author SHA1 Message Date
3ae1d9f4a6 change interface and ip back to example 2021-12-04 15:40:08 -05:00
f5bdef057c add code to sync the backup 2021-12-04 15:38:02 -05:00

View File

@@ -9,6 +9,7 @@ require_once("util.inc");
require_once("system.inc");
require_once('rrd.inc');
require_once('plugins.inc.d/webgui.inc');
require_once("XMLRPC_Client.inc");
/*
@@ -26,9 +27,9 @@ require_once('plugins.inc.d/webgui.inc');
#############
# Master Node/Router
$wanInterface = 'opt1';
$wanInterface = 'wan';
$gatewayName = 'WAN_GW';
$wanStaticIP = '10.0.12.5';
$wanStaticIP = '192.168.255.1';
$wanStaticIPSubnet = '30';
###################
@@ -101,6 +102,44 @@ function get_specialnets($only_enabled = false) {
return $specialnets;
}
function xmlrpc_exec($method, $params = [], $debug = false) {
global $config;
$synchronizeto = null;
$hasync = $config['hasync'];
if (is_ipaddrv6($hasync['synchronizetoip'])) {
$hasync['synchronizetoip'] = "[{$hasync['synchronizetoip']}]";
}
if (!empty($hasync['synchronizetoip'])) {
// determine target url
if (substr($hasync['synchronizetoip'],0, 4) == 'http') {
// URL provided
if (substr($hasync['synchronizetoip'], strlen($hasync['synchronizetoip'])-1, 1) == '/') {
$synchronizeto = $hasync['synchronizetoip']."xmlrpc.php";
} else {
$synchronizeto = $hasync['synchronizetoip']."/xmlrpc.php";
}
} elseif (!empty($config['system']['webgui']['protocol'])) {
// no url provided, assume the backup is using the same settings as our box.
$port = $config['system']['webgui']['port'];
if (!empty($port)) {
$synchronizeto = $config['system']['webgui']['protocol'] . '://'.$hasync['synchronizetoip'].':'.$port."/xmlrpc.php";
} else {
$synchronizeto = $config['system']['webgui']['protocol'] . '://'.$hasync['synchronizetoip']."/xmlrpc.php" ;
}
}
$username = empty($hasync['username']) ? "root" : $hasync['username'];
$client = new SimpleXMLRPC_Client($synchronizeto,240);
$client->debug=$debug;
$client->setCredentials($username, $hasync['password']);
if ($client->query($method, $params)) {
return $client->getResponse();
}
}
return false;
}
echo_write_log("Start of Script " . $argv[0]);
@@ -290,8 +329,9 @@ if (filter_var($config['hasync']['synchronizetoip'], FILTER_VALIDATE_IP)) {
}
} while (true);
exec('configctl system ha_reconfigure_backup', $output, $result);
configd_run('filter sync');
xmlrpc_exec('opnsense.configd_reload_all_templates');
echo_write_log("CARP Sync Status: " . $output);
echo_write_log("finished the CARP Sync");
} else {