Project

General

Profile

Download (9.92 KB) Statistics
| Branch: | Tag: | Revision:
1 104c11c6 Scott Ullrich
<?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 13d193c2 Scott Ullrich
/*	
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 104c11c6 Scott Ullrich
##|+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 ae396e30 Scott Ullrich
ini_set('zlib.output_compression', 0);
43
ini_set('implicit_flush', 1);
44
ini_set('max_input_time', '9999');
45 104c11c6 Scott Ullrich
46
require_once("guiconfig.inc");
47 96099c6a Renato Botelho
require_once("config.inc");
48 104c11c6 Scott Ullrich
49 9404a104 Renato Botelho
$pgtitle = array(gettext("Diagnostics"), gettext("NanoBSD"));
50 104c11c6 Scott Ullrich
include("head.inc");
51
52 a3a22a4e Scott Ullrich
// Survey slice info
53 08fd5444 jim-p
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 a3a22a4e Scott Ullrich
58 ae396e30 Scott Ullrich
?>
59
60
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?=$jsevents["body"]["onload"];?>">
61 be6e1e8a Scott Ullrich
62 ae396e30 Scott Ullrich
<?php include("fbegin.inc"); ?>
63 be6e1e8a Scott Ullrich
64 ae396e30 Scott Ullrich
<?php
65
66 08fd5444 jim-p
$NANOBSD_SIZE = nanobsd_get_size();
67 62d01a53 Scott Ullrich
68 104c11c6 Scott Ullrich
if($_POST['bootslice']) {
69 cf652f81 Chris Buechler
	$statusmsg = gettext("Setting slice information, please wait..."); 
70 ae396e30 Scott Ullrich
	echo <<<EOF
71
	 	<div id="loading">
72 7bc1b968 Renato Botelho
			<img src="/themes/{$g['theme']}/images/misc/loader.gif"> 
73 cf652f81 Chris Buechler
			$statusmsg
74 ae396e30 Scott Ullrich
			<p/>&nbsp;
75
		</div>
76
EOF;
77 2b5f276f jim-p
	nanobsd_switch_boot_slice();
78 9404a104 Renato Botelho
	$savemsg = gettext("The boot slice has been set to") . " " . nanobsd_get_active_slice();
79 a3a22a4e Scott Ullrich
	// Survey slice info
80 08fd5444 jim-p
	nanobsd_detect_slice_info();
81 a3a22a4e Scott Ullrich
82 104c11c6 Scott Ullrich
}
83
84
if($_POST['destslice']) {
85 cf652f81 Chris Buechler
	$statusmsg = gettext("Duplicating slice.  Please wait, this will take a moment...");
86 ae396e30 Scott Ullrich
echo <<<EOF
87
 	<div id="loading">
88 7bc1b968 Renato Botelho
		<img src="/themes/{$g['theme']}/images/misc/loader.gif">
89 cf652f81 Chris Buechler
		$statusmsg
90 ae396e30 Scott Ullrich
		<p/>&nbsp;
91
	</div>
92
EOF;
93 08fd5444 jim-p
	if(nanobsd_clone_slice($_POST['destslice'])) {
94 9404a104 Renato Botelho
		$savemsg = gettext("The slice has been duplicated.") . "<p/>" . gettext("If you would like to boot from this newly duplicated slice please set it using the bootup information area.");
95 08fd5444 jim-p
	} else {
96 9404a104 Renato Botelho
		$savemsg = gettext("There was an error while duplicating the slice.  Operation aborted.");
97 104c11c6 Scott Ullrich
	}
98 a3a22a4e Scott Ullrich
	// Re-Survey slice info
99 08fd5444 jim-p
	nanobsd_detect_slice_info();
100 104c11c6 Scott Ullrich
}
101
102 7b229013 jim-p
if ($_POST['changero']) {
103
	if (is_writable("/")) {
104
		conf_mount_ro();
105
	} else {
106
		conf_mount_rw();
107
	}
108
}
109
110
if ($_POST['setrw']) {
111 b8250344 Renato Botelho
	conf_mount_rw();
112
	if (isset($_POST['nanobsd_force_rw']))
113 7b229013 jim-p
		$config['system']['nanobsd_force_rw'] = true;
114 b8250344 Renato Botelho
	else
115 7b229013 jim-p
		unset($config['system']['nanobsd_force_rw']);
116
117
	write_config("Changed Permanent Read/Write Setting");
118
	conf_mount_ro();
119
}
120 85405c11 jim-p
121 104c11c6 Scott Ullrich
if ($savemsg)
122
	print_info_box($savemsg)
123 ae396e30 Scott Ullrich
124 104c11c6 Scott Ullrich
?>
125
<table width="100%" border="0" cellpadding="0" cellspacing="0">
126
	<tr>
127
		<td>
128
			<!-- tabs here if you want them -->
129
		</td>
130
	</tr>
131
	<tr>
132
		<td id="mainarea">
133
			<div class="tabcont">
134
				<span class="vexpl">
135
					<span class="red">
136 45a06eeb Renato Botelho
						<strong><?=gettext("NOTE:")?>&nbsp;</strong>
137 104c11c6 Scott Ullrich
					</span>
138 9404a104 Renato Botelho
					<?=gettext("The options on this page are intended for use by advanced users only.")?>
139 8cd558b6 ayvis
					<br />&nbsp;
140 104c11c6 Scott Ullrich
				</span>
141 ae396e30 Scott Ullrich
				<p/>
142 104c11c6 Scott Ullrich
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
143
					<tr>
144 9404a104 Renato Botelho
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
145 104c11c6 Scott Ullrich
					</tr>
146 b000d606 Scott Ullrich
					<tr>						
147 9404a104 Renato Botelho
						<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
148 b000d606 Scott Ullrich
						<td width="78%" class="vtable">
149 e0d47cb9 Scott Ullrich
							<?php echo $NANOBSD_SIZE; ?>
150 b000d606 Scott Ullrich
						</td>
151
					</tr>
152 104c11c6 Scott Ullrich
					<tr>
153 9404a104 Renato Botelho
						<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
154 104c11c6 Scott Ullrich
						<td width="78%" class="vtable">
155
							<form action="diag_nanobsd.php" method="post" name="iform">
156 aaaf679f Carlos Eduardo Ramos
								<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
157 8cd558b6 ayvis
								<br /><br /><?=gettext("This will switch the bootup slice to the alternate slice.");?>
158
								<br />
159 2b5f276f jim-p
								<input type='hidden' name='bootslice' value='switch'>
160
								<input type='submit' value='Switch Slice'></form>
161 104c11c6 Scott Ullrich
						</td>
162
					</tr>
163
					<tr>
164
						<td colspan="2" valign="top" class="">&nbsp;</td>
165
					</tr>					
166 7b229013 jim-p
					<tr>
167
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Media Read/Write Status");?></td>
168
					</tr>
169
					<tr>
170
						<td valign="top" class="vncell">Current Read/Write Status:</td>
171
						<td valign="top" class="vncell">
172
							<form action="diag_nanobsd.php" method="post" name="iform">
173
							<?php if (is_writable("/")) {
174 41cc7a54 Phil Davis
								$refcount = refcount_read(1000);
175 b8250344 Renato Botelho
								/* refcount_read returns -1 when shared memory section does not exist */
