aboutsummaryrefslogtreecommitdiffstats
path: root/packages/tftp
diff options
context:
space:
mode:
authorMark Crane <mcrane@pfsense.org>2008-12-27 03:18:56 +0000
committerMark Crane <mcrane@pfsense.org>2008-12-27 03:18:56 +0000
commit378fb592cd5e5870983f55f14585d91a9e838941 (patch)
tree15e1376a53a7ef3d8d59f1d7e031ab93ec16fba7 /packages/tftp
parent975ceaa0bc10e81232128f94d514946f42bee36a (diff)
downloadpfsense-packages-378fb592cd5e5870983f55f14585d91a9e838941.tar.gz
pfsense-packages-378fb592cd5e5870983f55f14585d91a9e838941.tar.bz2
pfsense-packages-378fb592cd5e5870983f55f14585d91a9e838941.zip
TFTP package fix restore
Diffstat (limited to 'packages/tftp')
-rw-r--r--packages/tftp/tftp.inc14
-rw-r--r--packages/tftp/tftp.xml2
-rw-r--r--packages/tftp/tftp_files.tmp6
-rw-r--r--packages/tftp/tftp_inc.tmp193
4 files changed, 12 insertions, 203 deletions
diff --git a/packages/tftp/tftp.inc b/packages/tftp/tftp.inc
index 459ad8f5..26ec2be3 100644
--- a/packages/tftp/tftp.inc
+++ b/packages/tftp/tftp.inc
@@ -104,8 +104,8 @@ function php_install_command()
// Create the directory
exec("mkdir /tftpboot");
- //Set the directory permissions
- exec("chmod -R 777 /tftpboot");
+ //Set the directory permissions
+ exec("chmod -R 777 /tftpboot");
}
@@ -114,10 +114,12 @@ function php_install_command()
exec("mkdir /usr/local/www/tftp");
}
- exec("tar zxvf /tmp/tftp.tgz -C /");
- unlink_if_exists("/tmp/tftp.tgz");
- system('cd /;tar cvzf /tmp/tftp.bak.tgz tftpboot');
-
+ //extract a specific directory to /tftpboot
+ if (file_exists('/tmp/'.$filename)) {
+ //echo "The file $filename exists";
+ system('cd /; tar xvpfz /tmp/tftp.bak.tgz');
+ unset($filename);
+ }
//rename PHP files from .tmp to .php
diff --git a/packages/tftp/tftp.xml b/packages/tftp/tftp.xml
index 77b00689..7983817d 100644
--- a/packages/tftp/tftp.xml
+++ b/packages/tftp/tftp.xml
@@ -41,7 +41,7 @@
<requirements>Describe your package requirements here</requirements>
<faq>Currently there are no FAQ items provided.</faq>
<name>tftp Settings</name>
- <version>0.8</version>
+ <version>0.8.1</version>
<title>TFTP: Settings</title>
<include_file>/usr/local/pkg/tftp.inc</include_file>
<menu>
diff --git a/packages/tftp/tftp_files.tmp b/packages/tftp/tftp_files.tmp
index fa7a521e..1ea1a346 100644
--- a/packages/tftp/tftp_files.tmp
+++ b/packages/tftp/tftp_files.tmp
@@ -53,16 +53,16 @@ if (($_GET['a'] == "download") && file_exists("/tftpboot/".$filename)) {
exit;
}
+
if ($_GET['a'] == "other") {
if ($_GET['t'] == "restore") {
$tmp = '/tmp/';
$filename = 'tftp.bak.tgz';
-
+
//extract a specific directory to /tftpboot
if (file_exists('/tmp/'.$filename)) {
//echo "The file $filename exists";
- system('cd /tftpboot; tar xvpfz /tmp/'.$filename.' tftpboot/');
-
+ system('cd /; tar xvpfz /tmp/'.$filename);
header( 'Location: tftp_files.php?savemsg=Backup+has+been+restored.' ) ;
}
else {
diff --git a/packages/tftp/tftp_inc.tmp b/packages/tftp/tftp_inc.tmp
deleted file mode 100644
index 20327fd9..00000000
--- a/packages/tftp/tftp_inc.tmp
+++ /dev/null
@@ -1,193 +0,0 @@
-<?php
-/* $Id$ */
-/*
-/* ========================================================================== */
-/*
- tftp_inc.php
- Copyright (C) 2008 Mark J Crane
- 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.
-*/
-
-
-function guid()
-{
- if (function_exists('com_create_guid')){
- return com_create_guid();
- }else{
- mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
- $charid = strtoupper(md5(uniqid(rand(), true)));
- $hyphen = chr(45);// "-"
- $uuid = chr(123)// "{"
- .substr($charid, 0, 8).$hyphen
- .substr($charid, 8, 4).$hyphen
- .substr($charid,12, 4).$hyphen
- .substr($charid,16, 4).$hyphen
- .substr($charid,20,12)
- .chr(125);// "}"
- return $uuid;
- }
-}
-//echo guid();
-
-
-function pkg_is_service_running($servicename)
-{
- exec("/bin/ps ax | awk '{ print $5 }'", $psout);
- array_shift($psout);
- foreach($psout as $line) {
- $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line)))));
- }
- if(is_service_running($servicename, $ps) or is_process_running($servicename) ) {
- return true;
- }
- else {
- return false;
- }
-}
-
-function sync_package()
-{
-
- //global $config;
- //sync_package_tftp_files();
-
- //if (pkg_is_service_running('inetd')) {
- // sync_package_tftp();
- //}
-
-}
-
-
-function php_install_command()
-{
-
- global $config;
- conf_mount_rw();
- config_lock();
-
- if (!is_dir('/tftpboot')) {
- // Create the directory
- exec("mkdir /tftpboot");
-
- //Set the directory permissions
- exec("chmod -R 777 /tftpboot");
-
- }
-
- if (!is_dir('/usr/local/www/tftp')) {
- // Create the directory
- exec("mkdir /usr/local/www/tftp");
- }
-
- exec("tar zxvf /tmp/tftp.tgz -C /");
- unlink_if_exists("/tmp/tftp.tgz");
-
-
- //rename PHP files from .tmp to .php
- exec("cp /tmp/tftp_inc.tmp /usr/local/www/tftp/tftp_inc.php");
- unlink_if_exists("/tmp/tftp_inc.tmp");
-
- exec("cp /tmp/tftp_files.tmp /usr/local/www/tftp/tftp_files.php");
- unlink_if_exists("/tmp/tftp_files.tmp");
-
- //prepare inetd.conf for tftp
- $filename = "/etc/inetd.conf";
- $handle = fopen($filename,"rb");
- $contents = fread($handle, filesize($filename));
- fclose($handle);
-
- $handle = fopen($filename,"w");
- $contents = str_replace("#tftp dgram udp wait root /usr/libexec/tftpd", "tftp dgram udp wait root /usr/libexec/tftpd", $contents);
- fwrite($handle, $contents);
- unset($contents);
- fclose($fout);
- unset($filename);
-
-
- // if backup file exists restore it
- $filename = 'tftp.bak.tgz';
-
- //extract a specific directory to /usr/local/freeswitch
- if (file_exists('/tmp/'.$filename)) {
- //echo "The file $filename exists";
-
- //Recommended
- system('cd /tftpboot; tar xvpfz /tmp/'.$filename.' tftpboot/');
-
- unset($filename);
- }
-
- write_rcfile(array(
- "file" => "tftp.sh",
- "start" => "/usr/sbin/inetd",
- "stop" => "killall -9 /usr/sbin/inetd"
- )
- );
-
-
- //sync_package_freeswitch();
- $handle = popen("/usr/sbin/inetd", "r");
- pclose($handle);
-
- //if (pkg_is_service_running('freeswitch')) {
- // sync_package_freeswitch_ivr();
- //}
-
- //conf_mount_ro();
- //config_unlock();
-
-}
-
-
-function php_deinstall_command()
-{
-
- //prepare inetd.conf for tftp
- $filename = "/etc/inetd.conf";
- $handle = fopen($filename,"rb");
- $contents = fread($handle, filesize($filename));
- fclose($handle);
-
- $handle = fopen($filename,"w");
- $contents = str_replace("tftp dgram udp wait root /usr/libexec/tftpd", "#tftp dgram udp wait root /usr/libexec/tftpd", $contents);
- fwrite($handle, $contents);
- unset($contents);
- fclose($fout);
- unset($filename);
-
- exec("killall -9 /usr/sbin/inetd");
-
- unlink_if_exists("/usr/local/pkg/tftp.xml");
- unlink_if_exists("/usr/local/pkg/tftp_inc.php");
- unlink_if_exists("/usr/local/www/tftp/tftp_files.php");
-
- exec("rm -R /tftpboot");
- unlink_if_exists("/usr/local/etc/rc.d/tftp.sh");
- unlink_if_exists("/tmp/pkg_mgr_tftp.log");
-
-}
-
-?> \ No newline at end of file