Project

General

Profile

Download (5.91 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="mainarea">
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="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="bar_gray.gif" valign="top" align="left"><img src='bar_blue.gif' width='0' height='15' name='progressbar' id='progressbar'></td></table>
76
					</td>
77
					<td background="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#mainarea","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
switch($_GET['mode']) {
112
	case "delete":
113
            
114
            $id = get_pkg_id($_GET['pkg']);
115
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
116
            delete_package($todel);
117
            delete_package_xml($_GET['pkg']);
118
            update_status("Package deleted.");
119
            $static_output .= "\nPackage deleted.";
120
            update_output_window($static_output);
121
            break;
122
	case "reinstallpkg":
123
            $id = get_pkg_id($_GET['pkg']);
124
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
125
            delete_package($todel);
126
            delete_package_xml($_GET['pkg']);
127
            install_package($_GET['pkg']);
128
            update_status("Package reinstalled.");
129
            $static_output .= "\n\nPackage reinstalled.";
130
            update_output_window($static_output);
131
            break;
132
	case "reinstallxml":
133
            delete_package_xml($_GET['pkg']);
134
            install_package($_GET['pkg']);
135
            $static_output .= "\n\nPackage reinstalled.";
136
            update_output_window($static_output);
137
            break;
138
	case "reinstallall":
139
            foreach($config['installedpackages']['package'] as $package) 
140
                    $todo[] = array('name' => $package['name'], 'version' => $package['version']);
141
            foreach($todo as $pkgtodo) {
142
                    $static_output = "";
143
                    update_output_window($static_output);
144
                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version']);
145
                    delete_package_xml($pkgtodo['name']);
146
                    install_package($pkgtodo['name']);
147
            }
148
            update_status("All packages reinstalled.");
149
            $static_output .= "\n\nAll packages reinstalled.";
150
            update_output_window($static_output);
151
    break;
152
	default:
153
            install_package($_GET['id']);
154
            update_status("Installation of {$_GET['id']} completed.");
155
            $static_output .= "\n\nInstallation completed.";
156
            update_output_window($static_output);
157
}
158

    
159
// Delete all temporary package tarballs and staging areas.
160
unlink_if_exists("/tmp/apkg_*");
161
rmdir_recursive("/var/tmp/instmp*");
162

    
163
/* read only fs */
164
conf_mount_ro();
165

    
166
// close log
167
fclose($fd_log);
168

    
169
?>
(68-68/128)