Project

General

Profile

Download (7.51 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
##|+PRIV
32
##|*IDENT=page-system-packagemanager-installpackage
33
##|*NAME=System: Package Manager: Install Package page
34
##|*DESCR=Allow access to the 'System: Package Manager: Install Package' page.
35
##|*MATCH=pkg_mgr_install.php*
36
##|-PRIV
37

    
38

    
39
require_once("guiconfig.inc");
40
require_once("pkg-utils.inc");
41

    
42
$static_output = "";
43
$static_status = "";
44
$sendto = "output";
45

    
46
$todo = array();
47

    
48
$pgtitle = array("System","Package Manager","Install Package");
49
include("head.inc");
50

    
51
?>
52

    
53
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
54
<?php include("fbegin.inc"); ?>
55
<form action="pkg_mgr_install.php" method="post">
56

    
57
<?php if ($savemsg) print_info_box($savemsg); ?>
58
<?php
59
?>
60
<div id="mainareapkg">
61
<table width="100%" border="0" cellpadding="0" cellspacing="0">  <tr><td>
62
<?php
63
	$version = file_get_contents("/etc/version");
64
	$tab_array = array();
65
	$tab_array[] = array("Available {$version} packages", false, "pkg_mgr.php");
66
	$tab_array[] = array("Packages for any platform", false, "pkg_mgr.php?ver=none");
67
/*  $tab_array[] = array("Packages for a different platform", $requested_version == "other" ? true : false, "pkg_mgr.php?ver=other"); */
68
	$tab_array[] = array("Installed packages", false, "pkg_mgr_installed.php");
69
  $tab_array[] = array("Package Installer", true, "");
70
	display_top_tabs($tab_array);
71
?>
72
  </td></tr>
73
  <tr>
74
    <td class="tabcont">
75
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
76
               <tr>
77
                 <td>
78
		   <center>
79
			<table height='15' width='420' border='0' colspacing='0' cellpadding='0' cellspacing='0'>
80
				<tr>
81
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_left.gif" height='15' width='5'>
82
					</td>
83
					<td>
84
						<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>
85
					</td>
86
					<td background="./themes/<?= $g['theme']; ?>/images/misc/bar_right.gif" height='15' width='5'>
87
					</td>
88
				</tr>
89
			</table>
90
                     <br>
91
	             <!-- status box -->
92
                     <textarea cols="60" rows="1" name="status" id="status" wrap="hard">Beginning package installation.</textarea>
93
                     <!-- command output box -->
94
	             <textarea cols="60" rows="25" name="output" id="output" wrap="hard"></textarea>
95
                     </center>
96
                 </td>
97
               </tr>
98
        </table>
99
    </td>
100
  </tr>
101
</table>
102
</div>
103
</form>
104
<?php include("fend.inc"); ?>
105

    
106
<script type="text/javascript">
107
NiftyCheck();
108
Rounded("div#mainareapkg","bl br","#FFF","#eeeeee","smooth");
109
</script>
110

    
111
</body>
112
</html>
113

    
114

    
115
<?php
116

    
117
ob_flush();
118

    
119
/* mount rw fs */
120
conf_mount_rw();
121

    
122
switch($_GET['mode']) {
123
	case "delete":
124
            $id = get_pkg_id($_GET['pkg']);
125
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
126
            delete_package($todel, htmlspecialchars($_GET['pkg']));
127
            delete_package_xml(htmlspecialchars($_GET['pkg']));
128
            update_status("Package deleted.");
129
            $static_output .= "\nPackage deleted.";
130
            update_output_window($static_output);
131
            break;
132
	case "showlog":
133
          $id = htmlspecialchars($_GET['pkg']);
134
		  if(strpos($id, "."))	
135
				exit;
136
			update_output_window(file_get_contents("/tmp/pkg_mgr_{$id}.log"));
137
			break;
138
	case "reinstallpkg":
139
            $id = get_pkg_id(htmlspecialchars($_GET['pkg']));
140
            $todel = substr(reverse_strrchr($config['installedpackages']['package'][$id]['depends_on_package'], "."), 0, -1);
141
            delete_package($todel, htmlspecialchars($_GET['pkg']));
142
            delete_package_xml(htmlspecialchars($_GET['pkg']));
143
            install_package(htmlspecialchars($_GET['pkg']));
144
            update_status("Package reinstalled.");
145
            $static_output .= "\n\nPackage reinstalled.";
146
            start_service(htmlspecialchars($_GET['pkg']));
147
            update_output_window($static_output);
148
            break;
149
	case "reinstallxml":
150
            delete_package_xml(htmlspecialchars($_GET['pkg']));
151
            install_package(htmlspecialchars($_GET['pkg']));
152
            $static_output .= "\n\nPackage reinstalled.";
153
            start_service(htmlspecialchars($_GET['pkg']));
154
            update_output_window($static_output);
155
            break;
156
	case "reinstallall":
157
	    if($config['installedpackages']['package'] <> "")
158
			exec("rm -rf /var/db/pkg/*");
159
			foreach($config['installedpackages']['package'] as $package)
160
				$todo[] = array('name' => $package['name'], 'version' => $package['version']);
161
			$pkg_id = 0;
162
            foreach($todo as $pkgtodo) {
163
                    $static_output = "";
164
					if($pkgtodo['name']) {
165
	                    update_output_window($static_output);
166
	                    delete_package($pkgtodo['name'] . '-' . $pkgtodo['version'], $pkg_id);
167
	                    delete_package_xml($pkgtodo['name']);
168
	                    install_package($pkgtodo['name']);
169
						$pkg_id++;
170
					}
171
            }
172
            update_status("All packages reinstalled.");
173
            $static_output .= "\n\nAll packages reinstalled.";
174
            start_service(htmlspecialchars($_GET['pkg']));
175
            update_output_window($static_output);
176
	    break;
177
	default:
178
            $status = install_package(htmlspecialchars($_GET['id']));
179
	    if($status == -1) {
180
		update_status("Installation of " . htmlspecialchars($_GET['id']) . " FAILED!");
181
                $static_output .= "\n\nInstallation halted.";
182
	    } else {
183
			update_status("Installation of " . htmlspecialchars($_GET['id']) . " completed.");
184
			$static_output .= "\n\nInstallation completed.   Please check to make sure that the package is configured from the respective menu then start the package.";
185
	    }
186
	    update_output_window($static_output);
187

    
188
}
189

    
190
// Delete all temporary package tarballs and staging areas.
191
unlink_if_exists("/tmp/apkg_*");
192
rmdir_recursive("/var/tmp/instmp*");
193

    
194
/* read only fs */
195
conf_mount_ro();
196

    
197
// close log
198
if($fd_log)
199
	fclose($fd_log);
200

    
201
?>
(106-106/209)