Project

General

Profile

Download (6.23 KB) Statistics
| Branch: | Tag: | Revision:
1 ee11cc6e Scott Ullrich
#!/usr/local/bin/php
2
<?php
3 b46bfcf5 Bill Marquette
/* $Id$ */
4 ee11cc6e Scott Ullrich
/*
5
    pkg_mgr_install.php
6 1548745b Scott Ullrich
    part of pfSense (http://www.pfSense.com)
7 9a2d499c Colin Smith
    Copyright (C) 2005 Scott Ullrich and Colin Smith
8 ee11cc6e Scott Ullrich
    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 9f9dcd98 Scott Ullrich
require_once("guiconfig.inc");
33
require_once("pkg-utils.inc");
34 ee11cc6e Scott Ullrich
35 9a2d499c Colin Smith
$static_output = "";
36
$static_status = "";
37
$sendto = "output";
38 8ccc8f1a Scott Ullrich
39 25cbd600 Scott Ullrich
$todo = array();
40
41 96d9f5c9 Bill Marquette
$pgtitle = "System: Package Manager: Install Package";
42 52380979 Scott Ullrich
include("head.inc");
43
44 ee11cc6e Scott Ullrich
?>
45
46
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
47 96d9f5c9 Bill Marquette
<?php include("fbegin.inc"); ?>
48
<p class="pgtitle"><?=$pgtitle?></p>
49 dd62c2d4 Scott Ullrich
<form action="pkg_mgr_install.php" method="post">
50 6cf08e20 Scott Ullrich
51 ee11cc6e Scott Ullrich
<?php if ($savemsg) print_info_box($savemsg); ?>
52
<?php
53
?>
54 4f409c9e Scott Ullrich
<div id="mainareapkg">
55 ee11cc6e Scott Ullrich
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
56 e3ebc979 Scott Ullrich
<?php
57
	$tab_array = array();
58
	$tab_array[0] = array("Available Packages", false, "pkg_mgr.php");
59 338ec5f4 Scott Ullrich
	$tab_array[1] = array("Installed Packages", false, "pkg_mgr_installed.php");
60
        $tab_array[2] = array("Package Installer", true, "");
61 e3ebc979 Scott Ullrich
	display_top_tabs($tab_array);
62
?>    
63 ee11cc6e Scott Ullrich
  </td></tr>
64
  <tr>
65
    <td class="tabcont">
66 71a85b21 Holger Bauer
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
67 ee11cc6e Scott Ullrich
               <tr>
68
                 <td>
69 8c304753 Colin Smith
		   <center>
70
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
71
				<tr>
72 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
73 8c304753 Colin Smith
					</td>
74
					<td>
75 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>
76 8c304753 Colin Smith
					</td>
77 677c0869 Erik Kristensen
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
78 8c304753 Colin Smith
					</td>
79
				</tr>
80
			</table>
81 c3fcf407 Scott Ullrich
                     <br>
82 b4ff3ccd Scott Ullrich
	             <!-- status box -->
83 9a2d499c Colin Smith
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
84 b4ff3ccd Scott Ullrich
                     <!-- command output box -->
85
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
86
                     </center>
87 ee11cc6e Scott Ullrich
                 </td>
88
               </tr>
89
        </table>
90
    </td>
91
  </tr>
92
</table>
93 323d040b Scott Ullrich
</div>
94 ee11cc6e Scott Ullrich
</form>
95
<?php include("fend.inc"); ?>
96 323d040b Scott Ullrich
97
<script type="text/javascript">
98
NiftyCheck();
99 4f409c9e Scott Ullrich
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
100 323d040b Scott Ullrich
</script>
101
102 ee11cc6e Scott Ullrich
</body>
103
</html>
104
105 323d040b Scott Ullrich
106 b4ff3ccd Scott Ullrich
<?php
107 91e58a1a Scott Ullrich
108
/* mount rw fs */
109
conf_mount_rw();
110
111 8d8f8970 Scott Ullrich
/* resync password database to avoid out of sync issues */
112 079948bd Scott Ullrich
sync_webgui_passwords();
113 8d8f8970 Scott Ullrich
114 e1531d00 Colin Smith
switch($_GET['mode']) {
115
	case "delete":
116 91e58a1a Scott Ullrich
            
117
            $id = get_pkg_id($_GET['pkg']);
118
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
119
            delete_package($todel);
120
            delete_package_xml($_GET['pkg']);
121
            update_status("Package deleted.");
122
            $static_output .= "\nPackage deleted.";
123
            update_output_window($static_output);
124
            break;
125 e1531d00 Colin Smith
	case "reinstallpkg":
126 91e58a1a Scott Ullrich
            $id = get_pkg_id($_GET['pkg']);
127
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
128
            delete_package($todel);
129
            delete_package_xml($_GET['pkg']);
130
            install_package($_GET['pkg']);
131
            update_status("Package reinstalled.");
132
            $static_output .= "\n\nPackage reinstalled.";
133
            update_output_window($static_output);
134
            break;
135 e1531d00 Colin Smith
	case "reinstallxml":
136 91e58a1a Scott Ullrich
            delete_package_xml($_GET['pkg']);
137
            install_package($_GET['pkg']);
138
            $static_output .= "\n\nPackage reinstalled.";
139
            update_output_window($static_output);
140
            break;
141 e1531d00 Colin Smith
	case "reinstallall":
142 a9dc5e11 Scott Ullrich
	    if($config['installedpackages']['package'] <> "")
143
			foreach($config['installedpackages']['package'] as $package) 
144
	                        $todo[] = array('name' => $package['name'], 'version' => $package['version']);
145 91e58a1a Scott Ullrich
            foreach($todo as $pkgtodo) {
146
                    $static_output = "";
147
                    update_output_window($static_output);
148
                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version']);
149
                    delete_package_xml($pkgtodo['name']);
150
                    install_package($pkgtodo['name']);
151
            }
152
            update_status("All packages reinstalled.");
153
            $static_output .= "\n\nAll packages reinstalled.";
154
            update_output_window($static_output);
155 7a13e63a Colin Smith
	    break;
156 e1531d00 Colin Smith
	default:
157 91e58a1a Scott Ullrich
            install_package($_GET['id']);
158
            update_status("Installation of {$_GET['id']} completed.");
159
            $static_output .= "\n\nInstallation completed.";
160
            update_output_window($static_output);
161 efd81869 Colin Smith
}
162 91e58a1a Scott Ullrich
163 58f130e4 Colin Smith
// Delete all temporary package tarballs and staging areas.
164
unlink_if_exists("/tmp/apkg_*");
165
rmdir_recursive("/var/tmp/instmp*");
166
167 91e58a1a Scott Ullrich
/* read only fs */
168
conf_mount_ro();
169
170 8ccc8f1a Scott Ullrich
// close log
171 276d1b95 Colin Smith
if($fd_log)
172
	fclose($fd_log);
173 8ccc8f1a Scott Ullrich
174 0035d7a6 Bill Marquette
?>