From 4a8a13b781a72d3ed3ad9328b830be535041633b Mon Sep 17 00:00:00 2001 From: Renato Botelho Date: Fri, 24 Apr 2015 13:24:18 -0300 Subject: Remove ugly copy files around and use additional_files_needed to install files in proper place. Bump package version --- config/backup/backup.inc | 29 +--- config/backup/backup.php | 316 ++++++++++++++++++++++++++++++++++++++++++ config/backup/backup.tmp | 316 ------------------------------------------ config/backup/backup.xml | 13 +- config/backup/backup_edit.php | 215 ++++++++++++++++++++++++++++ config/backup/backup_edit.tmp | 215 ---------------------------- 6 files changed, 538 insertions(+), 566 deletions(-) create mode 100644 config/backup/backup.php delete mode 100644 config/backup/backup.tmp create mode 100755 config/backup/backup_edit.php delete mode 100755 config/backup/backup_edit.tmp (limited to 'config') diff --git a/config/backup/backup.inc b/config/backup/backup.inc index b10fceb8..df508775 100644 --- a/config/backup/backup.inc +++ b/config/backup/backup.inc @@ -78,40 +78,15 @@ function backup_install_command() global $config; conf_mount_rw(); - if (!is_dir('/usr/local/www/packages/')) { - exec("mkdir /usr/local/www/packages/"); - } - - if (!is_dir('/usr/local/www/packages/backup/')) { - exec("mkdir /usr/local/www/packages/backup/"); - } - //create the backup directory if (!is_dir('/root/backup/')) { - exec("mkdir /root/backup/"); + @mkdir("/root/backup/"); } - //rename PHP files from .tmp to .php - exec("cp /tmp/backup.tmp /usr/local/www/packages/backup/backup.php"); - unlink_if_exists("/tmp/backup.tmp"); - - exec("cp /tmp/backup_edit.tmp /usr/local/www/packages/backup/backup_edit.php"); - unlink_if_exists("/tmp/backup_edit.tmp"); - backup_sync_package(); conf_mount_ro(); } - -function backup_deinstall_command() -{ - conf_mount_rw(); - unlink_if_exists("/usr/local/pkg/backup.xml"); - unlink_if_exists("/usr/local/pkg/backup.inc"); - exec("rm /usr/local/www/packages/backup/"); - conf_mount_ro(); -} - -?> \ No newline at end of file +?> diff --git a/config/backup/backup.php b/config/backup/backup.php new file mode 100644 index 00000000..3cada9b3 --- /dev/null +++ b/config/backup/backup.php @@ -0,0 +1,316 @@ + 0) { + $backup_cmd = 'tar --create --verbose --gzip --file '.$tmp.$filename.' --directory / '; + foreach ($a_backup as $ent) { + if ($ent['enabled'] =="true"){ + //htmlspecialchars($ent['name']); + //htmlspecialchars($ent['path']); + //htmlspecialchars($ent['description']); + $backup_cmd .= htmlspecialchars($ent['path']).' '; + } + $i++; + } + //echo $backup_cmd; //exit; + system($backup_cmd); + } + + session_cache_limiter('public'); + $fd = fopen($tmp.$filename, "rb"); + header("Content-Type: binary/octet-stream"); + header("Content-Length: " . filesize($tmp.$filename)); + header('Content-Disposition: attachment; filename="'.$filename.'"'); + fpassthru($fd); + + conf_mount_ro(); + exit; + } +} + +if ($_GET['a'] == "other") { + if ($_GET['t'] == "restore") { + conf_mount_rw(); + $tmp = '/root/backup/'; + $filename = 'pfsense.bak.tgz'; + + //extract the tgz file + if (file_exists('/root/backup/'.$filename)) { + //echo "The file $filename exists"; + system('cd /; tar xvpfz /root/backup/'.$filename.' '); + header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; + } + else { + header( 'Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; + } + conf_mount_ro(); + exit; + } +} + +if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { + conf_mount_rw(); + $filename = 'pfsense.bak.tgz'; + move_uploaded_file($_FILES['ulfile']['tmp_name'], "/root/backup/" . $filename); + $savemsg = "Uploaded file to /root/backup/" . htmlentities($_FILES['ulfile']['name']); + system('cd /; tar xvpfz /root/backup/'.$filename.' '); + conf_mount_ro(); +} + + +include("head.inc"); + +?> + + + + +

