diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2008-10-06 00:40:18 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2008-10-06 00:40:18 +0000 |
commit | 45169eeb1a0b3cb8da0dd26f9d15601310ea5fec (patch) | |
tree | 000a0268d6a036331691a48ab4906f3567e1939b | |
parent | eeba292300dbbd633e7aa658b077a9379baeea47 (diff) | |
download | pfsense-packages-45169eeb1a0b3cb8da0dd26f9d15601310ea5fec.tar.gz pfsense-packages-45169eeb1a0b3cb8da0dd26f9d15601310ea5fec.tar.bz2 pfsense-packages-45169eeb1a0b3cb8da0dd26f9d15601310ea5fec.zip |
Adding package for BSD Perimeter pfSense auto configuration backup.
This will be free for any portal.pfsense.org subscriber.
-rw-r--r-- | packages/autoconfigbackup/autoconfigbackup.xml | 91 | ||||
-rw-r--r-- | packages/autoconfigbackup/upload_config_filter.php | 36 |
2 files changed, 127 insertions, 0 deletions
diff --git a/packages/autoconfigbackup/autoconfigbackup.xml b/packages/autoconfigbackup/autoconfigbackup.xml new file mode 100644 index 00000000..53fce7c1 --- /dev/null +++ b/packages/autoconfigbackup/autoconfigbackup.xml @@ -0,0 +1,91 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd"> +<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?> +<packagegui> + <copyright> + <![CDATA[ + /* $Id$ */ + /* + autoconfigbackup.xml + part of pfSense (http://www.pfSense.com) + Copyright (C) 2008 BSD Perimeter + All rights reserved. + */ + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. + */ + ]]> + </copyright> + <description>Automatically backs up your pfSense configuration. All contents are encrypted on the server. Requires pfSense Premium Support Portal Subscription from http://portal.pfsense.org</description> + <requirements>pfSense Premium Support Portal</requirements> + <name>autoconfigbackup</name> + <version>1.0</version> + <title>Diagnostics: Auto Configuration Backup</title> + <savetext>Change</savetext> + <aftersaveredirect>pkg_edit.php?xml=autoconfigbackup.xml&id=0</aftersaveredirect> + <menu> + <name>autoconfigbackup Settings</name> + <tooltiptext>Set autoconfigbackup settings such as password and port.</tooltiptext> + <section>Diagnostics</section> + <url>/pkg_edit.php?xml=autoconfigbackup.xml&id=0</url> + </menu> + <tabs> + <tab> + <text>autoconfigbackup Settings</text> + <url>/pkg_edit.php?xml=autoconfigbackup.xml&id=0</url> + <active/> + </tab> + <tab> + <text>Restore</text> + <url>/autoconfigbackup.php</url> + </tab> + </tabs> + <fields> + <field> + <fielddescr>autoconfigbackup Subscription Username</fielddescr> + <fieldname>input</fieldname> + <description>Enter the username for the Automatic Configuration Backup Web GUI. Minimum 5 characters.</description> + <type>password</type> + </field> + + <field> + <fielddescr>autoconfigbackup Subscription Password</fielddescr> + <fieldname>password</fieldname> + <description>Enter the password for the Automatic Configuration Backup Web GUI. Minimum 5 characters.</description> + <type>password</type> + </field> + <field> + <fielddescr>autoconfigbackup Password AGAIN</fielddescr> + <fieldname>passwordagain</fieldname> + <type>password</type> + </field> + </fields> + <custom_php_global_functions> + </custom_php_global_functions> + <custom_add_php_command> + </custom_add_php_command> + <custom_php_resync_config_command> + </custom_php_resync_config_command> + <custom_php_install_command> + </custom_php_install_command> + <custom_php_deinstall_command> + </custom_php_deinstall_command> +</packagegui> diff --git a/packages/autoconfigbackup/upload_config_filter.php b/packages/autoconfigbackup/upload_config_filter.php new file mode 100644 index 00000000..a6e58c4c --- /dev/null +++ b/packages/autoconfigbackup/upload_config_filter.php @@ -0,0 +1,36 @@ +<?php + +/* + * pfSense upload config to pfSense.org script + * This file plugs into filter.inc (/usr/local/pkg/pf) + * and runs every time the running firewall filter changes. + * + * Written by Scott Ullrich + * (C) 2008 BSD Perimeter LLC + * + */ + + +$last_backup_date = $config['system']['lastpfSbackup']; +$last_config_change = $config['revision']['time']; + +/* If configuration has changed, upload to pfS */ +if($last_backup_date <> $last_config_change) { + + $hostname = $config['system']['hostname']; + $username = $config['installedpackages']['pfSautoconfigbackup']['config']['username']; + $password = $config['installedpackages']['pfSautoconfigbackup']['config']['password']; + $reason = $config['revision']['description']; + + $upload_url = "https://{$username}:{$password}@portal.pfsense.org/pfSconfigbackups/backup.php"; + + $curl_Session = curl_init($upload_url); + curl_setopt ($curl_Session, CURLOPT_POST, 1); + curl_setopt ($curl_Session, CURLOPT_POSTFIELDS, "reason={$reason}&configxml={$configxml}&hostname={$hostname}"); + curl_setopt ($curl_Session, CURLOPT_FOLLOWLOCATION, 1); + curl_exec ($curl_Session); + curl_close ($curl_Session); + +} + +?>
\ No newline at end of file |