Project

General

Profile

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

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

    
39
$todo = array();
40

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

    
44
?>
45

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

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

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

    
102
</body>
103
</html>
104

    
105

    
106
<?php
107

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

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

    
114
switch($_GET['mode']) {
115
	case "delete":
116
            
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
	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);
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
?>
(81-81/153)