mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
plugins: style sweep
This commit is contained in:
parent
949b7e3f56
commit
8db3b0e5ec
5 changed files with 27 additions and 26 deletions
|
|
@ -680,9 +680,9 @@ class updatedns
|
|||
* dnsUser ("Username" field in OPNsense) should be the subdomain / A-record ("myrecord" in 2nd-level domain)
|
||||
* dnsPass should be the Gandi-API key
|
||||
*/
|
||||
$server = "https://dns.api.gandi.net/api/v5/domains/". $this->_dnsHost . "/records/" . $this->_dnsUser . "/A";
|
||||
$server = "https://dns.api.gandi.net/api/v5/domains/" . $this->_dnsHost . "/records/" . $this->_dnsUser . "/A";
|
||||
|
||||
$body = '{"rrset_ttl":"' . "300" . '", "rrset_values":["'. $this->_dnsIP . '"]}';
|
||||
$body = '{"rrset_ttl":"' . "300" . '", "rrset_values":["' . $this->_dnsIP . '"]}';
|
||||
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace OPNsense\AcmeClient;
|
||||
|
||||
use \OPNsense\AcmeClient\AcmeClient;
|
||||
use OPNsense\AcmeClient\AcmeClient;
|
||||
|
||||
/**
|
||||
* Class LeAutomationFactory
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace OPNsense\AcmeClient;
|
||||
|
||||
use \OPNsense\AcmeClient\AcmeClient;
|
||||
use OPNsense\AcmeClient\AcmeClient;
|
||||
|
||||
/**
|
||||
* Class LeValidationFactory
|
||||
|
|
|
|||
|
|
@ -142,8 +142,10 @@ function main()
|
|||
$force = isset($options['force']) ? true : false;
|
||||
|
||||
// Verify mode and arguments
|
||||
if (empty($options) || isset($options['h']) || isset($options['help']) ||
|
||||
(isset($options['mode']) and !validateMode($options['mode']))) {
|
||||
if (
|
||||
empty($options) || isset($options['h']) || isset($options['help']) ||
|
||||
(isset($options['mode']) and !validateMode($options['mode']))
|
||||
) {
|
||||
// Not enough or invalid arguments specified.
|
||||
help();
|
||||
} elseif (($options['mode'] === 'issue') && (isset($options['cert']) || isset($options['all']))) {
|
||||
|
|
|
|||
|
|
@ -105,17 +105,17 @@ class Git extends Base implements IBackupProvider
|
|||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function setConfiguration($conf)
|
||||
{
|
||||
$mdl = new GitSettings();
|
||||
$this->setModelProperties($mdl, $conf);
|
||||
$validation_messages = $this->validateModel($mdl);
|
||||
if (empty($validation_messages)) {
|
||||
$mdl->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
}
|
||||
return $validation_messages;
|
||||
}
|
||||
public function setConfiguration($conf)
|
||||
{
|
||||
$mdl = new GitSettings();
|
||||
$this->setModelProperties($mdl, $conf);
|
||||
$validation_messages = $this->validateModel($mdl);
|
||||
if (empty($validation_messages)) {
|
||||
$mdl->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
}
|
||||
return $validation_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Backup is responsible for initialising the local repo and pusing it to upstream.
|
||||
|
|
@ -148,21 +148,20 @@ class Git extends Base implements IBackupProvider
|
|||
// When there are unprocessed config backups, flush them out.
|
||||
(new Backend())->configdRun("system event config_changed");
|
||||
// configure upstream
|
||||
exec("cd {$targetdir} && ".
|
||||
"{$git} config core.sshCommand ".
|
||||
"\"ssh -i {$ident_file} -o StrictHostKeyChecking=accept-new -o PasswordAuthentication=no\""
|
||||
);
|
||||
exec("cd {$targetdir} && " .
|
||||
"{$git} config core.sshCommand " .
|
||||
"\"ssh -i {$ident_file} -o StrictHostKeyChecking=accept-new -o PasswordAuthentication=no\"");
|
||||
$url = (string)$mdl->url;
|
||||
$pos = strpos($url, '//');
|
||||
// inject credentials in url (either username or username:password, depending on transport)
|
||||
if (stripos(trim((string)$mdl->url),'http') === 0) {
|
||||
if (stripos(trim((string)$mdl->url), 'http') === 0) {
|
||||
$cred = urlencode((string)$mdl->user) . ":" . urlencode((string)$mdl->password);
|
||||
$url = substr($url,0, $pos+2) . "{$cred}@" . substr($url, $pos+2);
|
||||
$url = substr($url, 0, $pos + 2) . "{$cred}@" . substr($url, $pos + 2);
|
||||
} else {
|
||||
$url = substr($url,0, $pos+2) . urlencode((string)$mdl->user) . "@" . substr($url, $pos+2);
|
||||
$url = substr($url, 0, $pos + 2) . urlencode((string)$mdl->user) . "@" . substr($url, $pos + 2);
|
||||
}
|
||||
exec("cd {$targetdir} && git remote remove origin");
|
||||
exec("cd {$targetdir} && git remote add origin ". escapeshellarg($url));
|
||||
exec("cd {$targetdir} && git remote add origin " . escapeshellarg($url));
|
||||
$pushtxt = shell_exec(
|
||||
"(cd {$targetdir} && git push origin " . escapeshellarg("master:{$mdl->branch}") .
|
||||
" && echo '__exit_ok__') 2>&1"
|
||||
|
|
@ -179,7 +178,7 @@ class Git extends Base implements IBackupProvider
|
|||
$error_type = "unknown error, check log for details";
|
||||
}
|
||||
if (!empty($error_type)) {
|
||||
syslog(LOG_ERR, "git-backup {$error_type} (".str_replace("\n", " ", $pushtxt).")");
|
||||
syslog(LOG_ERR, "git-backup {$error_type} (" . str_replace("\n", " ", $pushtxt) . ")");
|
||||
throw new \Exception($error_type);
|
||||
} else {
|
||||
// return filelist in git
|
||||
|
|
|
|||
Loading…
Reference in a new issue