Skip to content

Commit

Permalink
Merge pull request #234 from doktornotor/patch-3
Browse files Browse the repository at this point in the history
  • Loading branch information
rbgarga committed Dec 20, 2016
2 parents 7435f52 + fb00e44 commit e06176b
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 19 deletions.
2 changes: 1 addition & 1 deletion sysutils/pfSense-pkg-AutoConfigBackup/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# $FreeBSD$

PORTNAME= pfSense-pkg-AutoConfigBackup
PORTVERSION= 1.45
PORTVERSION= 1.46
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* autoconfigbackup.inc
*
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2008-2015 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2008-2016 Rubicon Communications, LLC (Netgate)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -26,10 +26,31 @@ require_once("notices.inc");
unlink_if_exists("/usr/local/pkg/parse_config/parse_config_upload.inc");
unlink_if_exists("/usr/local/pkg/parse_config/parse_config_upload.php");

/* Check whether ACB is enabled */
function acb_enabled() {
global $config;
$acb_enabled = false;

if (is_array($config['installedpackages']['autoconfigbackup']['config'])) {
if ($config['installedpackages']['autoconfigbackup']['config'][0]['enable_acb'] != "disabled") {
$acb_enabled = true;
}
}
return $acb_enabled;
}

// Ensures patches match
function acb_custom_php_validation_command($post, &$input_errors) {
global $_POST, $savemsg, $config;

// Do nothing when ACB is disabled in configuration
// This also makes it possible to delete the credentials from config.xml
if (!acb_enabled()) {
// We do not need to store this value.
unset($_POST['testconnection']);
return;
}

if (!$post['username']) {
$input_errors[] = "Username is required.";
}
Expand Down Expand Up @@ -62,6 +83,11 @@ function acb_custom_php_validation_command($post, &$input_errors) {
}

function acb_custom_php_resync_config_command() {
// Do nothing when ACB is disabled in configuration
if (!acb_enabled()) {
return;
}

if (is_file("/cf/conf/lastpfSbackup.txt")) {
conf_mount_rw();
unlink("/cf/conf/lastpfSbackup.txt");
Expand Down Expand Up @@ -96,12 +122,8 @@ function configure_proxy() {
function test_connection($post) {
global $savemsg, $config, $g;

// Do nothing when booting
if (function_exists("platform_booting")) {
if (platform_booting()) {
return;
}
} elseif ($g['booting']) {
// Do nothing when booting or when not enabled
if (platform_booting() || !acb_enabled()) {
return;
}

Expand Down Expand Up @@ -150,12 +172,8 @@ function test_connection($post) {
function upload_config($reasonm = "") {
global $config, $g, $input_errors;

// Do nothing when booting
if (function_exists("platform_booting")) {
if (platform_booting()) {
return;
}
} elseif ($g['booting']) {
// Do nothing when booting or when not enabled
if (platform_booting() || !acb_enabled()) {
return;
}

Expand Down Expand Up @@ -284,4 +302,3 @@ function upload_config($reasonm = "") {
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* autoconfigbackup.xml
*
* part of pfSense (https://www.pfsense.org)
* Copyright (c) 2008-2015 Rubicon Communications, LLC (Netgate)
* Copyright (c) 2008-2016 Rubicon Communications, LLC (Netgate)
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -57,6 +57,17 @@
</tab>
</tabs>
<fields>
<field>
<fielddescr>Enable AutoConfigBackup</fielddescr>
<fieldname>enable_acb</fieldname>
<description>Enable/disable configuration backups to portal.pfsense.org</description>
<type>select</type>
<default_value>enabled</default_value>
<options>
<option><value>enabled</value><name>Enabled</name></option>
<option><value>disabled</value><name>Disabled</name></option>
</options>
</field>
<field>
<fielddescr>Subscription Username</fielddescr>
<fieldname>username</fieldname>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,13 @@
touch("/tmp/acb_nooverwrite");
}
if ($_REQUEST['reason']) {
write_config($_REQUEST['reason']);
if (write_config($_REQUEST['reason'])) {
$savemsg = "Backup completed successfully.";
}
} elseif (write_config("Backup invoked via Auto Config Backup.")) {
$savemsg = "Backup completed successfully.";
} else {
write_config("Backup invoked via Auto Config Backup.");
$savemsg = "Backup not completed - write_config() failed.";
}
$config = parse_config(true);
conf_mount_rw();
Expand All @@ -47,7 +51,6 @@
*/
//upload_config($_REQUEST['reason']);

$savemsg = "Backup completed successfully.";
$donotshowheader = true;
}

Expand Down

0 comments on commit e06176b

Please sign in to comment.