Project

General

Profile

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

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

    
104
</body>
105
</html>
106

    
107
<?php
108

    
109
ob_flush();
110

    
111
// Write out configuration to creatae a backup prior to pkg install
112
write_config("Creating restore point before package installation.");
113

    
114
/* mount rw fs */
115
conf_mount_rw();
116

    
117
/* resync password database to avoid out of sync issues */
118
sync_webgui_passwords();
119

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

    
187
}
188

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

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

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

    
200
?>
(92-92/174)