Project

General

Profile

Download (5.96 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
?>
42
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
43
<html>
44
<head>
45
<title><?=gentitle("System: Package Manager: Install Package");?></title>
46
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
47
<link href="gui.css" rel="stylesheet" type="text/css">
48
</head>
49

    
50
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
51
<?php
52
include("fbegin.inc");
53
?>
54
<p class="pgtitle">System: Package Manager: Install Package</p>
55
<form action="pkg_mgr_install.php" method="post">
56

    
57
<?php if ($savemsg) print_info_box($savemsg); ?>
58
<?php
59
?>
60
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
61
  <ul id="tabnav">
62
    <li class="tabinact"><a href="pkg_mgr.php">Available Packages</a></li>
63
    <li class="tabinact"><a href="pkg_mgr_installed.php">Installed Packages</a></li>
64
    <li class="tabact">Package Installer</li>
65
  </ul>
66
  </td></tr>
67
  <tr>
68
    <td class="tabcont">
69
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
70
               <tr>
71
                 <td>
72
		   <center>
73
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
74
				<tr>
75
					<td background="bar_left.gif" height='15' width='5'>
76
					</td>
77
					<td>
78
						<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>
79
					</td>
80
					<td background="bar_right.gif" height='15' width='5'>
81
					</td>
82
				</tr>
83
			</table>
84
                     <br>
85
	             <!-- status box -->
86
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
87
                     <!-- command output box -->
88
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
89
                     </center>
90
                 </td>
91
               </tr>
92
        </table>
93
    </td>
94
  </tr>
95
</table>
96
</form>
97
<?php include("fend.inc"); ?>
98
</body>
99
</html>
100

    
101
<?php
102

    
103
/* mount rw fs */
104
conf_mount_rw();
105

    
106
switch($_GET['mode']) {
107
	case "delete":
108
            
109
            $id = get_pkg_id($_GET['pkg']);
110
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
111
            delete_package($todel);
112
            delete_package_xml($_GET['pkg']);
113
            update_status("Package deleted.");
114
            $static_output .= "\nPackage deleted.";
115
            update_output_window($static_output);
116
            break;
117
	case "reinstallpkg":
118
            $id = get_pkg_id($_GET['pkg']);
119
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
120
            delete_package($todel);
121
            delete_package_xml($_GET['pkg']);
122
            install_package($_GET['pkg']);
123
            update_status("Package reinstalled.");
124
            $static_output .= "\n\nPackage reinstalled.";
125
            update_output_window($static_output);
126
            break;
127
	case "reinstallxml":
128
            delete_package_xml($_GET['pkg']);
129
            install_package($_GET['pkg']);
130
            $static_output .= "\n\nPackage reinstalled.";
131
            update_output_window($static_output);
132
            break;
133
	case "reinstallall":
134
            foreach($config['installedpackages']['package'] as $package) 
135
                    $todo[] = array('name' => $package['name'], 'version' => $package['version']);
136
            foreach($todo as $pkgtodo) {
137
                    $static_output = "";
138
                    update_output_window($static_output);
139
                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version']);
140
                    delete_package_xml($pkgtodo['name']);
141
                    install_package($pkgtodo['name']);
142
            }
143
            update_status("All packages reinstalled.");
144
            $static_output .= "\n\nAll packages reinstalled.";
145
            update_output_window($static_output);
146
    break;
147
	default:
148
            install_package($_GET['id']);
149
            update_status("Installation of {$_GET['id']} completed.");
150
            $static_output .= "\n\nInstallation completed.";
151
            update_output_window($static_output);
152
}
153

    
154
// Delete all temporary package tarballs and staging areas.
155
unlink_if_exists("/tmp/apkg_*");
156
rmdir_recursive("/var/tmp/instmp*");
157

    
158
/* read only fs */
159
conf_mount_ro();
160

    
161
// close log
162
fclose($fd_log);
163

    
164
?>
(64-64/121)