Backup: Files & Directories

+ + + +
+ + +
+ +
+ + + + \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
+ + + + + +
+

+ Use this to tool to backup files and directories. The following directories + are recommended for backup. + + + + +
pfSense Config/cf/conf
RRD Graph Data Files/var/db/rrd
+

+
+ +
+
+ +
+ +
+ + + + + + + + +
Upload and Restore
Use this to upload and restore your backup file.File to upload: + + + +
+
+
+
+ + + +\n"; + echo "
\n"; + echo "Backup / Restore
\n"; + echo "The 'backup' button will tar gzip the directories that are listed below to /root/backup/pfsense.bak.tgz it then presents a file to download. \n"; + echo "If the backup file does not exist in /root/backup/pfsense.bak.tgz then the 'restore' button will be hidden. \n"; + echo "

\n"; + echo "
\n"; + echo " \n"; + if (file_exists('/root/backup/pfsense.bak.tgz')) { + echo " \n"; + } + echo "
\n"; + echo "

\n\n"; + + +echo "
\n"; + + +if ($config_change == 1) { + write_config(); + $config_change = 0; +} + +//if ($savemsg) print_info_box($savemsg); +//if (file_exists($d_hostsdirty_path)): echo"

"; +//print_info_box_np("This is an info box."); +//echo"
"; +//endif; + +?> + + + + + + + + + + + 0) { + + foreach ($a_backup as $ent) { + + ?> + + + + + + + + + + + + + + + + + + +
NameEnabledDescription + + + + + + +
+ +
+   + +   + +   + + + + + + +
+
+ + + + + +
+
+ +

