Project

General

Profile

Download (9.95 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	diag_nanobsd.php
4
	Copyright (C) 2009 Scott Ullrich <sullrich@gmail.com>
5
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
6
	All rights reserved.
7

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

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

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

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

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

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

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

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

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

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

    
59
?>
60

    
61
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?=$jsevents["body"]["onload"];?>">
62

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

    
65
<?php
66

    
67
$NANOBSD_SIZE = nanobsd_get_size();
68

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

    
83
}
84

    
85
if($_POST['destslice']) {
86
	$statusmsg = gettext("Duplicating slice.  Please wait, this will take a moment...");
87
echo <<<EOF
88
 	<div id="loading">
89
		<img src="/themes/{$g['theme']}/images/misc/loader.gif">
90
		$statusmsg
91
		<p/>&nbsp;
92
	</div>
93
EOF;
94
	if(nanobsd_clone_slice($_POST['destslice'])) {
95
		$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.");
96
	} else {
97
		$savemsg = gettext("There was an error while duplicating the slice.  Operation aborted.");
98
	}
99
	// Re-Survey slice info
100
	nanobsd_detect_slice_info();
101
}
102

    
103
if ($_POST['changero']) {
104
	if (is_writable("/")) {
105
		conf_mount_ro();
106
	} else {
107
		conf_mount_rw();
108
	}
109
}
110

    
111
if ($_POST['setrw']) {
112
	conf_mount_rw();
113
	if (isset($_POST['nanobsd_force_rw']))
114
		$config['system']['nanobsd_force_rw'] = true;
115
	else
116
		unset($config['system']['nanobsd_force_rw']);
117

    
118
	write_config("Changed Permanent Read/Write Setting");
119
	conf_mount_ro();
120
}
121

    
122
if ($savemsg)
123
	print_info_box($savemsg)
124

    
125
?>
126
<table width="100%" border="0" cellpadding="0" cellspacing="0">
127
	<tr>
128
		<td>
129
			<!-- tabs here if you want them -->
130
		</td>
131
	</tr>
132
	<tr>
133
		<td id="mainarea">
134
			<div class="tabcont">
135
				<span class="vexpl">
136
					<span class="red">
137
						<strong><?=gettext("NOTE:")?>&nbsp;</strong>
138
					</span>
139
					<?=gettext("The options on this page are intended for use by advanced users only.")?>
140
					<br />&nbsp;
141
				</span>
142
				<p/>
143
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
144
					<tr>
145
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
146
					</tr>
147
					<tr>						
148
						<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
149
						<td width="78%" class="vtable">
150
							<?php echo $NANOBSD_SIZE; ?>
151
						</td>
152
					</tr>
153
					<tr>
154
						<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
155
						<td width="78%" class="vtable">
156
							<form action="diag_nanobsd.php" method="post" name="iform">
157
								<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
158
								<br /><br /><?=gettext("This will switch the bootup slice to the alternate slice.");?>
159
								<br />
160
								<input type='hidden' name='bootslice' value='switch'>
161
								<input type='submit' value='Switch Slice'></form>
162
						</td>
163
					</tr>
164
					<tr>
165
						<td colspan="2" valign="top" class="">&nbsp;</td>
166
					</tr>					
167
					<tr>
168
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Media Read/Write Status");?></td>
169
					</tr>
170
					<tr>
171
						<td valign="top" class="vncell">Current Read/Write Status:</td>
172
						<td valign="top" class="vncell">
173
							<form action="diag_nanobsd.php" method="post" name="iform">
174
							<?php if (is_writable("/")) {
175
								$refcount = refcount_read(1000);
176
								/* refcount_read returns -1 when shared memory section does not exist */
177
								if ($refcount == 1 || $refcount == -1) {
178
									$refdisplay = "";
179
								} else {
180
									$refdisplay = " (reference count " . $refcount . ")";
181
								}
182
								echo gettext("Read/Write") . $refdisplay;
183
								if (!isset($config['system']['nanobsd_force_rw']))
184
									echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read-Only") . "'>";
185
							} else {
186
								echo gettext("Read-Only");
187
								if (!isset($config['system']['nanobsd_force_rw']))
188
									echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read/Write") . "'>";
189
							} ?>
190
							</form>
191
							<br /><?php echo gettext("NOTE: This setting is only temporary, and can be switched dynamically in the background."); ?>
192
						</td>
193
					</tr>
194
					<tr>
195
						<td valign="top" class="vncell">Permanent Read/Write:</td>
196
						<td valign="top" class="vncell">
197
							<form action="diag_nanobsd.php" method="post" name="iform">
198
								<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.") ?>
199
								<br /><input type='submit' name='setrw' value='<?php echo gettext("Save") ?>'>
200
							</form>
201
						</td>
202
					</tr>
203
					<tr>
204
						<td colspan="2" valign="top" class="">&nbsp;</td>
205
					</tr>
206
					<tr>
207
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
208
					</tr>
209
					<tr>
210
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
211
						<td width="78%" class="vtable">
212
							<form action="diag_nanobsd.php" method="post" name="iform">
213
								<?=gettext("Destination slice:");?>
214
								<select name='destslice'>
215
									<option value='<?php echo $COMPLETE_PATH; ?>'>
216
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
217
									</option>
218
								</select>
219
								<br />
220
								<?=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.");?>
221
								<br /><input type='submit' name='duplicateslice' value='<?php echo gettext("Duplicate slice") ?>'>
222
							</form>
223
						</td>
224
					</tr>
225
					<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
						<td width="22%" valign="top" class="vncell"><?=gettext("RRD/DHCP Backup");?></td>
233
						<td width="78%" class="vtable">
234
							<?=gettext("These options have been relocated to");?> <a href="system_advanced_misc.php"><?=gettext("System > Advanced, Miscellaneous tab")?></a>.
235
						</td>
236
					</tr>
237
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
238
					<tr>
239
						<td colspan="2" valign="top" class="">&nbsp;</td>
240
					</tr>					
241
					<tr>
242
						<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
243
					</tr>
244
					<tr>
245
						<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
246
						<td width="78%" class="vtable">
247
						<?php
248
							if ($_POST['viewupgradelog']) {
249
								echo "<textarea name='log' cols='80' rows='40'>";
250
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/upgrade_log.txt"));
251
								echo "\nFile list:\n";
252
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/file_upgrade_log.txt"));
253
								echo "\nMisc log:\n";
254
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/firmware_update_misc_log.txt"));
255
								echo "\nfdisk/bsdlabel log:\n";
256
								echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/fdisk_upgrade_log.txt"));
257
								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
					<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

    
278
<?php
279

    
280
// Clear the loading indicator
281
echo "<script type=\"text/javascript\">";
282
echo "jQuery('#loading').html('');";
283
echo "</script>";	
284

    
285
?>
(37-37/256)