aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorMark Crane <mcrane@pfsense.org>2008-12-26 08:35:23 +0000
committerMark Crane <mcrane@pfsense.org>2008-12-26 08:35:23 +0000
commitde58ef9089a3d104e73e122b9c1c005544e5e0ef (patch)
treeca82e69098554e637b48990883a365eabf194346 /packages
parent64c52e66445b1f74a6281d7c40c2ad4a976331fe (diff)
downloadpfsense-packages-de58ef9089a3d104e73e122b9c1c005544e5e0ef.tar.gz
pfsense-packages-de58ef9089a3d104e73e122b9c1c005544e5e0ef.tar.bz2
pfsense-packages-de58ef9089a3d104e73e122b9c1c005544e5e0ef.zip
Beginnings of a new TFTP package.
Diffstat (limited to 'packages')
-rw-r--r--packages/tftp/tftp.xml136
-rw-r--r--packages/tftp/tftp_files.tmp173
-rw-r--r--packages/tftp/tftp_inc.tmp193
3 files changed, 502 insertions, 0 deletions
diff --git a/packages/tftp/tftp.xml b/packages/tftp/tftp.xml
new file mode 100644
index 00000000..eaf23d07
--- /dev/null
+++ b/packages/tftp/tftp.xml
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!DOCTYPE packagegui SYSTEM "./schema/packages.dtd">
+<?xml-stylesheet type="text/xsl" href="./xsl/package.xsl"?>
+<packagegui>
+ <copyright>
+ <![CDATA[
+/* $Id$ */
+/* ========================================================================== */
+/*
+ tftp.xml
+ 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.
+ */
+/* ========================================================================== */
+ ]]>
+ </copyright>
+ <description>FreeSWITCH is an open source telephony platform designed to facilitate the creation of voice and chat driven products scaling from a soft-phone up to a soft-switch. It can be used as a simple switching engine, a PBX, a media gateway or a media server to host IVR applications using simple scripts or XML to control the callflow.</description>
+ <requirements>Describe your package requirements here</requirements>
+ <faq>Currently there are no FAQ items provided.</faq>
+ <name>tftp Settings</name>
+ <version>0.1</version>
+ <title>TFTP: Settings</title>
+ <include_file>/usr/local/pkg/freeswitch.inc</include_file>
+ <menu>
+ <name>FreeSWITCH</name>
+ <tooltiptext>Modify FreeSWITCH settings.</tooltiptext>
+ <section>Services</section>
+ <configfile>freeswitch.xml</configfile>
+ <url>/pkg_edit.php?xml=freeswitch.xml&amp;id=0</url>
+ </menu>
+ <service>
+ <name>tftp</name>
+ <rcfile>tftp.sh</rcfile>
+ <executable>tftp</executable>
+ <description>Trivial File Transport Protocol is a very simple file transfer protocol. Often used with routers, voip phones and more.</description>
+ </service>
+ <tabs>
+ <tab>
+ <text>Description</text>
+ <url>/pkg_edit.php?xml=tftp.xml&amp;id=0</url>
+ <active/>
+ </tab>
+ <tab>
+ <text>Files</text>
+ <url>/tftp/tftp_files.php</url>
+ </tab>
+ </tabs>
+ <configpath>installedpackages->package->$packagename->configuration->tftp</configpath>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/tftp/tftp_inc.tmp</item>
+ </additional_files_needed>
+ <additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>0755</chmod>
+ <item>http://www.pfsense.com/packages/config/tftp/tftp_files.tmp</item>
+ </additional_files_needed>
+ <fields>
+ <field>
+ <fielddescr>Numbering Plan</fielddescr>
+ <fieldname>numbering_plan</fieldname>
+ <description>Enter the numbering plan here. example: US</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Default Gateway</fielddescr>
+ <fieldname>default_gateway</fieldname>
+ <description>Enter the default gateway name here. example: asterlink.com</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>Default Area Code</fielddescr>
+ <fieldname>default_area_code</fieldname>
+ <description>Enter the area code here. example: 918</description>
+ <type>input</type>
+ </field>
+ <field>
+ <fielddescr>SMTP Secure</fielddescr>
+ <fieldname>smtpsecure</fieldname>
+ <description>Select the SMTP security. None, TLS, SSL</description>
+ <type>select</type>
+ <options>
+ <option>
+ <name>none</name>
+ <value></value>
+ </option>
+ <option>
+ <name>tls</name>
+ <value>tls</value>
+ </option>
+ <option>
+ <name>ssl</name>
+ <value>ssl</value>
+ </option>
+ </options>
+ </field>
+ </fields>
+ <custom_add_php_command>
+ </custom_add_php_command>
+ <custom_php_resync_config_command>
+ sync_package();
+ </custom_php_resync_config_command>
+ <custom_delete_php_command>
+ sync_package();
+ </custom_delete_php_command>
+ <custom_php_install_command>
+ php_install_command();
+ </custom_php_install_command>
+ <custom_php_deinstall_command>
+ php_deinstall_command();
+ </custom_php_deinstall_command>
+</packagegui> \ No newline at end of file
diff --git a/packages/tftp/tftp_files.tmp b/packages/tftp/tftp_files.tmp
new file mode 100644
index 00000000..a32d28f3
--- /dev/null
+++ b/packages/tftp/tftp_files.tmp
@@ -0,0 +1,173 @@
+<?php
+/* $Id$ */
+/*
+ freeswitch_ivr.php
+ Copyright (C) 2008 Mark J Crane
+ All rights reserved.
+
+ FreeSWITCH (TM)
+ http://www.freeswitch.org/
+
+ 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.
+*/
+
+require("guiconfig.inc");
+require("/usr/local/pkg/tftp_inc.php");
+
+
+//$a_ivr = &$config['installedpackages']['freeswitchivr']['config'];
+
+
+if ($_GET['act'] == "del") {
+ if ($_GET['type'] == 'ivr') {
+ if ($a_ivr[$_GET['id']]) {
+ //unset($a_ivr[$_GET['id']]);
+ //write_config();
+ sync_package_freeswitch_ivr();
+ header("Location: tftp_files.php");
+ exit;
+ }
+ }
+}
+
+include("head.inc");
+
+?>
+
+<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
+<?php include("fbegin.inc"); ?>
+<p class="pgtitle">TFTP: Files</p>
+
+<div id="mainlevel">
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+<tr><td class="tabnavtbl">
+<?php
+
+ $tab_array = array();
+ $tab_array[] = array(gettext("Description"), false, "/pkg_edit.php?xml=tftp.xml&amp;id=0");
+ $tab_array[] = array(gettext("Files"), false, "/tftp/tftp_files.php");
+ display_top_tabs($tab_array);
+
+?>
+</td></tr>
+</table>
+
+<table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td class="tabcont" >
+
+<form action="tftp_files.php" method="post" name="iform" id="iform">
+
+ <table width="100%" border="0" cellpadding="6" cellspacing="0">
+ <tr>
+ <td><p><span class="vexpl"><span class="red"><strong>IVR<br />
+ </strong></span>
+ Trivial File Transport Protocol is a very simple file transfer
+ protocol. Often used with routers, voip phones and more.
+ </span></p></td>
+ </tr>
+ </table>
+ <br />
+
+ <table width="100%" border="0" cellpadding="0" cellspacing="0">
+ <tr>
+ <td width="25%" class="listhdrr">Name</td>
+ <td width="50%" class="listhdr">Description</td>
+ <td width="10%" class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle"><a href="tftp_files_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <?php
+ if ($handle = opendir('.')) {
+ while (false !== ($file = readdir($handle))) {
+ if ($file != "." && $file != "..") {
+
+ echo "<tr>\n";
+ echo " <td class=\"listlr\" ondblclick=\"\">\n";
+ echo " $file";
+ echo " </td>\n";
+ echo " <td valign=\"middle\" nowrap class=\"list\">\n";
+ echo " <table border=\"0\" cellspacing=\"0\" cellpadding=\"1\">\n";
+ echo " <tr>\n";
+ echo " <td valign=\"middle\"><a href=\"tftp_files_edit.php?id=$i\"><img src=\"/themes/".$g['theme']."/images/icons/icon_e.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
+ echo " <td><a href=\"tftp_files_edit.php?type=tftp&act=del&id=$i\" onclick=\"return confirm('Do you really want to delete this file?')\"><img src=\"/themes/". $g['theme']."/images/icons/icon_x.gif\" width=\"17\" height=\"17\" border=\"0\"></a></td>\n";
+ echo " </tr>\n";
+ echo " </table>\n";
+ echo " </td>\n";
+ echo "</tr>\n";
+
+ }
+ }
+ closedir($handle);
+ }
+ ?>
+
+
+
+
+
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list">
+ <table border="0" cellspacing="0" cellpadding="1">
+ <tr>
+ <td width="17"></td>
+ <td valign="middle">
+ a href="tftp_files_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+
+ <tr>
+ <td class="list" colspan="3"></td>
+ <td class="list"></td>
+ </tr>
+ </table>
+
+</form>
+
+<br>
+<br>
+<br>
+<br>
+<br>
+<br>
+
+</td>
+</tr>
+</table>
+
+</div>
+
+
+<?php include("fend.inc"); ?>
+</body>
+</html>
diff --git a/packages/tftp/tftp_inc.tmp b/packages/tftp/tftp_inc.tmp
new file mode 100644
index 00000000..20327fd9
--- /dev/null
+++ b/packages/tftp/tftp_inc.tmp
@@ -0,0 +1,193 @@
+<?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