176
								if ($refcount == 1 || $refcount == -1) {
177 41cc7a54 Phil Davis
									$refdisplay = "";
178
								} else {
179
									$refdisplay = " (reference count " . $refcount . ")";
180
								}
181
								echo gettext("Read/Write") . $refdisplay;
182 7b229013 jim-p
								if (!isset($config['system']['nanobsd_force_rw']))
183 8cd558b6 ayvis
									echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read-Only") . "'>";
184 7b229013 jim-p
							} else {
185
								echo gettext("Read-Only");
186
								if (!isset($config['system']['nanobsd_force_rw']))
187 8cd558b6 ayvis
									echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read/Write") . "'>";
188 7b229013 jim-p
							} ?>
189
							</form>
190 8cd558b6 ayvis
							<br /><?php echo gettext("NOTE: This setting is only temporary, and can be switched dynamically in the background."); ?>
191 7b229013 jim-p
						</td>
192
					</tr>
193
					<tr>
194
						<td valign="top" class="vncell">Permanent Read/Write:</td>
195
						<td valign="top" class="vncell">
196
							<form action="diag_nanobsd.php" method="post" name="iform">
197
								<input type="checkbox" name="nanobsd_force_rw" <?php if (isset($config['system']['nanobsd_force_rw'])) echo "checked"; ?>> <?php echo gettext("Keep media mounted read/write at all times.") ?>
