sysutils/scp-backup: whitespace and style sweep

This commit is contained in:
Franco Fichtner
2018-01-04 08:35:06 +01:00
parent e59ee7067a
commit 5c671cd2f6
7 changed files with 10 additions and 15 deletions
+1 -1
View File
@@ -1 +1 @@
A simple plugin to perform config backups using SCP.
A simple plugin to perform config backups using SCP.
@@ -48,7 +48,7 @@ class GeneralController extends ApiMutableModelControllerBase
if ($this->request->isGet()) {
$mdlGeneral = $this->getModel();
$publicKey = fopen("/conf/sshd/ssh_host_rsa_key.pub", "r");
if($publicKey) {
if ($publicKey) {
$mdlGeneral->publickey = fread($publicKey, filesize("/conf/sshd/ssh_host_rsa_key.pub"));
fclose($publicKey);
}
@@ -70,11 +70,11 @@ class GeneralController extends ApiMutableModelControllerBase
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validation", $result)) {
$result["validations"] = array();
}
}
$result["validations"][$msg->getField()] = $msg->getMessage();
}
if($valMsgs->count() == 0) {
if($mdlGeneral->cronuuid->__toString() == "" and $mdlGeneral->enabled->__toString() == "1") {
if ($valMsgs->count() == 0) {
if ($mdlGeneral->cronuuid->__toString() == "" and $mdlGeneral->enabled->__toString() == "1") {
// First Time Save
$cronUuid = $mdlCron->newDailyJob("ScpBackup", "scpbackup perform", "Backup config using SCP", "*", "1");
if ($mdlCron->performValidation()->count() == 0) {
@@ -89,7 +89,7 @@ class GeneralController extends ApiMutableModelControllerBase
} elseif ($mdlGeneral->cronuuid->__toString() != "" and $mdlGeneral->enabled->__toString() == "0") {
// Removal of Cron Job and deactivation of the backup
$cronUuid = $mdlGeneral->cronuuid->__toString();
if($mdlCron->jobs->job->del($cronUuid)) {
if ($mdlCron->jobs->job->del($cronUuid)) {
$mdlCron->serializeToConfig();
$mdlGeneral->cronuuid = null;
$mdlGeneral->serializeToConfig($validateFullModel = false, $disable_validation = true);
@@ -109,5 +109,4 @@ class GeneralController extends ApiMutableModelControllerBase
}
return $result;
}
}
@@ -39,4 +39,3 @@ class GeneralController extends \OPNsense\Base\IndexController
$this->view->generalForm = $this->getForm("general");
}
}
@@ -37,4 +37,3 @@ class General extends BaseModel
{
}
@@ -41,4 +41,3 @@
</cronuuid>
</items>
</model>
@@ -5,4 +5,3 @@
</Configuration>
</System>
</menu>
@@ -36,10 +36,10 @@ require_once("config.inc");
use OPNsense\Base;
use OPNsense\Core\Config;
$config = Config::getInstance()->object();
$config = Config::getInstance()->object();
$scpBackup = $config->OPNsense->ScpBackup;
if(isset($scpBackup) && isset($scpBackup->enabled) && $scpBackup->enabled == 1) {
if (isset($scpBackup) && isset($scpBackup->enabled) && $scpBackup->enabled == 1) {
$hostname = escapeshellarg($scpBackup->hostname);
$username = escapeshellarg($scpBackup->username);
$port = $scpBackup->port;
@@ -47,7 +47,7 @@ if(isset($scpBackup) && isset($scpBackup->enabled) && $scpBackup->enabled == 1)
$identifyFile = "/conf/sshd/ssh_host_rsa_key";
$configFile = "/conf/config.xml";
if(!substr($remoteDirectory, -1) == "/") {
if (!substr($remoteDirectory, -1) == "/") {
$remoteDirectory = $remoteDirectory . "/";
}
@@ -59,7 +59,7 @@ if(isset($scpBackup) && isset($scpBackup->enabled) && $scpBackup->enabled == 1)
exec(escapeshellcmd($command), $output, $returnCode);
if($returnCode != 0) {
if ($returnCode != 0) {
syslog(LOG_ERR, "scp_backup command: return code [$returnCode]");
}
}