diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2004-12-12 01:44:44 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2004-12-12 01:44:44 +0000 |
commit | ee11cc6eaea213214d6f632dde3ff878edab55da (patch) | |
tree | 02dc9c2a3ee819dcacdd5b2c0717108d8f786737 | |
parent | d03efa9c8b1b6479e92969c684463c802dba741c (diff) | |
download | pfsense-ee11cc6eaea213214d6f632dde3ff878edab55da.zip pfsense-ee11cc6eaea213214d6f632dde3ff878edab55da.tar.gz |
Say welcome to the pfSense package manager!
-rw-r--r-- | cf/conf/config.xml | 8 | ||||
-rw-r--r-- | conf.default/config.xml | 8 | ||||
-rw-r--r-- | etc/inc/config.inc | 11 | ||||
-rw-r--r-- | etc/inc/globals.inc | 17 | ||||
-rwxr-xr-x | usr/local/www/fbegin.inc | 1 | ||||
-rwxr-xr-x | usr/local/www/pkg_mgr.php | 159 | ||||
-rwxr-xr-x | usr/local/www/pkg_mgr_install.php | 176 | ||||
-rwxr-xr-x | usr/local/www/pkg_mgr_installed.php | 116 |
8 files changed, 478 insertions, 18 deletions
diff --git a/cf/conf/config.xml b/cf/conf/config.xml index ab5d2bb..77b0ab4 100644 --- a/cf/conf/config.xml +++ b/cf/conf/config.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- m0n0wall default system configuration --> -<m0n0wall> +<!-- pfSense default system configuration --> +<pfsense> <version>1.4</version> <lastchange></lastchange> <system> @@ -521,4 +521,6 @@ </wolentry> --> </wol> -</m0n0wall> + <installedpackages> + </installedpackages> +</pfsense> diff --git a/conf.default/config.xml b/conf.default/config.xml index 3ba663b..2e4ec08 100644 --- a/conf.default/config.xml +++ b/conf.default/config.xml @@ -1,6 +1,6 @@ <?xml version="1.0"?> -<!-- m0n0wall default system configuration --> -<m0n0wall> +<!-- pfSense default system configuration --> +<pfsense> <version>1.4</version> <lastchange></lastchange> <system> @@ -519,4 +519,6 @@ </wolentry> --> </wol> -</m0n0wall> + <installedpackages> + </installedpackages> +</pfsense> diff --git a/etc/inc/config.inc b/etc/inc/config.inc index 1bc8c16..01a5e19 100644 --- a/etc/inc/config.inc +++ b/etc/inc/config.inc @@ -85,7 +85,7 @@ if ($g['booting']) { ******************************************************************************* * FATAL ERROR * * The device that contains the configuration file (config.xml) could not be * -* found. m0n0wall cannot continue booting. * +* found. pfSense cannot continue booting. * ******************************************************************************* @@ -126,6 +126,7 @@ if (!$noparseconfig) { /* read cache */ $config = unserialize(file_get_contents("{$g['tmp_path']}/config.cache")); + } else { if (!file_exists("{$g['conf_path']}/config.xml")) { @@ -139,7 +140,7 @@ if (!$noparseconfig) { echo "file is inserted. If it isn't, your configuration changes will be lost\n"; echo "on reboot.\n"; } else { - echo "XML configuration file not found. m0n0wall cannot continue booting.\n"; + echo "XML configuration file not found. pfSense cannot continue booting.\n"; mwexec("/sbin/halt"); exit; } @@ -158,9 +159,9 @@ if (!$noparseconfig) { ******************************************************************************* * WARNING! * -* The current configuration has been created with a newer version of m0n0wall * +* The current configuration has been created with a newer version of pfSense * * than this one! This can lead to serious misbehavior and even security * -* holes! You are urged to either upgrade to a newer version of m0n0wall or * +* holes! You are urged to either upgrade to a newer version of pfSense or * * revert to the default configuration immediately! * ******************************************************************************* @@ -203,7 +204,7 @@ function conf_mount_ro() { /* convert configuration, if necessary */ function convert_config() { - global $config, $g; + global $config, $pkg_config, $g; if ($config['version'] == $g['latest_config']) return; /* already at latest version */ diff --git a/etc/inc/globals.inc b/etc/inc/globals.inc index eef6cff..e278f12 100644 --- a/etc/inc/globals.inc +++ b/etc/inc/globals.inc @@ -1,21 +1,23 @@ <?php /* globals.inc - part of m0n0wall (http://m0n0.ch/wall) - + part of pfSense (www.pfsense.com) + Copyright (C) 2004 Scott Ullrich + + Originally Part of m0n0wall Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. 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 @@ -43,10 +45,11 @@ $g = array( "www_path" => "/usr/local/www", "captiveportal_path" => "/usr/local/captiveportal", "xml_rootobj" => "m0n0wall", + "xml_pkg_rootobj" => "pfSense_pkgs", "pppoe_interface" => "ng0", "n_pptp_units" => 16, "pptp_subnet" => 28, - "debug" => false, + "debug" => true, "latest_config" => "1.4", "nopccard_platforms" => array("wrap", "net48xx") ); diff --git a/usr/local/www/fbegin.inc b/usr/local/www/fbegin.inc index afbf447..4b96a6a 100755 --- a/usr/local/www/fbegin.inc +++ b/usr/local/www/fbegin.inc @@ -50,6 +50,7 @@ function showhide(tspan, tri) { routes</a><br> <a href="/system_firmware.php" class="navlnk">Firmware</a><br> <a href="/system_advanced.php" class="navlnk">Advanced</a><br> + <a href="/pkg_mgr.php" class="navlnk">Package Manager</a><br> <strong>Interfaces</strong> <?php if (!isset($config['system']['webgui']['noassigninterfaces'])): ?> <a href="/interfaces_assign.php" class="navlnks">(assign)</a> diff --git a/usr/local/www/pkg_mgr.php b/usr/local/www/pkg_mgr.php new file mode 100755 index 0000000..506907d --- /dev/null +++ b/usr/local/www/pkg_mgr.php @@ -0,0 +1,159 @@ +#!/usr/local/bin/php +<?php +/* + pkg_mgr.php + Copyright (C) 2004 Scott Ullrich + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. + 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. +*/ + +require("guiconfig.inc"); +require("xmlparse_pkg.inc"); + +$a_out = &$pkg_config['packages']; + +if ($_POST) { + + $pconfig = $_POST; + + $retval = 0; + + if (!file_exists($d_sysrebootreqd_path)) { + config_lock(); + $retval |= filter_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + + if ($retval == 0) { + if (file_exists($d_natconfdirty_path)) + unlink($d_natconfdirty_path); + if (file_exists($d_filterconfdirty_path)) + unlink($d_filterconfdirty_path); + } +} + +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<title><?=gentitle("System: Package Manager");?></title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<link href="gui.css" rel="stylesheet" type="text/css"> +</head> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle">System: Package Manager</p> +<form action="firewall_nat_out_load_balancing.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if (file_exists($d_natconfdirty_path)): ?><p> +<?php print_info_box_np("The Package Manager configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br> +<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p> +<?php endif; ?> +<?php +$configa = $config; +if(!file_exists("/tmp/pkg_config.xml")) { + mwexec("cd {$g['tmp_path']} && /usr/bin/fetch \"http://www.pfsense.com/packages/pkg_config.xml\" >/dev/null 2>&1 "); + if(!file_exists("{$g['tmp_path']}/pkg_config.xml")) { + print_info_box_np("Could not download pkg_config.xml from pfSense.com. Check your DNS settings."); + die; + } +} + +$pkg_config = parse_xml_config("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); + +if(!$pkg_config['packages']) { + print_info_box_np("Could not find any packages in pkg_config.xml"); +} +?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> + <ul id="tabnav"> + <li class="tabact">Available Packages</a></li> + <li class="tabinact"><a href="pkg_mgr_installed.php">Installed Packages</a></li> + </ul> + </td></tr> + <tr> + <td class="tabcont"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="25%" class="listhdrr">Package Name</td> + <td width="25%" class="listhdrr">Category</td> + <td width="50%" class="listhdr">Description</td> + </tr> + + <?php + $i = 0; + foreach ($pkg_config['packages']['package'] as $pkg) { + if(is_array($configa['installedpackages']['package'])) { + foreach ($configa['installedpackages']['package'] as $installed) { + if($installed['name'] == $pkg['name']) + $pkg['name'] = ""; + } + } + if($pkg['name'] <> "") { + ?> + <tr valign="top"> + <td class="listlr"> + <?= $pkg['name'] ?> + </td> + <td class="listlr"> + <?= $pkg['category'] ?> + </td> + <td class="listbg"> + <font color="#FFFFFFF"> + <?= $pkg['descr'] ?> + </td> + <td valign="middle" class="list" nowrap> + <a href="pkg_mgr_install.php?id=<?=$i;?>"><img src="plus.gif" width="17" height="17" border="0"></a> + + </td> + </tr> + + <?php + $i++; + } + } + ?> + </table> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> + + + + + + + + + + diff --git a/usr/local/www/pkg_mgr_install.php b/usr/local/www/pkg_mgr_install.php new file mode 100755 index 0000000..5403268 --- /dev/null +++ b/usr/local/www/pkg_mgr_install.php @@ -0,0 +1,176 @@ +#!/usr/local/bin/php +<?php +/* + pkg_mgr_install.php + Copyright (C) 2004 Scott Ullrich + 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. +*/ + +require("guiconfig.inc"); +require("xmlparse_pkg.inc"); + +function update_status($status) { + echo "\n<script language=\"JavaScript\">document.forms[0].status.value=\"" . $status . "\";</script>"; +} + +function execute_command_return_output($command) { + $fd = popen($command . " 2>&1 ", "r"); + echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"\";</script>"; + $counter = 0; + $counter2 = 0; + while(!feof($fd)) { + $tmp = fread($fd,49); + $tmp1 = ereg_replace("\n","\\n", $tmp); + $text = ereg_replace("\"","'", $tmp1); + if($lasttext == "..") { + $text = ""; + $lasttext = ""; + $counter=$counter-2; + } else { + $lasttext .= $text; + } + if($counter > 51) { + $counter = 0; + $extrabreak = "\\n"; + } else { + $extrabreak = ""; + $counter++; + } + if($counter2 > 600) { + echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = \"\";</script>"; + $counter2 = 0; + } else + $counter2++; + echo "\n<script language=\"JavaScript\">this.document.forms[0].output.value = this.document.forms[0].output.value + \"" . $text . $extrabreak . "\"; f('output'); </script>"; + } + fclose($fd); +} + +$a_out = &$pkg_config['packages']; + +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<title><?=gentitle("System: Package Manager: Install Package");?></title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<link href="gui.css" rel="stylesheet" type="text/css"> +</head> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle">System: Package Manager: Install Package</p> +<form action="firewall_nat_out_load_balancing.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if (file_exists($d_natconfdirty_path)): ?><p> +<?php print_info_box_np("The Package Manager configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br> +<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p> +<?php endif; ?> +<?php +if(!file_exists("/tmp/pkg_config.xml")) { + mwexec("cd {$g['tmp_path']} && /usr/bin/fetch \"http://www.pfsense.com/packages/pkg_config.xml\" >/dev/null 2>&1 "); + if(!file_exists("{$g['tmp_path']}/pkg_config.xml")) { + print_info_box_np("Could not download pkg_config.xml from pfSense.com. Check your DNS settings."); + die; + } +} + +$pkg_config = parse_xml_config("{$g['tmp_path']}/pkg_config.xml", "pfsensepkgs"); + +$id = $_GET['id']; + +if(!$pkg_config['packages']) { + print_info_box_np("Could not find any packages in pkg_config.xml"); +} +?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> + <ul id="tabnav"> + <li class="tabact">Available Packages</a></li> + <li class="tabinact"><a href="pkg_mgr_installed.php">Installed Packages</a></li> + </ul> + </td></tr> + <tr> + <td class="tabcont"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td> + <textarea cols="55" rows="1" name="status" id="status" wrap="hard">One moment please... This will take a while!</textarea> + <textarea cols="55" rows="25" name="output" id="output" wrap="hard"></textarea> + </td> + </tr> + </table> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> + +<? + +/* install the package */ + +$a_out = &$pkg_config['packages']['package']; +$pkgent = array(); +$pkgent['name'] = $pkg_config['packages']['package'][$id]['name']; +$pkgent['descr'] = $pkg_config['packages']['package'][$id]['descr']; +$pkgent['category'] = $pkg_config['packages']['package'][$id]['category']; +$pkgent['depends_on_package'] = $a_out[$id]['depends_on_package']; +$pkgent['depends_on_package_base'] = $a_out[$id]['depends_on_package_base']; +$pkgent['pfsense_package'] = $a_out[$id]['pfsense_package']; +$pkgent['pfsense_package_base'] = $a_out[$id]['pfsense_package_base']; +$a_out = &$config['packages']['package']; + +update_status("Downloading and installing " . $pkgent['name'] . " ... "); + +execute_command_return_output("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['pfsense_package_base'] . "/" . $pkgent['pfsense_package']); + +if ($pkgent['pfsense_package_base']) + execute_command_return_output("cd /tmp/ && /usr/sbin/pkg_add -r " . $pkgent['depends_on_package_base'] . "/" . $pkgent['depends_on_package']); + +// XXX: ensure package is REALLY installed before doing below... + +$config = parse_xml_config("{$g['conf_path']}/config.xml", $g['xml_rootobj']); + +$config['installedpackages']['package'][] = $pkgent; + +if (isset($id) && $a_out[$id]) + $a_out[$id] = $pkgent; +else + $a_out[] = $pkgent; + +write_config(); + +update_status("Package installation completed."); +?> + + + + + + + + + diff --git a/usr/local/www/pkg_mgr_installed.php b/usr/local/www/pkg_mgr_installed.php new file mode 100755 index 0000000..7213648 --- /dev/null +++ b/usr/local/www/pkg_mgr_installed.php @@ -0,0 +1,116 @@ +#!/usr/local/bin/php +<?php +/* + pkg_mgr.php + Copyright (C) 2004 Scott Ullrich + All rights reserved. + + originally part of m0n0wall (http://m0n0.ch/wall) + Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>. + 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. +*/ + +require("guiconfig.inc"); +require("xmlparse_pkg.inc"); + +?> +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> +<html> +<head> +<title><?=gentitle("System: Package Manager");?></title> +<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> +<link href="gui.css" rel="stylesheet" type="text/css"> +</head> + +<body link="#0000CC" vlink="#0000CC" alink="#0000CC"> +<?php include("fbegin.inc"); ?> +<p class="pgtitle">System: Package Manager</p> +<form action="firewall_nat_out_load_balancing.php" method="post"> +<?php if ($savemsg) print_info_box($savemsg); ?> +<?php if (file_exists($d_natconfdirty_path)): ?><p> +<?php print_info_box_np("The Package Manager configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br> +<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p> +<?php endif; ?> +<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td> + <ul id="tabnav"> + <li class="tabinact"><a href="pkg_mgr.php">Available Packages</a></li> + <li class="tabact">Installed Packages</li> + </ul> + </td></tr> + <tr> + <td class="tabcont"> + <table width="100%" border="0" cellpadding="6" cellspacing="0"> + <tr> + <td width="25%" class="listhdrr">Package Name</td> + <td width="25%" class="listhdrr">Category</td> + <td width="50%" class="listhdr">Description</td> + </tr> + + <?php + $i = 0; + if($config['installedpackages']['package']) { + foreach ($config['installedpackages']['package'] as $pkg) { + if($pkg['name'] <> "") { + ?> + <tr valign="top"> + <td class="listlr"> + <?= $pkg['name'] ?> + </td> + <td class="listlr"> + <?= $pkg['category'] ?> + </td> + <td class="listbg"> + <font color="#FFFFFFF"> + <?= $pkg['descr'] ?> + </td> + <td valign="middle" class="list" nowrap> + <a href="pkg_mgr_delete.php?id=<?=$i;?>"><img src="x.gif" width="17" height="17" border="0"></a> + + </td> + </tr> + + <?php + $i++; + } + } + } + ?> + </table> + </td> + </tr> +</table> +</form> +<?php include("fend.inc"); ?> +</body> +</html> + + + + + + + + + + |