+ + +
+
+
+
+
+
+
+
+ + + + + +
+ + + + + diff --git a/config/backup/backup.tmp b/config/backup/backup.tmp deleted file mode 100644 index 3cada9b3..00000000 --- a/config/backup/backup.tmp +++ /dev/null @@ -1,316 +0,0 @@ - 0) { - $backup_cmd = 'tar --create --verbose --gzip --file '.$tmp.$filename.' --directory / '; - foreach ($a_backup as $ent) { - if ($ent['enabled'] =="true"){ - //htmlspecialchars($ent['name']); - //htmlspecialchars($ent['path']); - //htmlspecialchars($ent['description']); - $backup_cmd .= htmlspecialchars($ent['path']).' '; - } - $i++; - } - //echo $backup_cmd; //exit; - system($backup_cmd); - } - - session_cache_limiter('public'); - $fd = fopen($tmp.$filename, "rb"); - header("Content-Type: binary/octet-stream"); - header("Content-Length: " . filesize($tmp.$filename)); - header('Content-Disposition: attachment; filename="'.$filename.'"'); - fpassthru($fd); - - conf_mount_ro(); - exit; - } -} - -if ($_GET['a'] == "other") { - if ($_GET['t'] == "restore") { - conf_mount_rw(); - $tmp = '/root/backup/'; - $filename = 'pfsense.bak.tgz'; - - //extract the tgz file - if (file_exists('/root/backup/'.$filename)) { - //echo "The file $filename exists"; - system('cd /; tar xvpfz /root/backup/'.$filename.' '); - header( 'Location: backup.php?savemsg=Backup+has+been+restored.' ) ; - } - else { - header( 'Location: backup.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; - } - conf_mount_ro(); - exit; - } -} - -if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { - conf_mount_rw(); - $filename = 'pfsense.bak.tgz'; - move_uploaded_file($_FILES['ulfile']['tmp_name'], "/root/backup/" . $filename); - $savemsg = "Uploaded file to /root/backup/" . htmlentities($_FILES['ulfile']['name']); - system('cd /; tar xvpfz /root/backup/'.$filename.' '); - conf_mount_ro(); -} - - -include("head.inc"); - -?> - - - - -

Backup: Files & Directories

- - - -
- - -
- -
- - - - \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
- - - - - -
-

- Use this to tool to backup files and directories. The following directories - are recommended for backup. - - - - -
pfSense Config/cf/conf
RRD Graph Data Files/var/db/rrd
-

-
- -
-
- -
- -
- - - - - - - - -
Upload and Restore
Use this to upload and restore your backup file.File to upload: - - - -
-
-
-
- - - -\n"; - echo "
\n"; - echo "Backup / Restore
\n"; - echo "The 'backup' button will tar gzip the directories that are listed below to /root/backup/pfsense.bak.tgz it then presents a file to download. \n"; - echo "If the backup file does not exist in /root/backup/pfsense.bak.tgz then the 'restore' button will be hidden. \n"; - echo "

\n"; - echo "
\n"; - echo " \n"; - if (file_exists('/root/backup/pfsense.bak.tgz')) { - echo " \n"; - } - echo "
\n"; - echo "

\n\n"; - - -echo "
\n"; - - -if ($config_change == 1) { - write_config(); - $config_change = 0; -} - -//if ($savemsg) print_info_box($savemsg); -//if (file_exists($d_hostsdirty_path)): echo"

"; -//print_info_box_np("This is an info box."); -//echo"
"; -//endif; - -?> - - - - - - - - - - - 0) { - - foreach ($a_backup as $ent) { - - ?> - - - - - - - - - - - - - - - - - - -
NameEnabledDescription - - - - - - -
- -
-   - -   - -   - - - - - - -
-
- - - - - -
-
- -

- - -
-
-
-
-
-
-
-
- - - - - -
- - - - - diff --git a/config/backup/backup.xml b/config/backup/backup.xml index 1ed9c46e..ae1adf52 100644 --- a/config/backup/backup.xml +++ b/config/backup/backup.xml @@ -75,14 +75,14 @@ https://packages.pfsense.org/packages/config/backup/backup.inc - /tmp/ + /usr/local/www/packages/backup/ 0755 - https://packages.pfsense.org/packages/config/backup/backup.tmp + https://packages.pfsense.org/packages/config/backup/backup.php - /tmp/ + /usr/local/www/packages/backup/ 0755 - https://packages.pfsense.org/packages/config/backup/backup_edit.tmp + https://packages.pfsense.org/packages/config/backup/backup_edit.php @@ -109,7 +109,4 @@ backup_install_command(); - - backup_deinstall_command(); - - \ No newline at end of file + diff --git a/config/backup/backup_edit.php b/config/backup/backup_edit.php new file mode 100755 index 00000000..c7dbc38a --- /dev/null +++ b/config/backup/backup_edit.php @@ -0,0 +1,215 @@ + + + + + + +

Backup: Edit

+ + + +
+ + +
+ +
+ + + + +
+ + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + +
Name + +
Path + +
Enabled + \n"; + echo " \n"; + switch (htmlspecialchars($pconfig['enabled'])) { + case "true": + echo " \n"; + echo " \n"; + break; + case "false": + echo " \n"; + echo " \n"; + + break; + default: + echo " \n"; + echo " \n"; + } + echo " \n"; + ?> +
Description + +
Enter the description here.
+
  + + + + +
+
+ +
+
+
+
+
+
+ +
+ +
+ + + + diff --git a/config/backup/backup_edit.tmp b/config/backup/backup_edit.tmp deleted file mode 100755 index c7dbc38a..00000000 --- a/config/backup/backup_edit.tmp +++ /dev/null @@ -1,215 +0,0 @@ - - - - - - -

Backup: Edit

- - - -
- - -
- -
- - - - -
- - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - -
Name - -
Path - -
Enabled - \n"; - echo " \n"; - switch (htmlspecialchars($pconfig['enabled'])) { - case "true": - echo " \n"; - echo " \n"; - break; - case "false": - echo " \n"; - echo " \n"; - - break; - default: - echo " \n"; - echo " \n"; - } - echo " \n"; - ?> -
Description - -
Enter the description here.
-
  - - - - -
-
- -
-
-
-
-
-
- -
- -
- - - - -- cgit v1.2.3