From d00e4a703c02e59b9318d11612109642a1186b36 Mon Sep 17 00:00:00 2001 From: Mark Crane Date: Sun, 1 Feb 2009 09:23:28 +0000 Subject: TFTP package add the TFTP DHCP Option to the DHCP Server, Also add edit for text based files. --- packages/tftp/tftp.inc | 85 +++++++++++++++++++++++++++++++++++++++++++- packages/tftp/tftp.xml | 2 +- packages/tftp/tftp_files.tmp | 12 +++---- 3 files changed, 90 insertions(+), 9 deletions(-) (limited to 'packages') diff --git a/packages/tftp/tftp.inc b/packages/tftp/tftp.inc index 32c11f8b..b731a9ac 100644 --- a/packages/tftp/tftp.inc +++ b/packages/tftp/tftp.inc @@ -131,7 +131,90 @@ function php_install_command() unset($contents); fclose($handle); unset($filename); - + + + // add a TFTP DHCP Option to the DHCP Server + $filename = "/usr/local/www/services_dhcp.php"; + $fout = fopen($filename,"r"); + $tmp = fread($fout, filesize($filename)); + fclose($fout); + + //tftp was not found in the string + if (strpos($tmp, "tftp") === false) { + $tmpsearch = "\$pconfig['netmask'] = \$config['dhcpd'][\$if]['netmask'];"; + $tmpreplace = "\$pconfig['netmask'] = \$config['dhcpd'][\$if]['netmask'];\n"; + $tmpreplace .= "\$pconfig['tftp'] = \$config['dhcpd'][\$if]['options']['tftp-server-name'];"; + $tmp = str_replace($tmpsearch, $tmpreplace, $tmp); + unset($tmpsearch, $tmpreplace); + + $tmpsearch = "\$config['dhcpd'][\$if]['filename'] = \$_POST['filename'];"; + $tmpreplace = "\$config['dhcpd'][\$if]['filename'] = \$_POST['filename'];\n"; + $tmpreplace .= " \$config['dhcpd'][\$if]['options']['tftp-server-name'] = \$_POST['tftp'];"; + $tmp = str_replace($tmpsearch, $tmpreplace, $tmp); + unset($tmpsearch, $tmpreplace); + + $tmpsearch = "function show_netboot_config() {"; + $tmpreplace = "function show_tftp_config() {\n"; + $tmpreplace .= " document.getElementById(\"showtftpbox\").innerHTML=''\n"; + $tmpreplace .= " aodiv = document.getElementById('showtftp');\n"; + $tmpreplace .= " aodiv.style.display = \"block\";\n"; + $tmpreplace .= "}\n"; + $tmpreplace .= "\n"; + $tmpreplace .= "function show_netboot_config() {"; + $tmp = str_replace($tmpsearch, $tmpreplace, $tmp); + unset($tmpsearch, $tmpreplace); + + $tmpsearch = "Enable Network booting"; + $tmpreplace .= ""; + //$tmpreplace = " \n"; + $tmpreplace .= "TFTP server\n"; + $tmpreplace .= " \n"; + $tmpreplace .= "
\n"; + $tmpreplace .= " - Show TFTP configuration\n"; + $tmpreplace .= "
\n"; + $tmpreplace .= "
\n"; + $tmpreplace .= " \">
\n"; + $tmpreplace .= "
\n"; + $tmpreplace .= " \n"; + $tmpreplace .= " \n"; + $tmpreplace .= "\n"; + $tmpreplace .= " \n"; + $tmpreplace .= " Enable Network booting"; + $tmpreplace .= "\n"; + $tmp = str_replace($tmpsearch, $tmpreplace, $tmp); + unset($tmpsearch, $tmpreplace); + + $fout = fopen($filename,"w"); + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + } + unset($tmp, $filename); + + + + $filename = "/etc/inc/services.inc"; + $fout = fopen($filename,"r"); + $tmp = fread($fout, filesize($filename)); + fclose($fout); + + //tftp was not found in the string + if (strpos($tmp, "tftp") === false) { + $tmpsearch = "if (is_array(\$dhcpifconf['ntpserver']) && \$dhcpifconf['ntpserver'][0])"; + $tmpreplace = "if (isset(\$dhcpifconf['options']['tftp-server-name'])) {\n"; + $tmpreplace .= " \$dhcpdconf .= \" option tftp-server-name \\\"\".\$dhcpifconf['options']['tftp-server-name'].\"\\\";\".\"\\n\";\n"; + $tmpreplace .= " }\n"; + $tmpreplace .= " \n"; + $tmpreplace .= " if (is_array(\$dhcpifconf['ntpserver']) && \$dhcpifconf['ntpserver'][0])"; + $tmp = str_replace($tmpsearch, $tmpreplace, $tmp); + unset($tmpsearch, $tmpreplace); + + $fout = fopen($filename,"w"); + fwrite($fout, $tmp); + fclose($fout); + } + unset($tmp, $filename); + // if backup file exists restore it $filename = 'tftp.bak.tgz'; diff --git a/packages/tftp/tftp.xml b/packages/tftp/tftp.xml index dadfd37a..cf2bb680 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.5 + 1.0 TFTP: Settings /usr/local/pkg/tftp.inc diff --git a/packages/tftp/tftp_files.tmp b/packages/tftp/tftp_files.tmp index 1d4b6d21..f49ea76e 100644 --- a/packages/tftp/tftp_files.tmp +++ b/packages/tftp/tftp_files.tmp @@ -179,11 +179,10 @@ if ($savemsg) { echo "

\n\n"; ?> -
- - - +
File Name
+ + @@ -211,7 +210,7 @@ if ($savemsg) { echo "
File Name (download) Last Modified Size
\n"; echo " \n"; echo " \n"; - //echo " \n"; + echo " \n"; echo " \n"; echo " \n"; echo "
\n"; @@ -229,8 +228,7 @@ if ($savemsg) {
- - +

-- cgit v1.2.3