Project

General

Profile

Download (7.51 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
<?php
2 b46bfcf5 Bill Marquette
/* $Id$ */
3 ee11cc6e Scott Ullrich
/*
4
    pkg_mgr_install.php
5 1548745b Scott Ullrich
    part of pfSense (http://www.pfSense.com)
6 9a2d499c Colin Smith
    Copyright (C) 2005 Scott Ullrich and Colin Smith
7 ee11cc6e Scott Ullrich
    All rights reserved.
8
9
    Redistribution and use in source and binary forms, with or without
10
    modification, are permitted provided that the following conditions are met:
11
12
    1. Redistributions of source code must retain the above copyright notice,
13
       this list of conditions and the following disclaimer.
14
15
    2. Redistributions in binary form must reproduce the above copyright
16
       notice, this list of conditions and the following disclaimer in the
17
       documentation and/or other materials provided with the distribution.
18
19
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
    POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31 6b07c15a Matthew Grooms
##|+PRIV
32
##|*IDENT=page-system-packagemanager-installpackage
33
##|*NAME=System: Package Manager: Install Package page
34
##|*DESCR=Allow access to the 'System: Package Manager: Install Package' page.
35
##|*MATCH=pkg_mgr_install.php*
36
##|-PRIV
37
38
39 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
40
require_once("pkg-utils.inc");
41 ee11cc6e Scott Ullrich
42 9a2d499c Colin Smith
$static_output = "";
43
$static_status = "";
44
$sendto = "output";
45 8ccc8f1a Scott Ullrich
46 25cbd600 Scott Ullrich
$todo = array();
47
48 d88c6a9f Scott Ullrich
$pgtitle = array("System","Package Manager","Install Package");
49 52380979 Scott Ullrich
include("head.inc");
50
51 ee11cc6e Scott Ullrich
?>
52
53
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
54 96d9f5c9 Bill Marquette
<?php include("fbegin.inc"); ?>
55 dd62c2d4 Scott Ullrich
<form action="pkg_mgr_install.php" method="post">
56 6cf08e20 Scott Ullrich
57 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
58
<?php
59
?>
60 4f409c9e Scott Ullrich
<div id="mainareapkg">
61 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
62 e3ebc979 Scott Ullrich
<?php
63 61a48553 Scott Ullrich
	$version = file_get_contents("/etc/version");
64 e3ebc979 Scott Ullrich
	$tab_array = array();
65 64b243d2 Scott Ullrich
	$tab_array[] = array("Available {$version} packages", false, "pkg_mgr.php");
66
	$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
67
/*  $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
68
	$tab_array[] = array("Installed packages", false, "pkg_mgr_installed.php");
69
  $tab_array[] = array("Package Installer", true, "");
70 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
71 5bd87465 Scott Ullrich
?>
72 ee11cc6e Scott Ullrich
  </td></tr>
73
  <tr>
74
    <td class="tabcont">
75 71a85b21 Holger Bauer
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
76 ee11cc6e Scott Ullrich
               <tr>
77
                 <td>
78 8c304753 Colin Smith
		   <center>
79
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
80
				<tr>
81 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
82 8c304753 Colin Smith
					</td>
83
					<td>
84 30af342f Erik Kristensen
						<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'><td background="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" valign="top" align="left"><img src='./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'></td></table>
85 8c304753 Colin Smith
					</td>
86 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
87 8c304753 Colin Smith
					</td>
88
				</tr>
89
			</table>
90 c3fcf407 Scott Ullrich
                     <br>
91 b4ff3ccd Scott Ullrich
	             <!-- status box -->
92 9a2d499c Colin Smith
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
93 b4ff3ccd Scott Ullrich
                     <!-- command output box -->
94
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
95
                     </center>
96 ee11cc6e Scott Ullrich
                 </td>
97
               </tr>
98
        </table>
99
    </td>
100
  </tr>
101
</table>
102 323d040b Scott Ullrich
</div>
103 ee11cc6e Scott Ullrich
</form>
104
<?php include("fend.inc"); ?>
105 323d040b Scott Ullrich
106
<script type="text/javascript">
107
NiftyCheck();
108 4f409c9e Scott Ullrich
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
109 323d040b Scott Ullrich
</script>
110
111 ee11cc6e Scott Ullrich
</body>
112
</html>
113
114 323d040b Scott Ullrich
115 b4ff3ccd Scott Ullrich
<?php
116 91e58a1a Scott Ullrich
117 a3af2487 Scott Ullrich
ob_flush();
118
119 91e58a1a Scott Ullrich
/* mount rw fs */
120
conf_mount_rw();
121
122 e1531d00 Colin Smith
switch($_GET['mode']) {
123
	case "delete":
124 91e58a1a Scott Ullrich
            $id = get_pkg_id($_GET['pkg']);
125
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
126 d8c1a6c5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
127
            delete_package_xml(htmlspecialchars($_GET['pkg']));
128 91e58a1a Scott Ullrich
            update_status("Package deleted.");
129
            $static_output .= "\nPackage deleted.";
130
            update_output_window($static_output);
131
            break;
132 af6f0a3a Scott Ullrich
	case "showlog":
133
          $id = htmlspecialchars($_GET['pkg']);
134
		  if(strpos($id, "."))	
135
				exit;
136
			update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
137
			break;
138 e1531d00 Colin Smith
	case "reinstallpkg":
139 d8c1a6c5 Scott Ullrich
            $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
140 91e58a1a Scott Ullrich
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
141 d8c1a6c5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
142
            delete_package_xml(htmlspecialchars($_GET['pkg']));
143
            install_package(htmlspecialchars($_GET['pkg']));
144 91e58a1a Scott Ullrich
            update_status("Package reinstalled.");
145
            $static_output .= "\n\nPackage reinstalled.";
146 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
147 880e1525 Scott Ullrich
            update_output_window($static_output);
148 91e58a1a Scott Ullrich
            break;
149 e1531d00 Colin Smith
	case "reinstallxml":
150 d8c1a6c5 Scott Ullrich
            delete_package_xml(htmlspecialchars($_GET['pkg']));
151
            install_package(htmlspecialchars($_GET['pkg']));
152 91e58a1a Scott Ullrich
            $static_output .= "\n\nPackage reinstalled.";
153 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
154 880e1525 Scott Ullrich
            update_output_window($static_output);
155 91e58a1a Scott Ullrich
            break;
156 e1531d00 Colin Smith
	case "reinstallall":
157 a9dc5e11 Scott Ullrich
	    if($config['installedpackages']['package'] <> "")
158 7ffeba59 Scott Ullrich
			exec("rm -rf /var/db/pkg/*");
159 5bd87465 Scott Ullrich
			foreach($config['installedpackages']['package'] as $package)
160 7ffeba59 Scott Ullrich
				$todo[] = array('name' => $package['name'], 'version' => $package['version']);
161 7fa5fd2c Scott Ullrich
			$pkg_id = 0;
162 91e58a1a Scott Ullrich
            foreach($todo as $pkgtodo) {
163
                    $static_output = "";
164 7ffeba59 Scott Ullrich
					if($pkgtodo['name']) {
165
	                    update_output_window($static_output);
166
	                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
167
	                    delete_package_xml($pkgtodo['name']);
168
	                    install_package($pkgtodo['name']);
169
						$pkg_id++;
170
					}
171 91e58a1a Scott Ullrich
            }
172
            update_status("All packages reinstalled.");
173
            $static_output .= "\n\nAll packages reinstalled.";
174 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
175 880e1525 Scott Ullrich
            update_output_window($static_output);
176 7a13e63a Colin Smith
	    break;
177 e1531d00 Colin Smith
	default:
178 d8c1a6c5 Scott Ullrich
            $status = install_package(htmlspecialchars($_GET['id']));
179 f9b205f3 Scott Ullrich
	    if($status == -1) {
180 d8c1a6c5 Scott Ullrich
		update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!");
181 5bd87465 Scott Ullrich
                $static_output .= "\n\nInstallation halted.";
182 f9b205f3 Scott Ullrich
	    } else {
183 d8c1a6c5 Scott Ullrich
			update_status("Installation of " . htmlspecialchars($_GET['id']) . " completed.");
184 880e1525 Scott Ullrich
			$static_output .= "\n\nInstallation completed.   Please check to make sure that the package is configured from the respective menu then start the package.";
185 f9b205f3 Scott Ullrich
	    }
186
	    update_output_window($static_output);
187
188 efd81869 Colin Smith
}
189 91e58a1a Scott Ullrich
190 58f130e4 Colin Smith
// Delete all temporary package tarballs and staging areas.
191
unlink_if_exists("/tmp/apkg_*");
192
rmdir_recursive("/var/tmp/instmp*");
193
194 91e58a1a Scott Ullrich
/* read only fs */
195
conf_mount_ro();
196
197 8ccc8f1a Scott Ullrich
// close log
198 276d1b95 Colin Smith
if($fd_log)
199
	fclose($fd_log);
200 8ccc8f1a Scott Ullrich
201 61a48553 Scott Ullrich
?>