Project

General

Profile

Download (6.39 KB) Statistics
| Branch: | Tag: | Revision:
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
require_once("guiconfig.inc");
32
require_once("pkg-utils.inc");
33

    
34
$static_output = "";
35
$static_status = "";
36
$sendto = "output";
37

    
38
$todo = array();
39

    
40
$pgtitle = "System: Package Manager: Install Package";
41
include("head.inc");
42

    
43
?>
44

    
45
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
46
<?php include("fbegin.inc"); ?>
47
<p class="pgtitle"><?=$pgtitle?></p>
48
<form action="pkg_mgr_install.php" method="post">
49

    
50
<?php if ($savemsg) print_info_box($savemsg); ?>
51
<?php
52
?>
53
<div id="mainareapkg">
54
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
55
<?php
56
	$tab_array = array();
57
	$tab_array[0] = array("Available Packages", false, "pkg_mgr.php");
58
	$tab_array[1] = array("Installed Packages", false, "pkg_mgr_installed.php");
59
        $tab_array[2] = array("Package Installer", true, "");
60
	display_top_tabs($tab_array);
61
?>    
62
  </td></tr>
63
  <tr>
64
    <td class="tabcont">
65
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
66
               <tr>
67
                 <td>
68
		   <center>
69
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
70
				<tr>
71
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
72
					</td>
73
					<td>
74
						<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>
75
					</td>
76
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
77
					</td>
78
				</tr>
79
			</table>
80
                     <br>
81
	             <!-- status box -->
82
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
83
                     <!-- command output box -->
84
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
85
                     </center>
86
                 </td>
87
               </tr>
88
        </table>
89
    </td>
90
  </tr>
91
</table>
92
</div>
93
</form>
94
<?php include("fend.inc"); ?>
95

    
96
<script type="text/javascript">
97
NiftyCheck();
98
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
99
</script>
100

    
101
</body>
102
</html>
103

    
104

    
105
<?php
106

    
107
ob_flush();
108

    
109
/* mount rw fs */
110
conf_mount_rw();
111

    
112
/* resync password database to avoid out of sync issues */
113
sync_webgui_passwords();
114

    
115
switch($_GET['mode']) {
116
	case "delete":
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, $_GET['pkg']);
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
	case "reinstallpkg":
126
            $id = get_pkg_id($_GET['pkg']);
127
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
128
            delete_package($todel, $_GET['pkg']);
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
	case "reinstallxml":
136
            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
	case "reinstallall":
142
	    if($config['installedpackages']['package'] <> "")
143
			foreach($config['installedpackages']['package'] as $package) 
144
	                        $todo[] = array('name' => $package['name'], 'version' => $package['version']);
145
            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
	    break;
156
	default:
157
            $status = install_package($_GET['id']);
158
	    if($status == -1) {
159
		update_status("Installation of {$_GET['id']} FAILED!");
160
                $static_output .= "\n\nInstallation halted.";		
161
	    } else {
162
                update_status("Installation of {$_GET['id']} completed.");
163
		$static_output .= "\n\nInstallation completed.";
164
	    }
165
	    update_output_window($static_output);
166

    
167
}
168

    
169
// Delete all temporary package tarballs and staging areas.
170
unlink_if_exists("/tmp/apkg_*");
171
rmdir_recursive("/var/tmp/instmp*");
172

    
173
/* read only fs */
174
conf_mount_ro();
175

    
176
// close log
177
if($fd_log)
178
	fclose($fd_log);
179

    
180
?>
(85-85/163)