Project

General

Profile

Download (7.52 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 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
32
require_once("pkg-utils.inc");
33 ee11cc6e Scott Ullrich
34 9a2d499c Colin Smith
$static_output = "";
35
$static_status = "";
36
$sendto = "output";
37 8ccc8f1a Scott Ullrich
38 25cbd600 Scott Ullrich
$todo = array();
39
40 96d9f5c9 Bill Marquette
$pgtitle = "System: Package Manager: Install Package";
41 52380979 Scott Ullrich
include("head.inc");
42
43 ee11cc6e Scott Ullrich
?>
44
45
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
46 96d9f5c9 Bill Marquette
<?php include("fbegin.inc"); ?>
47
<p class="pgtitle"><?=$pgtitle?></p>
48 dd62c2d4 Scott Ullrich
<form action="pkg_mgr_install.php" method="post">
49 6cf08e20 Scott Ullrich
50 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
51
<?php
52
?>
53 4f409c9e Scott Ullrich
<div id="mainareapkg">
54 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
55 e3ebc979 Scott Ullrich
<?php
56 61a48553 Scott Ullrich
	$version = file_get_contents("/etc/version");
57 e3ebc979 Scott Ullrich
	$tab_array = array();
58 7b3154d5 Scott Ullrich
	$tab_array[] = array("{$version} packages", false, "pkg_mgr.php");
59
//	$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
60
//  $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other");
61 64b243d2 Scott Ullrich
	$tab_array[] = array("Installed packages", false, "pkg_mgr_installed.php");
62 7b3154d5 Scott Ullrich
  	$tab_array[] = array("Package Installer", true, "");
63 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
64 5bd87465 Scott Ullrich
?>
65 ee11cc6e Scott Ullrich
  </td></tr>
66
  <tr>
67
    <td class="tabcont">
68 71a85b21 Holger Bauer
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
69 ee11cc6e Scott Ullrich
               <tr>
70
                 <td>
71 8c304753 Colin Smith
		   <center>
72
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
73
				<tr>
74 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
75 8c304753 Colin Smith
					</td>
76
					<td>
77 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>
78 8c304753 Colin Smith
					</td>
79 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
80 8c304753 Colin Smith
					</td>
81
				</tr>
82
			</table>
83 c3fcf407 Scott Ullrich
                     <br>
84 b4ff3ccd Scott Ullrich
	             <!-- status box -->
85 9a2d499c Colin Smith
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
86 b4ff3ccd Scott Ullrich
                     <!-- command output box -->
87
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
88
                     </center>
89 ee11cc6e Scott Ullrich
                 </td>
90
               </tr>
91
        </table>
92
    </td>
93
  </tr>
94
</table>
95 323d040b Scott Ullrich
</div>
96 ee11cc6e Scott Ullrich
</form>
97
<?php include("fend.inc"); ?>
98 323d040b Scott Ullrich
99
<script type="text/javascript">
100
NiftyCheck();
101 4f409c9e Scott Ullrich
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
102 323d040b Scott Ullrich
</script>
103
104 ee11cc6e Scott Ullrich
</body>
105
</html>
106
107 b4ff3ccd Scott Ullrich
<?php
108 91e58a1a Scott Ullrich
109 a3af2487 Scott Ullrich
ob_flush();
110
111 4cac6f77 Scott Ullrich
// Write out configuration to creatae a backup prior to pkg install
112
write_config("Creating restore point before package installation.");
113
114 91e58a1a Scott Ullrich
/* mount rw fs */
115
conf_mount_rw();
116
117 8d8f8970 Scott Ullrich
/* resync password database to avoid out of sync issues */
118 079948bd Scott Ullrich
sync_webgui_passwords();
119 8d8f8970 Scott Ullrich
120 4b14ae30 Scott Ullrich
// Note: sync_webgui_passwords() will send the image to RO on Nano.
121
conf_mount_rw();
122
123 e1531d00 Colin Smith
switch($_GET['mode']) {
124
	case "delete":
125 b5aebbf5 Scott Ullrich
            $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
126 91e58a1a Scott Ullrich
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
127 b5aebbf5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
128
            delete_package_xml(htmlspecialchars($_GET['pkg']));
129 91e58a1a Scott Ullrich
            update_status("Package deleted.");
130
            $static_output .= "\nPackage deleted.";
131
            update_output_window($static_output);
132
            break;
133 5b4062dc Scott Ullrich
	case "showlog":
134
            $id = htmlspecialchars($_GET['pkg']);
135
			if(strpos($id, "."))	
136
				exit;
137
			update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
138
			break;
139 e1531d00 Colin Smith
	case "reinstallpkg":
140 b5aebbf5 Scott Ullrich
            $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
141 91e58a1a Scott Ullrich
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
142 b5aebbf5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
143
            delete_package_xml(htmlspecialchars($_GET['pkg']));
144
            install_package(htmlspecialchars($_GET['pkg']));
145 91e58a1a Scott Ullrich
            update_status("Package reinstalled.");
146
            $static_output .= "\n\nPackage reinstalled.";
147 b5aebbf5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
148 880e1525 Scott Ullrich
            update_output_window($static_output);
149 91e58a1a Scott Ullrich
            break;
150 e1531d00 Colin Smith
	case "reinstallxml":
151 b5aebbf5 Scott Ullrich
            delete_package_xml(htmlspecialchars($_GET['pkg']));
152
            install_package(htmlspecialchars($_GET['pkg']));
153 91e58a1a Scott Ullrich
            $static_output .= "\n\nPackage reinstalled.";
154 b5aebbf5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
155 880e1525 Scott Ullrich
            update_output_window($static_output);
156 91e58a1a Scott Ullrich
            break;
157 e1531d00 Colin Smith
	case "reinstallall":
158 28118e6b Scott Ullrich
		    if($config['installedpackages']['package'])
159 d01e6aee Scott Ullrich
				exec("rm -rf /var/db/pkg/*");
160 28118e6b Scott Ullrich
		    if($config['installedpackages']['package'])
161
				foreach($config['installedpackages']['package'] as $package)
162
					$todo[] = array('name' => $package['name'], 'version' => $package['version']);
163 0af52dfc Scott Ullrich
			$pkg_id = 0;
164 d01e6aee Scott Ullrich
			foreach($todo as $pkgtodo) {
165
				$static_output = "";
166
				if($pkgtodo['name']) {
167
						update_output_window($static_output);
168
						delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
169
						delete_package_xml($pkgtodo['name']);
170
						install_package($pkgtodo['name']);
171
						$pkg_id++;
172
					}
173
			}
174
			update_status("All packages reinstalled.");
175
			$static_output .= "\n\nAll packages reinstalled.";
176
			start_service(htmlspecialchars($_GET['pkg']));
177
			update_output_window($static_output);
178 7a13e63a Colin Smith
	    break;
179 d01e6aee Scott Ullrich
		default:
180 b5aebbf5 Scott Ullrich
            $status = install_package(htmlspecialchars($_GET['id']));
181 f9b205f3 Scott Ullrich
	    if($status == -1) {
182 b5aebbf5 Scott Ullrich
		update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!");
183 5bd87465 Scott Ullrich
                $static_output .= "\n\nInstallation halted.";
184 f9b205f3 Scott Ullrich
	    } else {
185 b5aebbf5 Scott Ullrich
			update_status("Installation of " . $_GET['id'] ." completed.");
186 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.";
187 f9b205f3 Scott Ullrich
	    }
188
	    update_output_window($static_output);
189
190 efd81869 Colin Smith
}
191 91e58a1a Scott Ullrich
192 58f130e4 Colin Smith
// Delete all temporary package tarballs and staging areas.
193
unlink_if_exists("/tmp/apkg_*");
194
rmdir_recursive("/var/tmp/instmp*");
195
196 91e58a1a Scott Ullrich
/* read only fs */
197
conf_mount_ro();
198
199 8ccc8f1a Scott Ullrich
// close log
200 276d1b95 Colin Smith
if($fd_log)
201
	fclose($fd_log);
202 8ccc8f1a Scott Ullrich
203 61a48553 Scott Ullrich
?>