Project

General

Profile

Download (7.15 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_set_boot_slice($_POST['bootslice']);
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:
137
								<select name='bootslice'>
138
									<option value='<?php echo $BOOTFLASH; ?>'<?php if ($BOOTFLASH == $ACTIVE_SLICE) {?> selected<?php } ?>>
139
										<?php echo $BOOTFLASH; ?>
140
									</option>
141
									<option value='<?php echo $TOFLASH; ?>'<?php if ($TOFLASH == $ACTIVE_SLICE) {?> selected<?php } ?>>
142
										<?php echo $TOFLASH; ?>
143
									</option>
144
								</select>
145
								<br/>
146
								This will set the bootup slice.
147
						</td>
148
					</tr>
149
					<tr>
150
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Set bootup'></form></td>
151
					</tr>
152
					<tr>
153
						<td colspan="2" valign="top" class="">&nbsp;</td>
154
					</tr>					
155
					<tr>
156
						<td colspan="2" valign="top" class="listtopic">Duplicate bootup slice to alternate</td>
157
					</tr>
158
					<tr>
159
						<td width="22%" valign="top" class="vncell">Duplicate bootup slice</td>
160
						<td width="78%" class="vtable">
161
							<form action="diag_nanobsd.php" method="post" name="iform">						
162
								Destination slice:							
163
								<select name='destslice'>
164
									<option value='<?php echo $COMPLETE_PATH; ?>'>
165
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
166
									</option>
167
								</select>
168
								<br/>
169
								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.
170
						</td>
171
					</tr>
172
					<tr>
173
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Duplicate slice'></form></td>
174
					</tr>
175
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
176
					<tr>
177
						<td colspan="2" valign="top" class="">&nbsp;</td>
178
					</tr>					
179
					<tr>
180
						<td colspan="2" valign="top" class="listtopic">View upgrade log</td>
181
					</tr>
182
					<tr>
183
						<td width="22%" valign="top" class="vncell">View previous upgrade log</td>
184
						<td width="78%" class="vtable">
185
						<?php
186
							if($_POST['viewupgradelog']) {
187
								echo "<textarea name='log' cols='80' rows='40'>";
188
								echo file_get_contents("/conf/upgrade_log.txt");
189
								echo "\nFile list:\n";
190
								echo file_get_contents("/conf/file_upgrade_log.txt");
191
								echo "\nMisc log:\n";
192
								echo file_get_contents("/conf/firmware_update_misc.log");
193
								echo "\nfdisk/bsdlabel log:\n";
194
								echo file_get_contents("/conf/fdisk_upgrade_log.txt");
195
								echo "</textarea>";
196
							} else {
197
								echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
198
								echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
199
							}
200
						?>
201
						</td>
202
					</tr>
203
<?php endif; ?>
204
					<tr>
205
						<td colspan="2" valign="top" class="">&nbsp;</td>
206
					</tr>					
207
				</table>
208
			</div>
209
		</td>
210
	</tr>
211
</table>
212
<?php require("fend.inc"); ?>
213
</body>
214
</html>
215

    
216
<?php
217

    
218
// Clear the loading indicator
219
echo "<script type=\"text/javascript\">";
220
echo "$('loading').innerHTML = '';";
221
echo "</script>";	
222

    
223
?>
(27-27/216)