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 |
4f6a5e6a
|
Scott Ullrich
|
Copyright (C) 2004-2010 Scott Ullrich <sullrich@gmail.com>
|
7 |
|
|
Copyright (C) 2005 Colin Smith
|
8 |
ee11cc6e
|
Scott Ullrich
|
All rights reserved.
|
9 |
|
|
|
10 |
|
|
Redistribution and use in source and binary forms, with or without
|
11 |
|
|
modification, are permitted provided that the following conditions are met:
|
12 |
|
|
|
13 |
|
|
1. Redistributions of source code must retain the above copyright notice,
|
14 |
|
|
this list of conditions and the following disclaimer.
|
15 |
|
|
|
16 |
|
|
2. Redistributions in binary form must reproduce the above copyright
|
17 |
|
|
notice, this list of conditions and the following disclaimer in the
|
18 |
|
|
documentation and/or other materials provided with the distribution.
|
19 |
|
|
|
20 |
|
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
21 |
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
22 |
|
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
23 |
|
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
24 |
|
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25 |
|
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26 |
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27 |
|
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28 |
|
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29 |
|
|
POSSIBILITY OF SUCH DAMAGE.
|
30 |
|
|
*/
|
31 |
1d333258
|
Scott Ullrich
|
/*
|
32 |
|
|
pfSense_BUILDER_BINARIES: /bin/rm
|
33 |
|
|
pfSense_MODULE: pkgs
|
34 |
|
|
*/
|
35 |
ee11cc6e
|
Scott Ullrich
|
|
36 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
37 |
|
|
##|*IDENT=page-system-packagemanager-installpackage
|
38 |
|
|
##|*NAME=System: Package Manager: Install Package page
|
39 |
|
|
##|*DESCR=Allow access to the 'System: Package Manager: Install Package' page.
|
40 |
|
|
##|*MATCH=pkg_mgr_install.php*
|
41 |
|
|
##|-PRIV
|
42 |
|
|
|
43 |
0089af7c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
44 |
|
|
|
45 |
7a927e67
|
Scott Ullrich
|
require("guiconfig.inc");
|
46 |
|
|
require_once("functions.inc");
|
47 |
|
|
require_once("filter.inc");
|
48 |
|
|
require_once("shaper.inc");
|
49 |
9f9dcd98
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
50 |
ee11cc6e
|
Scott Ullrich
|
|
51 |
9a2d499c
|
Colin Smith
|
$static_output = "";
|
52 |
|
|
$static_status = "";
|
53 |
|
|
$sendto = "output";
|
54 |
8ccc8f1a
|
Scott Ullrich
|
|
55 |
25cbd600
|
Scott Ullrich
|
$todo = array();
|
56 |
|
|
|
57 |
0897ff7b
|
Renato Botelho
|
$pgtitle = array(gettext("System"),gettext("Package Manager"),gettext("Install Package"));
|
58 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
59 |
|
|
|
60 |
ee11cc6e
|
Scott Ullrich
|
?>
|
61 |
|
|
|
62 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
63 |
96d9f5c9
|
Bill Marquette
|
<?php include("fbegin.inc"); ?>
|
64 |
4c951cc9
|
Matthew Grooms
|
<form action="pkg_mgr_install.php" method="post">
|
65 |
|
|
<div id="mainareapkg">
|
66 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
67 |
8c304753
|
Colin Smith
|
<tr>
|
68 |
|
|
<td>
|
69 |
4c951cc9
|
Matthew Grooms
|
<?php
|
70 |
|
|
$version = file_get_contents("/etc/version");
|
71 |
|
|
$tab_array = array();
|
72 |
0897ff7b
|
Renato Botelho
|
$tab_array[] = array("{$version} " . gettext("packages"), false, "pkg_mgr.php");
|
73 |
ba6d3521
|
Scott Ullrich
|
// $tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
|
74 |
4c951cc9
|
Matthew Grooms
|
// $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
|
75 |
0897ff7b
|
Renato Botelho
|
$tab_array[] = array(gettext("Installed packages"), false, "pkg_mgr_installed.php");
|
76 |
|
|
$tab_array[] = array(gettext("Package Installer"), true, "");
|
77 |
4c951cc9
|
Matthew Grooms
|
display_top_tabs($tab_array);
|
78 |
|
|
?>
|
79 |
8c304753
|
Colin Smith
|
</td>
|
80 |
4c951cc9
|
Matthew Grooms
|
</tr>
|
81 |
|
|
<tr>
|
82 |
|
|
<td class="tabcont">
|
83 |
|
|
<center>
|
84 |
|
|
<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
85 |
|
|
<tr>
|
86 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
|
87 |
|
|
</td>
|
88 |
|
|
<td>
|
89 |
|
|
<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
90 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" valign="top" align="left">
|
91 |
|
|
<img src='./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
|
92 |
|
|
</td>
|
93 |
|
|
</table>
|
94 |
|
|
</td>
|
95 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
|
96 |
|
|
</td>
|
97 |
|
|
</tr>
|
98 |
|
|
</table>
|
99 |
|
|
<br>
|
100 |
|
|
<!-- status box -->
|
101 |
0897ff7b
|
Renato Botelho
|
<textarea cols="60" rows="1" name="status" id="status" wrap="hard"><?=gettext("Beginning package installation.");?></textarea>
|
102 |
4c951cc9
|
Matthew Grooms
|
<!-- command output box -->
|
103 |
f8a437b6
|
Bill Marquette
|
<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
|
104 |
4c951cc9
|
Matthew Grooms
|
</center>
|
105 |
8c304753
|
Colin Smith
|
</td>
|
106 |
|
|
</tr>
|
107 |
|
|
</table>
|
108 |
4c951cc9
|
Matthew Grooms
|
</div>
|
109 |
|
|
</form>
|
110 |
ee11cc6e
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
111 |
323d040b
|
Scott Ullrich
|
<script type="text/javascript">
|
112 |
|
|
NiftyCheck();
|
113 |
4f409c9e
|
Scott Ullrich
|
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
|
114 |
323d040b
|
Scott Ullrich
|
</script>
|
115 |
ee11cc6e
|
Scott Ullrich
|
</body>
|
116 |
|
|
</html>
|
117 |
|
|
|
118 |
323d040b
|
Scott Ullrich
|
|
119 |
b4ff3ccd
|
Scott Ullrich
|
<?php
|
120 |
91e58a1a
|
Scott Ullrich
|
|
121 |
a3af2487
|
Scott Ullrich
|
ob_flush();
|
122 |
|
|
|
123 |
864b3976
|
Scott Ullrich
|
// Write out configuration to creatae a backup prior to pkg install
|
124 |
0897ff7b
|
Renato Botelho
|
write_config(gettext("Creating restore point before package installation."));
|
125 |
864b3976
|
Scott Ullrich
|
|
126 |
91e58a1a
|
Scott Ullrich
|
/* mount rw fs */
|
127 |
|
|
conf_mount_rw();
|
128 |
|
|
|
129 |
e1531d00
|
Colin Smith
|
switch($_GET['mode']) {
|
130 |
|
|
case "delete":
|
131 |
4c951cc9
|
Matthew Grooms
|
$id = get_pkg_id($_GET['pkg']);
|
132 |
1570d27a
|
Ermal Lu?i
|
uninstall_package_from_name($_GET['pkg']);
|
133 |
0897ff7b
|
Renato Botelho
|
update_status(gettext("Package deleted."));
|
134 |
|
|
$static_output .= "\n" . gettext("Package deleted.");
|
135 |
4c951cc9
|
Matthew Grooms
|
update_output_window($static_output);
|
136 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
137 |
4c951cc9
|
Matthew Grooms
|
break;
|
138 |
af6f0a3a
|
Scott Ullrich
|
case "showlog":
|
139 |
4c951cc9
|
Matthew Grooms
|
$id = htmlspecialchars($_GET['pkg']);
|
140 |
|
|
if(strpos($id, "."))
|
141 |
|
|
exit;
|
142 |
|
|
update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
|
143 |
|
|
break;
|
144 |
e1531d00
|
Colin Smith
|
case "reinstallpkg":
|
145 |
4c951cc9
|
Matthew Grooms
|
$id = get_pkg_id(htmlspecialchars($_GET['pkg']));
|
146 |
|
|
delete_package_xml(htmlspecialchars($_GET['pkg']));
|
147 |
|
|
install_package(htmlspecialchars($_GET['pkg']));
|
148 |
0897ff7b
|
Renato Botelho
|
update_status(gettext("Package reinstalled."));
|
149 |
|
|
$static_output .= "\n\n" . gettext("Package reinstalled.");
|
150 |
4c951cc9
|
Matthew Grooms
|
start_service(htmlspecialchars($_GET['pkg']));
|
151 |
|
|
update_output_window($static_output);
|
152 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
153 |
4c951cc9
|
Matthew Grooms
|
break;
|
154 |
e1531d00
|
Colin Smith
|
case "reinstallxml":
|
155 |
4c951cc9
|
Matthew Grooms
|
delete_package_xml(htmlspecialchars($_GET['pkg']));
|
156 |
|
|
install_package(htmlspecialchars($_GET['pkg']));
|
157 |
0897ff7b
|
Renato Botelho
|
$static_output .= "\n\n" . gettext("Package reinstalled.");
|
158 |
4c951cc9
|
Matthew Grooms
|
start_service(htmlspecialchars($_GET['pkg']));
|
159 |
|
|
update_output_window($static_output);
|
160 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
161 |
4c951cc9
|
Matthew Grooms
|
break;
|
162 |
16654db5
|
Scott Ullrich
|
case "installedinfo":
|
163 |
|
|
$id = get_pkg_id(htmlspecialchars($_GET['pkg']));
|
164 |
|
|
if(file_exists("/tmp/{$_GET['pkg']}.info")) {
|
165 |
|
|
$filename = escapeshellcmd("/tmp/" . $_GET['pkg'] . ".info");
|
166 |
|
|
$status = file_get_contents($filename);
|
167 |
0897ff7b
|
Renato Botelho
|
update_status($_GET['pkg'] . " " . gettext("installation completed."));
|
168 |
16654db5
|
Scott Ullrich
|
update_output_window($status);
|
169 |
|
|
} else {
|
170 |
0897ff7b
|
Renato Botelho
|
update_output_window(gettext("Could not find") . " " . $_GET['pkg'] . ".");
|
171 |
16654db5
|
Scott Ullrich
|
}
|
172 |
|
|
break;
|
173 |
e1531d00
|
Colin Smith
|
case "reinstallall":
|
174 |
4c951cc9
|
Matthew Grooms
|
if ($config['installedpackages']['package'])
|
175 |
7ffeba59
|
Scott Ullrich
|
exec("rm -rf /var/db/pkg/*");
|
176 |
4c951cc9
|
Matthew Grooms
|
if (is_array($config['installedpackages']['package']))
|
177 |
|
|
foreach($config['installedpackages']['package'] as $package)
|
178 |
|
|
$todo[] = array('name' => $package['name'], 'version' => $package['version']);
|
179 |
|
|
$pkg_id = 0;
|
180 |
|
|
foreach($todo as $pkgtodo) {
|
181 |
|
|
$static_output = "";
|
182 |
|
|
if($pkgtodo['name']) {
|
183 |
|
|
update_output_window($static_output);
|
184 |
|
|
delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
|
185 |
|
|
delete_package_xml($pkgtodo['name']);
|
186 |
|
|
install_package($pkgtodo['name']);
|
187 |
|
|
$pkg_id++;
|
188 |
|
|
}
|
189 |
|
|
}
|
190 |
0897ff7b
|
Renato Botelho
|
update_status(gettext("All packages reinstalled."));
|
191 |
|
|
$static_output .= "\n\n" . gettext("All packages reinstalled.");
|
192 |
4c951cc9
|
Matthew Grooms
|
start_service(htmlspecialchars($_GET['pkg']));
|
193 |
|
|
update_output_window($static_output);
|
194 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
195 |
4c951cc9
|
Matthew Grooms
|
break;
|
196 |
e1531d00
|
Colin Smith
|
default:
|
197 |
4c951cc9
|
Matthew Grooms
|
$status = install_package(htmlspecialchars($_GET['id']));
|
198 |
|
|
if($status == -1) {
|
199 |
0897ff7b
|
Renato Botelho
|
update_status(gettext("Installation of") . " " . htmlspecialchars($_GET['id']) . " " . gettext("FAILED!"));
|
200 |
|
|
$static_output .= "\n\n" . gettext("Installation halted.");
|
201 |
16654db5
|
Scott Ullrich
|
update_output_window($static_output);
|
202 |
4c951cc9
|
Matthew Grooms
|
} else {
|
203 |
e2d15485
|
Scott Ullrich
|
$filename = escapeshellcmd("/tmp/" . $_GET['id'] . ".info");
|
204 |
16654db5
|
Scott Ullrich
|
$fd = fopen($filename, "w");
|
205 |
0897ff7b
|
Renato Botelho
|
$status_a = gettext("Installation of") . " " . htmlspecialchars($_GET['id']) . " " . gettext("completed.");
|
206 |
16654db5
|
Scott Ullrich
|
update_status($status_a);
|
207 |
cfde64b8
|
Scott Ullrich
|
$status = get_after_install_info($_GET['id']);
|
208 |
|
|
if($status)
|
209 |
0897ff7b
|
Renato Botelho
|
$static_output .= "\n" . gettext("Installation completed.") . "\n\n{$_GET['id']} " . gettext("setup instructions") . ":\n\n{$status}";
|
210 |
cfde64b8
|
Scott Ullrich
|
else
|
211 |
0897ff7b
|
Renato Botelho
|
$static_output .= "\n" . gettext("Installation completed. Please check to make sure that the package is configured from the respective menu then start the package.");
|
212 |
16654db5
|
Scott Ullrich
|
fwrite($fd, $status_a . "\n\n". $static_output);
|
213 |
|
|
fclose($fd);
|
214 |
|
|
echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['id']}\";</script>";
|
215 |
4c951cc9
|
Matthew Grooms
|
}
|
216 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
217 |
|
|
break;
|
218 |
efd81869
|
Colin Smith
|
}
|
219 |
91e58a1a
|
Scott Ullrich
|
|
220 |
58f130e4
|
Colin Smith
|
// Delete all temporary package tarballs and staging areas.
|
221 |
|
|
unlink_if_exists("/tmp/apkg_*");
|
222 |
|
|
rmdir_recursive("/var/tmp/instmp*");
|
223 |
|
|
|
224 |
8ccc8f1a
|
Scott Ullrich
|
// close log
|
225 |
276d1b95
|
Colin Smith
|
if($fd_log)
|
226 |
|
|
fclose($fd_log);
|
227 |
8ccc8f1a
|
Scott Ullrich
|
|
228 |
68347742
|
Ermal Lu?i
|
/* read only fs */
|
229 |
|
|
conf_mount_ro();
|
230 |
|
|
|
231 |
0897ff7b
|
Renato Botelho
|
?>
|