Project

General

Profile

Download (7.13 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 d88c6a9f Scott Ullrich
$pgtitle = array("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 dd62c2d4 Scott Ullrich
<form action="pkg_mgr_install.php" method="post">
48 6cf08e20 Scott Ullrich
49 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
50
<?php
51
?>
52 4f409c9e Scott Ullrich
<div id="mainareapkg">
53 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
54 e3ebc979 Scott Ullrich
<?php
55 61a48553 Scott Ullrich
	$version = file_get_contents("/etc/version");
56 e3ebc979 Scott Ullrich
	$tab_array = array();
57 64b243d2 Scott Ullrich
	$tab_array[] = array("Available {$version} packages", false, "pkg_mgr.php");
58
	$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
59
/*  $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
60
	$tab_array[] = array("Installed packages", false, "pkg_mgr_installed.php");
61
  $tab_array[] = array("Package Installer", true, "");
62 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
63 5bd87465 Scott Ullrich
?>
64 ee11cc6e Scott Ullrich
  </td></tr>
65
  <tr>
66
    <td class="tabcont">
67 71a85b21 Holger Bauer
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
68 ee11cc6e Scott Ullrich
               <tr>
69
                 <td>
70 8c304753 Colin Smith
		   <center>
71
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
72
				<tr>
73 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
74 8c304753 Colin Smith
					</td>
75
					<td>
76 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>
77 8c304753 Colin Smith
					</td>
78 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
79 8c304753 Colin Smith
					</td>
80
				</tr>
81
			</table>
82 c3fcf407 Scott Ullrich
                     <br>
83 b4ff3ccd Scott Ullrich
	             <!-- status box -->
84 9a2d499c Colin Smith
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
85 b4ff3ccd Scott Ullrich
                     <!-- command output box -->
86
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
87
                     </center>
88 ee11cc6e Scott Ullrich
                 </td>
89
               </tr>
90
        </table>
91
    </td>
92
  </tr>
93
</table>
94 323d040b Scott Ullrich
</div>
95 ee11cc6e Scott Ullrich
</form>
96
<?php include("fend.inc"); ?>
97 323d040b Scott Ullrich
98
<script type="text/javascript">
99
NiftyCheck();
100 4f409c9e Scott Ullrich
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
101 323d040b Scott Ullrich
</script>
102
103 ee11cc6e Scott Ullrich
</body>
104
</html>
105
106 323d040b Scott Ullrich
107 b4ff3ccd Scott Ullrich
<?php
108 91e58a1a Scott Ullrich
109 a3af2487 Scott Ullrich
ob_flush();
110
111 91e58a1a Scott Ullrich
/* mount rw fs */
112
conf_mount_rw();
113
114 8d8f8970 Scott Ullrich
/* resync password database to avoid out of sync issues */
115 079948bd Scott Ullrich
sync_webgui_passwords();
116 8d8f8970 Scott Ullrich
117 e1531d00 Colin Smith
switch($_GET['mode']) {
118
	case "delete":
119 91e58a1a Scott Ullrich
            $id = get_pkg_id($_GET['pkg']);
120
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
121 d8c1a6c5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
122
            delete_package_xml(htmlspecialchars($_GET['pkg']));
123 91e58a1a Scott Ullrich
            update_status("Package deleted.");
124
            $static_output .= "\nPackage deleted.";
125
            update_output_window($static_output);
126
            break;
127 e1531d00 Colin Smith
	case "reinstallpkg":
128 d8c1a6c5 Scott Ullrich
            $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
129 91e58a1a Scott Ullrich
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
130 d8c1a6c5 Scott Ullrich
            delete_package($todel, htmlspecialchars($_GET['pkg']));
131
            delete_package_xml(htmlspecialchars($_GET['pkg']));
132
            install_package(htmlspecialchars($_GET['pkg']));
133 91e58a1a Scott Ullrich
            update_status("Package reinstalled.");
134
            $static_output .= "\n\nPackage reinstalled.";
135 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
136 880e1525 Scott Ullrich
            update_output_window($static_output);
137 91e58a1a Scott Ullrich
            break;
138 e1531d00 Colin Smith
	case "reinstallxml":
139 d8c1a6c5 Scott Ullrich
            delete_package_xml(htmlspecialchars($_GET['pkg']));
140
            install_package(htmlspecialchars($_GET['pkg']));
141 91e58a1a Scott Ullrich
            $static_output .= "\n\nPackage reinstalled.";
142 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
143 880e1525 Scott Ullrich
            update_output_window($static_output);
144 91e58a1a Scott Ullrich
            break;
145 e1531d00 Colin Smith
	case "reinstallall":
146 a9dc5e11 Scott Ullrich
	    if($config['installedpackages']['package'] <> "")
147 5bd87465 Scott Ullrich
			foreach($config['installedpackages']['package'] as $package)
148 a9dc5e11 Scott Ullrich
	                        $todo[] = array('name' => $package['name'], 'version' => $package['version']);
149 7fa5fd2c Scott Ullrich
			$pkg_id = 0;
150 91e58a1a Scott Ullrich
            foreach($todo as $pkgtodo) {
151
                    $static_output = "";
152
                    update_output_window($static_output);
153 7fa5fd2c Scott Ullrich
                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
154 91e58a1a Scott Ullrich
                    delete_package_xml($pkgtodo['name']);
155
                    install_package($pkgtodo['name']);
156 7fa5fd2c Scott Ullrich
					$pkg_id++;
157 91e58a1a Scott Ullrich
            }
158
            update_status("All packages reinstalled.");
159
            $static_output .= "\n\nAll packages reinstalled.";
160 d8c1a6c5 Scott Ullrich
            start_service(htmlspecialchars($_GET['pkg']));
161 880e1525 Scott Ullrich
            update_output_window($static_output);
162 7a13e63a Colin Smith
	    break;
163 e1531d00 Colin Smith
	default:
164 d8c1a6c5 Scott Ullrich
            $status = install_package(htmlspecialchars($_GET['id']));
165 f9b205f3 Scott Ullrich
	    if($status == -1) {
166 d8c1a6c5 Scott Ullrich
		update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!");
167 5bd87465 Scott Ullrich
                $static_output .= "\n\nInstallation halted.";
168 f9b205f3 Scott Ullrich
	    } else {
169 d8c1a6c5 Scott Ullrich
			update_status("Installation of " . htmlspecialchars($_GET['id']) . " completed.");
170 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.";
171 f9b205f3 Scott Ullrich
	    }
172
	    update_output_window($static_output);
173
174 efd81869 Colin Smith
}
175 91e58a1a Scott Ullrich
176 58f130e4 Colin Smith
// Delete all temporary package tarballs and staging areas.
177
unlink_if_exists("/tmp/apkg_*");
178
rmdir_recursive("/var/tmp/instmp*");
179
180 91e58a1a Scott Ullrich
/* read only fs */
181
conf_mount_ro();
182
183 8ccc8f1a Scott Ullrich
// close log
184 276d1b95 Colin Smith
if($fd_log)
185
	fclose($fd_log);
186 8ccc8f1a Scott Ullrich
187 61a48553 Scott Ullrich
?>