Project

General

Profile

Download (6.83 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	diag_nanobsd.php
4
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
5
	All rights reserved.
6

    
7
	Redistribution and use in source and binary forms, with or without
8
	modification, are permitted provided that the following conditions are met:
9

    
10
	1. Redistributions of source code must retain the above copyright notice,
11
	   this list of conditions and the following disclaimer.
12

    
13
	2. Redistributions in binary form must reproduce the above copyright
14
	   notice, this list of conditions and the following disclaimer in the
15
	   documentation and/or other materials provided with the distribution.
16

    
17
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
18
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
19
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
20
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
21
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26
	POSSIBILITY OF SUCH DAMAGE.
27
*/
28

    
29
/*	
30
	pfSense_BUILDER_BINARIES:	/sbin/mount	/sbin/glabel	/usr/bin/grep	/usr/bin/cut	/usr/bin/head	/bin/cp
31
	pfSense_BUILDER_BINARIES:	/usr/sbin/boot0cfg	/bin/mkdir	/sbin/fsck_ufs	/sbin/mount	/sbin/sysctl	/bin/dd	/sbin/tunefs
32
	pfSense_MODULE:	nanobsd
33
*/
34

    
35
##|+PRIV
36
##|*IDENT=page-diagnostics-nanobsd
37
##|*NAME=Diagnostics: NanoBSD
38
##|*DESCR=Allow access to the 'Diagnostics: NanoBSD' page.
39
##|*MATCH=diag_nanobsd.php*
40
##|-PRIV
41

    
42
ini_set('zlib.output_compression', 0);
43
ini_set('implicit_flush', 1);
44
ini_set('max_input_time', '9999');
45

    
46
require_once("guiconfig.inc");
47
require_once("config.inc");
48

    
49
$pgtitle = array("Diagnostics","NanoBSD");
50
include("head.inc");
51

    
52
// Survey slice info
53
global $SLICE, $OLDSLICE, $TOFLASH, $COMPLETE_PATH, $COMPLETE_BOOT_PATH;
54
global $GLABEL_SLICE, $UFS_ID, $OLD_UFS_ID, $BOOTFLASH;
55
global $BOOT_DEVICE, $REAL_BOOT_DEVICE, $BOOT_DRIVE, $ACTIVE_SLICE;
56
nanobsd_detect_slice_info();
57

    
58
?>
59

    
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?=$jsevents["body"]["onload"];?>">
61
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
62

    
63
<?php include("fbegin.inc"); ?>
64

    
65
<?php
66

    
67
$NANOBSD_SIZE = nanobsd_get_size();
68

    
69
if($_POST['bootslice']) {
70
	echo <<<EOF
71
	 	<div id="loading">
72
			<img src="/themes/metallic/images/misc/loader.gif"> 
73
			Setting slice information, please wait...
74
			<p/>&nbsp;
75
		</div>
76
EOF;
77
	nanobsd_switch_boot_slice();
78
	$savemsg = "The boot slice has been set to " . nanobsd_get_active_slice();
79
	// Survey slice info
80
	nanobsd_detect_slice_info();
81

    
82
}
83

    
84
if($_POST['destslice']) {
85
echo <<<EOF
86
 	<div id="loading">
87
		<img src="/themes/metallic/images/misc/loader.gif">
88
		Duplicating slice.  Please wait, this will take a moment...
89
		<p/>&nbsp;
90
	</div>
91
EOF;
92
	if(nanobsd_clone_slice($_POST['destslice'])) {
93
		$savemsg = "The slice has been duplicated.<p/>If you would like to boot from this newly duplicated slice please set it using the bootup information area.";
94
	} else {
95
		$savemsg = "There was an error while duplicating the slice.  Operation aborted.";
96
	}
97
	// Re-Survey slice info
98
	nanobsd_detect_slice_info();
99
}
100

    
101
if ($savemsg)
102
	print_info_box($savemsg)
103

    
104
?>
105
<table width="100%" border="0" cellpadding="0" cellspacing="0">
106
	<tr>
107
		<td>
108
			<!-- tabs here if you want them -->
109
		</td>
110
	</tr>
111
	<tr>
112
		<td id="mainarea">
113
			<div class="tabcont">
114
				<span class="vexpl">
115
					<span class="red">
116
						<strong>NOTE:&nbsp</strong>
117
					</span>
118
					The options on this page are intended for use by advanced users only.
119
					<br/>&nbsp;
120
				</span>
121
				<p/>
122
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
123
					<tr>
124
						<td colspan="2" valign="top" class="listtopic">Bootup information</td>
125
					</tr>
126
					<tr>						
127
						<td width="22%" valign="top" class="vncell">NanoBSD Image size</td>
128
						<td width="78%" class="vtable">
129
							<?php echo $NANOBSD_SIZE; ?>
130
						</td>
131
					</tr>
132
					<tr>
133
						<td width="22%" valign="top" class="vncell">Bootup</td>
134
						<td width="78%" class="vtable">
135
							<form action="diag_nanobsd.php" method="post" name="iform">
136
								Bootup slice is currently: <?php echo $ACTIVE_SLICE; ?>
137
								<br/><br/>This will switch the bootup slice to the alternate slice.
138
								<br/>
139
								<input type='hidden' name='bootslice' value='switch'>
140
								<input type='submit' value='Switch Slice'></form>
141
						</td>
142
					</tr>
143
					<tr>
144
						<td colspan="2" valign="top" class="">&nbsp;</td>
145
					</tr>					
146
					<tr>
147
						<td colspan="2" valign="top" class="listtopic">Duplicate bootup slice to alternate</td>
148
					</tr>
149
					<tr>
150
						<td width="22%" valign="top" class="vncell">Duplicate bootup slice</td>
151
						<td width="78%" class="vtable">
152
							<form action="diag_nanobsd.php" method="post" name="iform">						
153
								Destination slice:							
154
								<select name='destslice'>
155
									<option value='<?php echo $COMPLETE_PATH; ?>'>
156
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
157
									</option>
158
								</select>
159
								<br/>
160
								This will duplicate the bootup slice to the alternate slice.  Use this if you would like to duplicate the known good working boot partition to the alternate.
161
						</td>
162
					</tr>
163
					<tr>
164
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Duplicate slice'></form></td>
165
					</tr>
166
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
167
					<tr>
168
						<td colspan="2" valign="top" class="">&nbsp;</td>
169
					</tr>					
170
					<tr>
171
						<td colspan="2" valign="top" class="listtopic">View upgrade log</td>
172
					</tr>
173
					<tr>
174
						<td width="22%" valign="top" class="vncell">View previous upgrade log</td>
175
						<td width="78%" class="vtable">
176
						<?php
177
							if($_POST['viewupgradelog']) {
178
								echo "<textarea name='log' cols='80' rows='40'>";
179
								echo file_get_contents("/conf/upgrade_log.txt");
180
								echo "\nFile list:\n";
181
								echo file_get_contents("/conf/file_upgrade_log.txt");
182
								echo "\nMisc log:\n";
183
								echo file_get_contents("/conf/firmware_update_misc.log");
184
								echo "\nfdisk/bsdlabel log:\n";
185
								echo file_get_contents("/conf/fdisk_upgrade_log.txt");
186
								echo "</textarea>";
187
							} else {
188
								echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
189
								echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
190
							}
191
						?>
192
						</td>
193
					</tr>
194
<?php endif; ?>
195
					<tr>
196
						<td colspan="2" valign="top" class="">&nbsp;</td>
197
					</tr>					
198
				</table>
199
			</div>
200
		</td>
201
	</tr>
202
</table>
203
<?php require("fend.inc"); ?>
204
</body>
205
</html>
206

    
207
<?php
208

    
209
// Clear the loading indicator
210
echo "<script type=\"text/javascript\">";
211
echo "$('loading').innerHTML = '';";
212
echo "</script>";	
213

    
214
?>
(27-27/216)