198 8cd558b6 ayvis
								<br /><input type='submit' name='setrw' value='<?php echo gettext("Save") ?>'>
199 7b229013 jim-p
							</form>
200
						</td>
201
					</tr>
202
					<tr>
203
						<td colspan="2" valign="top" class="">&nbsp;</td>
204
					</tr>
205 104c11c6 Scott Ullrich
					<tr>
206 9404a104 Renato Botelho
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
207 104c11c6 Scott Ullrich
					</tr>
208
					<tr>
209 9404a104 Renato Botelho
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
210 104c11c6 Scott Ullrich
						<td width="78%" class="vtable">
211 c0948c6c Renato Botelho
							<form action="diag_nanobsd.php" method="post" name="iform">
212 aaaf679f Carlos Eduardo Ramos
								<?=gettext("Destination slice:");?>
213 104c11c6 Scott Ullrich
								<select name='destslice'>
214
									<option value='<?php echo $COMPLETE_PATH; ?>'>
215 9cd8fd11 Scott Ullrich
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
216 104c11c6 Scott Ullrich
									</option>
217
								</select>
218 8cd558b6 ayvis
								<br />
219 9404a104 Renato Botelho
								<?=gettext("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.");?>
220 104c11c6 Scott Ullrich
						</td>
221
					</tr>
222
					<tr>
223 8cd558b6 ayvis
						<td valign="top" class="">&nbsp;</td><td><br /><input type='submit' value='Duplicate slice'></form></td>
224 104c11c6 Scott Ullrich
					</tr>
225 85405c11 jim-p
					<tr>
226
						<td colspan="2" valign="top" class="">&nbsp;</td>
227
					</tr>
228
					<tr>
229
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Periodic Data Backup");?></td>
230
					</tr>
231
					<tr>
232 e92e83d4 jim-p
						<td width="22%" valign="top" class="vncell"><?=gettext("RRD/DHCP Backup");?></td>
233 85405c11 jim-p
						<td width="78%" class="vtable">
234 e92e83d4 jim-p
							<?=gettext("These options have been relocated to");?> <a href="system_advanced_misc.php"><?=gettext("System > Advanced, Miscellaneous tab")?></a>.
235 85405c11 jim-p
						</td>
236
					</tr>
237 bcb03f4b Scott Ullrich
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
238
					<tr>
239
						<td colspan="2" valign="top" class="">&nbsp;</td>
240
					</tr>					
241
					<tr>
242 9404a104 Renato Botelho
						<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
243 bcb03f4b Scott Ullrich
					</tr>
244
					<tr>
245 9404a104 Renato Botelho
						<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
246 bcb03f4b Scott Ullrich
						<td width="78%" class="vtable">
247
						<?php
248 2df0e712 Warren Baker
							if ($_POST['viewupgradelog']) {
249 bcb03f4b Scott Ullrich
								echo "<textarea name='log' cols='80' rows='40'>";
250 2df0e712 Warren Baker
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/upgrade_log.txt"));
251 ad3c7724 Scott Ullrich
								echo "\nFile list:\n";
252 2df0e712 Warren Baker
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/file_upgrade_log.txt"));
253 ad3c7724 Scott Ullrich
								echo "\nMisc log:\n";
254 2df0e712 Warren Baker
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/firmware_update_misc_log.txt"));
255 c5eb3a17 Scott Ullrich
								echo "\nfdisk/bsdlabel log:\n";
256 2df0e712 Warren Baker
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/fdisk_upgrade_log.txt"));
257 bcb03f4b Scott Ullrich
								echo "</textarea>";
258
							} else {
259
								echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
260
								echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
261
							}
262
						?>
263
						</td>
264
					</tr>
265
<?php endif; ?>
266 104c11c6 Scott Ullrich
					<tr>
267
						<td colspan="2" valign="top" class="">&nbsp;</td>
268
					</tr>					
269
				</table>
270
			</div>
271
		</td>
272
	</tr>
273
</table>
274
<?php require("fend.inc"); ?>
275
</body>
276
</html>
277 ae396e30 Scott Ullrich
278
<?php
279
280 be6e1e8a Scott Ullrich
// Clear the loading indicator
281 ae396e30 Scott Ullrich
echo "<script type=\"text/javascript\">";
282 ebfc87d6 Vinicius Coque
echo "jQuery('#loading').html('');";
283 ae396e30 Scott Ullrich
echo "</script>";	
284
285 58cd9724 Renato Botelho
?>