1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
pkg_mgr_install.php
|
5
|
part of pfSense (http://www.pfSense.com)
|
6
|
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
7
|
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
|
pfSense_BUILDER_BINARIES: /bin/rm
|
32
|
pfSense_MODULE: pkgs
|
33
|
*/
|
34
|
|
35
|
##|+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
|
ini_set('max_execution_time', '0');
|
43
|
|
44
|
require("guiconfig.inc");
|
45
|
require_once("functions.inc");
|
46
|
require_once("filter.inc");
|
47
|
require_once("shaper.inc");
|
48
|
require_once("pkg-utils.inc");
|
49
|
|
50
|
$static_output = "";
|
51
|
$static_status = "";
|
52
|
$sendto = "output";
|
53
|
|
54
|
$todo = array();
|
55
|
|
56
|
$pgtitle = array("System","Package Manager","Install Package");
|
57
|
include("head.inc");
|
58
|
|
59
|
?>
|
60
|
|
61
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
62
|
<?php include("fbegin.inc"); ?>
|
63
|
<form action="pkg_mgr_install.php" method="post">
|
64
|
<div id="mainareapkg">
|
65
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
66
|
<tr>
|
67
|
<td>
|
68
|
<?php
|
69
|
$version = file_get_contents("/etc/version");
|
70
|
$tab_array = array();
|
71
|
$tab_array[] = array("{$version} packages", false, "pkg_mgr.php");
|
72
|
// $tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
|
73
|
// $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
|
</td>
|
79
|
</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
|
<textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
|
101
|
<!-- command output box -->
|
102
|
<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
|
103
|
</center>
|
104
|
</td>
|
105
|
</tr>
|
106
|
</table>
|
107
|
</div>
|
108
|
</form>
|
109
|
<?php include("fend.inc"); ?>
|
110
|
<script type="text/javascript">
|
111
|
NiftyCheck();
|
112
|
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
|
113
|
</script>
|
114
|
</body>
|
115
|
</html>
|
116
|
|
117
|
|
118
|
<?php
|
119
|
|
120
|
ob_flush();
|
121
|
|
122
|
// Write out configuration to creatae a backup prior to pkg install
|
123
|
write_config("Creating restore point before package installation.");
|
124
|
|
125
|
/* mount rw fs */
|
126
|
conf_mount_rw();
|
127
|
|
128
|
switch($_GET['mode']) {
|
129
|
case "delete":
|
130
|
$id = get_pkg_id($_GET['pkg']);
|
131
|
uninstall_package_from_name($_GET['pkg']);
|
132
|
update_status("Package deleted.");
|
133
|
$static_output .= "\nPackage deleted.";
|
134
|
update_output_window($static_output);
|
135
|
filter_configure();
|
136
|
break;
|
137
|
case "showlog":
|
138
|
$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
|
case "reinstallpkg":
|
144
|
$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
|
filter_configure();
|
152
|
break;
|
153
|
case "reinstallxml":
|
154
|
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
|
filter_configure();
|
160
|
break;
|
161
|
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
|
case "reinstallall":
|
173
|
if ($config['installedpackages']['package'])
|
174
|
exec("rm -rf /var/db/pkg/*");
|
175
|
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
|
filter_configure();
|
194
|
break;
|
195
|
default:
|
196
|
$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
|
update_output_window($static_output);
|
201
|
} else {
|
202
|
$filename = escapeshellcmd("/tmp/" . $_GET['id'] . ".info");
|
203
|
$fd = fopen($filename, "w");
|
204
|
$status_a = "Installation of " . htmlspecialchars($_GET['id']) . " completed.";
|
205
|
update_status($status_a);
|
206
|
$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
|
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
|
}
|
215
|
filter_configure();
|
216
|
break;
|
217
|
}
|
218
|
|
219
|
// Delete all temporary package tarballs and staging areas.
|
220
|
unlink_if_exists("/tmp/apkg_*");
|
221
|
rmdir_recursive("/var/tmp/instmp*");
|
222
|
|
223
|
// close log
|
224
|
if($fd_log)
|
225
|
fclose($fd_log);
|
226
|
|
227
|
/* read only fs */
|
228
|
conf_mount_ro();
|
229
|
|
230
|
?>
|