From caba11a8e7089cec153d4943538217cbca555dc0 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Fri, 26 Dec 2008 23:14:38 +0000 Subject: tftp add backup for the tftp directory --- packages/tftp/tftp.inc | 4 +-- packages/tftp/tftp.xml | 2 +- packages/tftp/tftp_files.tmp | 60 ++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 6 deletions(-) (limited to 'packages') diff --git a/packages/tftp/tftp.inc b/packages/tftp/tftp.inc index de6b90db..0e86b400 100644 --- a/packages/tftp/tftp.inc +++ b/packages/tftp/tftp.inc @@ -130,9 +130,7 @@ function php_install_command() //extract a specific directory to /usr/local/freeswitch if (file_exists('/tmp/'.$filename)) { - //echo "The file $filename exists"; - - //Recommended + //echo "The file $filename exists"; system('cd /tftpboot; tar xvpfz /tmp/'.$filename.' tftpboot/'); unset($filename); diff --git a/packages/tftp/tftp.xml b/packages/tftp/tftp.xml index c7f72a5a..eee6ddcc 100644 --- a/packages/tftp/tftp.xml +++ b/packages/tftp/tftp.xml @@ -41,7 +41,7 @@ Describe your package requirements here Currently there are no FAQ items provided. tftp Settings - 0.7.3 + 0.7.4 TFTP: Settings /usr/local/pkg/tftp.inc diff --git a/packages/tftp/tftp_files.tmp b/packages/tftp/tftp_files.tmp index 809e51a8..6491627c 100644 --- a/packages/tftp/tftp_files.tmp +++ b/packages/tftp/tftp_files.tmp @@ -34,6 +34,12 @@ require("guiconfig.inc"); require("/usr/local/pkg/tftp.inc"); if (($_GET['a'] == "download") && file_exists("/tftpboot/".$_GET['filename'])) { + if ($_GET['t'] == "backup") { + $tmp = '/tmp/'; + $filename = 'freeswitch.bak.tgz'; + system('cd /usr/local/;tar cvzf /tmp/freeswitch.bak.tgz freeswitch'); + } + session_cache_limiter('public'); $fd = fopen("/tftpboot/".$_GET['filename'], "rb"); header("Content-Type: application/force-download"); @@ -48,6 +54,27 @@ if (($_GET['a'] == "download") && file_exists("/tftpboot/".$_GET['filename'])) { exit; } +if ($_GET['a'] == "other") { + if ($_GET['t'] == "restore") { + $tmp = '/tmp/'; + $filename = 'tftp.bak.tgz'; + + //extract a specific directory to /usr/local/freeswitch + if (file_exists('/tmp/'.$filename)) { + //echo "The file $filename exists"; + system('cd /tftpboot; tar xvpfz /tmp/'.$filename.' tftpboot/'); + + header( 'Location: tftp_files.php?savemsg=Backup+has+been+restored.' ) ; + } + else { + header( 'Location: tftp_files.php?savemsg=Restore+failed.+Backup+file+not+found.' ) ; + } + + exit; + } +} + + if (($_POST['submit'] == "Upload") && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { move_uploaded_file($_FILES['ulfile']['tmp_name'], "/tftpboot/" . $_FILES['ulfile']['name']); $ulmsg = "Uploaded file to /tftpboot/" . htmlentities($_FILES['ulfile']['name']); @@ -71,6 +98,12 @@ include("head.inc");

TFTP: Files

+ +
@@ -93,7 +126,8 @@ include("head.inc");

TFTP files
Trivial File Transport Protocol is a very simple file transfer - protocol. Often used with routers, voip phones and more. + protocol. Use the file upload to add files to the /tftpboot directory. + Click on the file to download it.

@@ -147,7 +181,7 @@ include("head.inc"); echo " "; echo " \n"; echo " \n"; - echo date ("F d Y H:i:s.", filemtime('/tftpboot/'.$file)); + echo date ("F d Y H:i:s", filemtime('/tftpboot/'.$file)); echo " \n"; echo " \n"; echo " \n"; @@ -175,6 +209,28 @@ include("head.inc");

+ +\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "\n"; +echo "
\n"; +echo "Backup / Restore
\n"; +echo "The 'backup' button will tar gzip /tftpboot/ to /tmp/tftp.bak.tgz it then presents a file to download. \n"; +echo "If the backup file does not exist in /tmp/tftp.bak.tgz then the 'restore' button will be hidden. \n"; +echo "Use Diagnostics->Command->File to upload: to browse to the file and then click on upload it now ready to be restored. \n"; +echo "

\n"; +echo "
\n"; +echo " \n"; +if (file_exists('/tmp/tftp.bak.tgz')) { + echo " \n"; +} +echo "
\n"; +echo "

\n\n"; +?> +


-- cgit v1.2.3