From dceb67ec01824f07e585d7894888721ee4eb2590 Mon Sep 17 00:00:00 2001 From: jim-p Date: Fri, 6 May 2011 15:39:27 -0400 Subject: Add a TFTP package fixed for pfSense 2.0 --- config/tftp2/tftp.inc | 126 ++++++++++++++++++++++ config/tftp2/tftp.xml | 83 ++++++++++++++ config/tftp2/tftp_files.php | 257 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 466 insertions(+) create mode 100644 config/tftp2/tftp.inc create mode 100644 config/tftp2/tftp.xml create mode 100644 config/tftp2/tftp_files.php (limited to 'config/tftp2') diff --git a/config/tftp2/tftp.inc b/config/tftp2/tftp.inc new file mode 100644 index 00000000..698122d2 --- /dev/null +++ b/config/tftp2/tftp.inc @@ -0,0 +1,126 @@ +10^x|1024->2^x] + $s=array('B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB'); + $e=floor(log($bytes,$convention)); + return round($bytes/pow($convention,$e),2).' '.$s[$e]; +} + +function tftp_install_command() { + global $config; + conf_mount_rw(); + + if (!is_dir('/tftpboot')) { + // Create the directory + exec("mkdir /tftpboot"); + + //Set the directory permissions + exec("chmod -R 777 /tftpboot"); + } + + if (!is_dir('/root/backup/')) { + // Create the backup directory + exec("mkdir /root/backup/"); + } + + // if backup file exists restore it + $filename = 'tftp.bak.tgz'; + + //extract a specific directory to /usr/local/freeswitch + if (file_exists('/root/backup/'.$filename)) { + system('cd /; tar xvpfz /root/backup/tftp.bak.tgz'); + system('chmod -R 744 /tftpboot/*'); + unset($filename); + } +} + +function tftp_deinstall_command() { + + unlink_if_exists("/usr/local/pkg/tftp.xml"); + unlink_if_exists("/usr/local/pkg/tftp.inc"); + unlink_if_exists("/usr/local/www/packages/tftp/tftp_files.php"); + exec("rm -R /usr/local/www/packages/tftp/"); + + //exec("rm -R /tftpboot"); + unlink_if_exists("/usr/local/etc/rc.d/tftp.sh"); + unlink_if_exists("/tmp/pkg_mgr_tftp.log"); +} + +function tftp_generate_rules($type) { + if ($type != "nat") + return; + // Open inetd.conf write handle + $inetd_fd = fopen("/var/etc/inetd.conf","a+"); + /* add tftp daemon */ + fwrite($inetd_fd, "tftp\t\tdgram\tudp\twait\t\troot\t/usr/libexec/tftpd\ttftpd /tftpboot\n"); + fclose($inetd_fd); // Close file handle +} +?> diff --git a/config/tftp2/tftp.xml b/config/tftp2/tftp.xml new file mode 100644 index 00000000..6d757cc4 --- /dev/null +++ b/config/tftp2/tftp.xml @@ -0,0 +1,83 @@ + + + + + + + + + Describe your package requirements here + Currently there are no FAQ items provided. + tftp Settings + 2.0 + TFTP: Settings + /usr/local/pkg/tftp.inc + + TFTP + Add or Remove files for TFTP. +
Services
+ tftp.xml + tftp_files.php +
+ + tftp + inetd + Trivial File Transport Protocol is a very simple file transfer protocol. Often used with routers, voip phones and more. + + + + Files + tftp_files.php + + + installedpackages->$packagename + + /usr/local/pkg/ + 0755 + http://www.pfsense.com/packages/config/tftp/tftp.inc + + + /usr/local/www/ + 0755 + http://www.pfsense.com/packages/config/tftp/tftp_files.php + + + tftp_install_command(); + + + tftp_deinstall_command(); + + tftp_generate_rules +
\ No newline at end of file diff --git a/config/tftp2/tftp_files.php b/config/tftp2/tftp_files.php new file mode 100644 index 00000000..a55e92c6 --- /dev/null +++ b/config/tftp2/tftp_files.php @@ -0,0 +1,257 @@ + + + + +

TFTP: Files

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

TFTP files
+
+ Trivial File Transport Protocol is a very simple file transfer + protocol. Use the file upload to add files to the /tftpboot directory. + Click on the file from the file list below to download it. +

+
+ + +
+
+ + + + + + + + + + + +
File to upload: + +
    +
+
+ + +
+
+ + \n"; + echo "
\n"; + echo "Backup / Restore
\n"; + echo "The 'backup' button will tar gzip /tftpboot/ to /root/backup/tftp.bak.tgz it then presents a file to download. \n"; + echo "If the backup file does not exist in /root/backup/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('/root/backup/tftp.bak.tgz')) { + echo " \n"; + } + echo "
\n"; + echo "

\n\n"; + ?> + + + + + + + + + + \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + + } + } + closedir($handle); + } + ?> + + + + + +
File Name (download)Last ModifiedSize
\n"; + echo " \n"; + echo " $file"; + echo " "; + echo " \n"; + echo date ("F d Y H:i:s", filemtime('/tftpboot/'.$file)); + echo " \n"; + echo " ".$tftp_filesize; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "
+ + +
+
+
+
+
+
+ + + + + +
+ + + + -- cgit v1.2.3