1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/* $Id$ */
|
4
|
/*
|
5
|
pkg_mgr_install.php
|
6
|
part of pfSense (http://www.pfSense.com)
|
7
|
Copyright (C) 2005 Scott Ullrich and Colin Smith
|
8
|
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
|
|
32
|
require_once("guiconfig.inc");
|
33
|
require_once("xmlparse_pkg.inc");
|
34
|
require_once("pkg-utils.inc");
|
35
|
|
36
|
$static_output = "";
|
37
|
$static_status = "";
|
38
|
$sendto = "output";
|
39
|
|
40
|
?>
|
41
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
42
|
<html>
|
43
|
<head>
|
44
|
<title><?=gentitle("System: Package Manager: Install Package");?></title>
|
45
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
46
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
47
|
</head>
|
48
|
|
49
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
50
|
<?php
|
51
|
include("fbegin.inc");
|
52
|
?>
|
53
|
<p class="pgtitle">System: Package Manager: Install Package</p>
|
54
|
<form action="pkg_mgr_install.php" method="post">
|
55
|
|
56
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
57
|
<?php
|
58
|
?>
|
59
|
<table width="100%" border="0" cellpadding="0" cellspacing="0"> <tr><td>
|
60
|
<ul id="tabnav">
|
61
|
<li class="tabinact"><a href="pkg_mgr.php">Available Packages</a></li>
|
62
|
<li class="tabinact"><a href="pkg_mgr_installed.php">Installed Packages</a></li>
|
63
|
<li class="tabact">Package Installer</li>
|
64
|
</ul>
|
65
|
</td></tr>
|
66
|
<tr>
|
67
|
<td class="tabcont">
|
68
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
69
|
<tr>
|
70
|
<td>
|
71
|
<center>
|
72
|
<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
|
73
|
<tr>
|
74
|
<td background="bar_left.gif" height='15' width='5'>
|
75
|
</td>
|
76
|
<td>
|
77
|
<table id="progholder" name="progholder" height='15' width='410' border='0' colspacing='0' cellpadding='0' cellspacing='0'><td background="bar_gray.gif" valign="top" align="left"><img src='bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'></td></table>
|
78
|
</td>
|
79
|
<td background="bar_right.gif" height='15' width='5'>
|
80
|
</td>
|
81
|
</tr>
|
82
|
</table>
|
83
|
<br>
|
84
|
<!-- status box -->
|
85
|
<textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
|
86
|
<!-- command output box -->
|
87
|
<textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
|
88
|
</center>
|
89
|
</td>
|
90
|
</tr>
|
91
|
</table>
|
92
|
</td>
|
93
|
</tr>
|
94
|
</table>
|
95
|
</form>
|
96
|
<?php include("fend.inc"); ?>
|
97
|
</body>
|
98
|
</html>
|
99
|
|
100
|
<?php
|
101
|
switch($_GET['mode']) {
|
102
|
case "delete":
|
103
|
$id = get_pkg_id($_GET['pkg']);
|
104
|
$todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
|
105
|
delete_package($todel);
|
106
|
delete_package_xml($_GET['pkg']);
|
107
|
update_status("Package deleted.");
|
108
|
$static_output .= "\nPackage deleted.";
|
109
|
update_output_window($static_output);
|
110
|
break;
|
111
|
case "reinstallpkg":
|
112
|
$id = get_pkg_id($_GET['pkg']);
|
113
|
$todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
|
114
|
delete_package($todel);
|
115
|
delete_package_xml($_GET['pkg']);
|
116
|
install_package($_GET['pkg']);
|
117
|
update_status("Package reinstalled.");
|
118
|
$static_output .= "\n\nPackage reinstalled.";
|
119
|
update_output_window($static_output);
|
120
|
break;
|
121
|
case "reinstallxml":
|
122
|
delete_package_xml($_GET['pkg']);
|
123
|
install_package($_GET['pkg']);
|
124
|
$static_output .= "\n\nPackage reinstalled.";
|
125
|
update_output_window($static_output);
|
126
|
break;
|
127
|
case "reinstallall":
|
128
|
foreach($config['installedpackages']['package'] as $package) {
|
129
|
$todo[] = array('name' => $package['name'], 'version' => $package['version']);
|
130
|
}
|
131
|
foreach($todo as $pkgtodo) {
|
132
|
$static_output = "";
|
133
|
update_output_window($static_output);
|
134
|
delete_package($pkgtodo['name'] . '-' . $pkgtodo['version']);
|
135
|
delete_package_xml($pkgtodo['name']);
|
136
|
install_package($pkgtodo['name']);
|
137
|
}
|
138
|
update_status("All packages reinstalled.");
|
139
|
$static_output .= "\n\nAll packages reinstalled.";
|
140
|
update_output_window($static_output);
|
141
|
break;
|
142
|
default:
|
143
|
install_package($_GET['id']);
|
144
|
update_status("Installation of {$_GET['id']} completed.");
|
145
|
$static_output .= "\n\nInstallation completed.";
|
146
|
update_output_window($static_output);
|
147
|
}
|
148
|
// Delete all temporary package tarballs and staging areas.
|
149
|
unlink_if_exists("/tmp/apkg_*");
|
150
|
rmdir_recursive("/var/tmp/instmp*");
|
151
|
|
152
|
// close log
|
153
|
fclose($fd_log);
|
154
|
|
155
|
?>
|