Project

General

Profile

Download (6.88 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 = array("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
<form action="pkg_mgr_install.php" method="post">
48

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

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

    
103
</body>
104
</html>
105

    
106

    
107
<?php
108

    
109
ob_flush();
110

    
111
/* mount rw fs */
112
conf_mount_rw();
113

    
114
/* resync password database to avoid out of sync issues */
115
sync_webgui_passwords();
116

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

    
174
}
175

    
176
// Delete all temporary package tarballs and staging areas.
177
unlink_if_exists("/tmp/apkg_*");
178
rmdir_recursive("/var/tmp/instmp*");
179

    
180
/* read only fs */
181
conf_mount_ro();
182

    
183
// close log
184
if($fd_log)
185
	fclose($fd_log);
186

    
187
?>
(95-95/187)