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 |
1d333258
|
Scott Ullrich
|
/*
|
31 |
|
|
pfSense_BUILDER_BINARIES: /bin/rm
|
32 |
|
|
pfSense_MODULE: pkgs
|
33 |
|
|
*/
|
34 |
ee11cc6e
|
Scott Ullrich
|
|
35 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
36 |
|
|
##|*IDENT=page-system-packagemanager-installpackage
|
37 |
|
|
##|*NAME=System: Package Manager: Install Package page
|
38 |
|
|
##|*DESCR=Allow access to the 'System: Package Manager: Install Package' page.
|
39 |
|
|
##|*MATCH=pkg_mgr_install.php*
|
40 |
|
|
##|-PRIV
|
41 |
|
|
|
42 |
0089af7c
|
Scott Ullrich
|
ini_set('max_execution_time', '0');
|
43 |
|
|
|
44 |
7a927e67
|
Scott Ullrich
|
require("guiconfig.inc");
|
45 |
|
|
require_once("functions.inc");
|
46 |
|
|
require_once("filter.inc");
|
47 |
|
|
require_once("shaper.inc");
|
48 |
9f9dcd98
|
Scott Ullrich
|
require_once("pkg-utils.inc");
|
49 |
ee11cc6e
|
Scott Ullrich
|
|
50 |
9a2d499c
|
Colin Smith
|
$static_output = "";
|
51 |
|
|
$static_status = "";
|
52 |
|
|
$sendto = "output";
|
53 |
8ccc8f1a
|
Scott Ullrich
|
|
54 |
25cbd600
|
Scott Ullrich
|
$todo = array();
|
55 |
|
|
|
56 |
d88c6a9f
|
Scott Ullrich
|
$pgtitle = array("System","Package Manager","Install Package");
|
57 |
52380979
|
Scott Ullrich
|
include("head.inc");
|
58 |
|
|
|
59 |
ee11cc6e
|
Scott Ullrich
|
?>
|
60 |
|
|
|
61 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
62 |
96d9f5c9
|
Bill Marquette
|
<?php include("fbegin.inc"); ?>
|
63 |
4c951cc9
|
Matthew Grooms
|
<form action="pkg_mgr_install.php" method="post">
|
64 |
|
|
<div id="mainareapkg">
|
65 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
66 |
8c304753
|
Colin Smith
|
<tr>
|
67 |
|
|
<td>
|
68 |
4c951cc9
|
Matthew Grooms
|
<?php
|
69 |
|
|
$version = file_get_contents("/etc/version");
|
70 |
|
|
$tab_array = array();
|
71 |
ba6d3521
|
Scott Ullrich
|
$tab_array[] = array("{$version} packages", false, "pkg_mgr.php");
|
72 |
|
|
// $tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
|
73 |
4c951cc9
|
Matthew Grooms
|
// $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
|
74 |
|
|
$tab_array[] = array("Installed packages", false, "pkg_mgr_installed.php");
|
75 |
|
|
$tab_array[] = array("Package Installer", true, "");
|
76 |
|
|
display_top_tabs($tab_array);
|
77 |
|
|
?>
|
78 |
8c304753
|
Colin Smith
|
</td>
|
79 |
4c951cc9
|
Matthew Grooms
|
</tr>
|
80 |
|
|
<tr>
|
81 |
|
|
<td class="tabcont">
|
82 |
|
|
<center>
|
83 |
|
|
<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
84 |
|
|
<tr>
|
85 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
|
86 |
|
|
</td>
|
87 |
|
|
<td>
|
88 |
|
|
<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
89 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_gray.gif" valign="top" align="left">
|
90 |
|
|
<img src='./themes/<?= $g['theme']; ?>/images/misc/bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'>
|
91 |
|
|
</td>
|
92 |
|
|
</table>
|
93 |
|
|
</td>
|
94 |
|
|
<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
|
95 |
|
|
</td>
|
96 |
|
|
</tr>
|
97 |
|
|
</table>
|
98 |
|
|
<br>
|
99 |
|
|
<!-- status box -->
|
100 |
f8a437b6
|
Bill Marquette
|
<textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
|
101 |
4c951cc9
|
Matthew Grooms
|
<!-- command output box -->
|
102 |
f8a437b6
|
Bill Marquette
|
<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
|
103 |
4c951cc9
|
Matthew Grooms
|
</center>
|
104 |
8c304753
|
Colin Smith
|
</td>
|
105 |
|
|
</tr>
|
106 |
|
|
</table>
|
107 |
4c951cc9
|
Matthew Grooms
|
</div>
|
108 |
|
|
</form>
|
109 |
ee11cc6e
|
Scott Ullrich
|
<?php include("fend.inc"); ?>
|
110 |
323d040b
|
Scott Ullrich
|
<script type="text/javascript">
|
111 |
|
|
NiftyCheck();
|
112 |
4f409c9e
|
Scott Ullrich
|
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
|
113 |
323d040b
|
Scott Ullrich
|
</script>
|
114 |
ee11cc6e
|
Scott Ullrich
|
</body>
|
115 |
|
|
</html>
|
116 |
|
|
|
117 |
323d040b
|
Scott Ullrich
|
|
118 |
b4ff3ccd
|
Scott Ullrich
|
<?php
|
119 |
91e58a1a
|
Scott Ullrich
|
|
120 |
a3af2487
|
Scott Ullrich
|
ob_flush();
|
121 |
|
|
|
122 |
864b3976
|
Scott Ullrich
|
// Write out configuration to creatae a backup prior to pkg install
|
123 |
|
|
write_config("Creating restore point before package installation.");
|
124 |
|
|
|
125 |
91e58a1a
|
Scott Ullrich
|
/* mount rw fs */
|
126 |
|
|
conf_mount_rw();
|
127 |
|
|
|
128 |
e1531d00
|
Colin Smith
|
switch($_GET['mode']) {
|
129 |
|
|
case "delete":
|
130 |
4c951cc9
|
Matthew Grooms
|
$id = get_pkg_id($_GET['pkg']);
|
131 |
1570d27a
|
Ermal Lu?i
|
uninstall_package_from_name($_GET['pkg']);
|
132 |
4c951cc9
|
Matthew Grooms
|
update_status("Package deleted.");
|
133 |
|
|
$static_output .= "\nPackage deleted.";
|
134 |
|
|
update_output_window($static_output);
|
135 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
136 |
4c951cc9
|
Matthew Grooms
|
break;
|
137 |
af6f0a3a
|
Scott Ullrich
|
case "showlog":
|
138 |
4c951cc9
|
Matthew Grooms
|
$id = htmlspecialchars($_GET['pkg']);
|
139 |
|
|
if(strpos($id, "."))
|
140 |
|
|
exit;
|
141 |
|
|
update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
|
142 |
|
|
break;
|
143 |
e1531d00
|
Colin Smith
|
case "reinstallpkg":
|
144 |
4c951cc9
|
Matthew Grooms
|
$id = get_pkg_id(htmlspecialchars($_GET['pkg']));
|
145 |
|
|
delete_package_xml(htmlspecialchars($_GET['pkg']));
|
146 |
|
|
install_package(htmlspecialchars($_GET['pkg']));
|
147 |
|
|
update_status("Package reinstalled.");
|
148 |
|
|
$static_output .= "\n\nPackage reinstalled.";
|
149 |
|
|
start_service(htmlspecialchars($_GET['pkg']));
|
150 |
|
|
update_output_window($static_output);
|
151 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
152 |
4c951cc9
|
Matthew Grooms
|
break;
|
153 |
e1531d00
|
Colin Smith
|
case "reinstallxml":
|
154 |
4c951cc9
|
Matthew Grooms
|
delete_package_xml(htmlspecialchars($_GET['pkg']));
|
155 |
|
|
install_package(htmlspecialchars($_GET['pkg']));
|
156 |
|
|
$static_output .= "\n\nPackage reinstalled.";
|
157 |
|
|
start_service(htmlspecialchars($_GET['pkg']));
|
158 |
|
|
update_output_window($static_output);
|
159 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
160 |
4c951cc9
|
Matthew Grooms
|
break;
|
161 |
16654db5
|
Scott Ullrich
|
case "installedinfo":
|
162 |
|
|
$id = get_pkg_id(htmlspecialchars($_GET['pkg']));
|
163 |
|
|
if(file_exists("/tmp/{$_GET['pkg']}.info")) {
|
164 |
|
|
$filename = escapeshellcmd("/tmp/" . $_GET['pkg'] . ".info");
|
165 |
|
|
$status = file_get_contents($filename);
|
166 |
|
|
update_status($_GET['pkg'] . " installation completed.");
|
167 |
|
|
update_output_window($status);
|
168 |
|
|
} else {
|
169 |
|
|
update_output_window("Could not find {$_GET['pkg']}.");
|
170 |
|
|
}
|
171 |
|
|
break;
|
172 |
e1531d00
|
Colin Smith
|
case "reinstallall":
|
173 |
4c951cc9
|
Matthew Grooms
|
if ($config['installedpackages']['package'])
|
174 |
7ffeba59
|
Scott Ullrich
|
exec("rm -rf /var/db/pkg/*");
|
175 |
4c951cc9
|
Matthew Grooms
|
if (is_array($config['installedpackages']['package']))
|
176 |
|
|
foreach($config['installedpackages']['package'] as $package)
|
177 |
|
|
$todo[] = array('name' => $package['name'], 'version' => $package['version']);
|
178 |
|
|
$pkg_id = 0;
|
179 |
|
|
foreach($todo as $pkgtodo) {
|
180 |
|
|
$static_output = "";
|
181 |
|
|
if($pkgtodo['name']) {
|
182 |
|
|
update_output_window($static_output);
|
183 |
|
|
delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
|
184 |
|
|
delete_package_xml($pkgtodo['name']);
|
185 |
|
|
install_package($pkgtodo['name']);
|
186 |
|
|
$pkg_id++;
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
update_status("All packages reinstalled.");
|
190 |
|
|
$static_output .= "\n\nAll packages reinstalled.";
|
191 |
|
|
start_service(htmlspecialchars($_GET['pkg']));
|
192 |
|
|
update_output_window($static_output);
|
193 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
194 |
4c951cc9
|
Matthew Grooms
|
break;
|
195 |
e1531d00
|
Colin Smith
|
default:
|
196 |
4c951cc9
|
Matthew Grooms
|
$status = install_package(htmlspecialchars($_GET['id']));
|
197 |
|
|
if($status == -1) {
|
198 |
|
|
update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!");
|
199 |
|
|
$static_output .= "\n\nInstallation halted.";
|
200 |
16654db5
|
Scott Ullrich
|
update_output_window($static_output);
|
201 |
4c951cc9
|
Matthew Grooms
|
} else {
|
202 |
e2d15485
|
Scott Ullrich
|
$filename = escapeshellcmd("/tmp/" . $_GET['id'] . ".info");
|
203 |
16654db5
|
Scott Ullrich
|
$fd = fopen($filename, "w");
|
204 |
|
|
$status_a = "Installation of " . htmlspecialchars($_GET['id']) . " completed.";
|
205 |
|
|
update_status($status_a);
|
206 |
cfde64b8
|
Scott Ullrich
|
$status = get_after_install_info($_GET['id']);
|
207 |
|
|
if($status)
|
208 |
|
|
$static_output .= "\nInstallation completed.\n\n{$_GET['id']} setup instructions:\n\n{$status}";
|
209 |
|
|
else
|
210 |
|
|
$static_output .= "\nInstallation completed. Please check to make sure that the package is configured from the respective menu then start the package.";
|
211 |
16654db5
|
Scott Ullrich
|
fwrite($fd, $status_a . "\n\n". $static_output);
|
212 |
|
|
fclose($fd);
|
213 |
|
|
echo "<script type='text/javascript'>document.location=\"pkg_mgr_install.php?mode=installedinfo&pkg={$_GET['id']}\";</script>";
|
214 |
4c951cc9
|
Matthew Grooms
|
}
|
215 |
f69d50ce
|
Ermal Lu?i
|
filter_configure();
|
216 |
|
|
break;
|
217 |
efd81869
|
Colin Smith
|
}
|
218 |
91e58a1a
|
Scott Ullrich
|
|
219 |
58f130e4
|
Colin Smith
|
// Delete all temporary package tarballs and staging areas.
|
220 |
|
|
unlink_if_exists("/tmp/apkg_*");
|
221 |
|
|
rmdir_recursive("/var/tmp/instmp*");
|
222 |
|
|
|
223 |
8ccc8f1a
|
Scott Ullrich
|
// close log
|
224 |
276d1b95
|
Colin Smith
|
if($fd_log)
|
225 |
|
|
fclose($fd_log);
|
226 |
8ccc8f1a
|
Scott Ullrich
|
|
227 |
68347742
|
Ermal Lu?i
|
/* read only fs */
|
228 |
|
|
conf_mount_ro();
|
229 |
|
|
|
230 |
f69d50ce
|
Ermal Lu?i
|
?>
|