From 378fb592cd5e5870983f55f14585d91a9e838941 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sat, 27 Dec 2008 03:18:56 +0000 Subject: TFTP package fix restore --- packages/tftp/tftp.inc | 14 ++-- packages/tftp/tftp.xml | 2 +- packages/tftp/tftp_files.tmp | 6 +- packages/tftp/tftp_inc.tmp | 193 ------------------------------------------- 4 files changed, 12 insertions(+), 203 deletions(-) delete mode 100644 packages/tftp/tftp_inc.tmp 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 @@ Describe your package requirements here Currently there are no FAQ items provided. tftp Settings - 0.8 + 0.8.1 TFTP: Settings /usr/local/pkg/tftp.inc 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 @@ - "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 -- cgit v1.2.3