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 /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(gettext("Diagnostics"), gettext("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
|
|
62
|
<?php include("fbegin.inc"); ?>
|
63
|
|
64
|
<?php
|
65
|
|
66
|
$NANOBSD_SIZE = nanobsd_get_size();
|
67
|
|
68
|
if($_POST['bootslice']) {
|
69
|
$statusmsg = gettext("Setting slice information, please wait...");
|
70
|
echo <<<EOF
|
71
|
<div id="loading">
|
72
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif">
|
73
|
$statusmsg
|
74
|
<p/>
|
75
|
</div>
|
76
|
EOF;
|
77
|
nanobsd_switch_boot_slice();
|
78
|
$savemsg = gettext("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
|
$statusmsg = gettext("Duplicating slice. Please wait, this will take a moment...");
|
86
|
echo <<<EOF
|
87
|
<div id="loading">
|
88
|
<img src="/themes/{$g['theme']}/images/misc/loader.gif">
|
89
|
$statusmsg
|
90
|
<p/>
|
91
|
</div>
|
92
|
EOF;
|
93
|
if(nanobsd_clone_slice($_POST['destslice'])) {
|
94
|
$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
|
} else {
|
96
|
$savemsg = gettext("There was an error while duplicating the slice. Operation aborted.");
|
97
|
}
|
98
|
// Re-Survey slice info
|
99
|
nanobsd_detect_slice_info();
|
100
|
}
|
101
|
|
102
|
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
|
conf_mount_rw();
|
112
|
if (isset($_POST['nanobsd_force_rw']))
|
113
|
$config['system']['nanobsd_force_rw'] = true;
|
114
|
else
|
115
|
unset($config['system']['nanobsd_force_rw']);
|
116
|
|
117
|
write_config("Changed Permanent Read/Write Setting");
|
118
|
conf_mount_ro();
|
119
|
}
|
120
|
|
121
|
if ($savemsg)
|
122
|
print_info_box($savemsg)
|
123
|
|
124
|
?>
|
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
|
<strong><?=gettext("NOTE:")?> </strong>
|
137
|
</span>
|
138
|
<?=gettext("The options on this page are intended for use by advanced users only.")?>
|
139
|
<br />
|
140
|
</span>
|
141
|
<p/>
|
142
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
143
|
<tr>
|
144
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
|
145
|
</tr>
|
146
|
<tr>
|
147
|
<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
|
148
|
<td width="78%" class="vtable">
|
149
|
<?php echo $NANOBSD_SIZE; ?>
|
150
|
</td>
|
151
|
</tr>
|
152
|
<tr>
|
153
|
<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
|
154
|
<td width="78%" class="vtable">
|
155
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
156
|
<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
|
157
|
<br /><br /><?=gettext("This will switch the bootup slice to the alternate slice.");?>
|
158
|
<br />
|
159
|
<input type='hidden' name='bootslice' value='switch'>
|
160
|
<input type='submit' value='Switch Slice'></form>
|
161
|
</td>
|
162
|
</tr>
|
163
|
<tr>
|
164
|
<td colspan="2" valign="top" class=""> </td>
|
165
|
</tr>
|
166
|
<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
|
$refcount = refcount_read(1000);
|
175
|
/* refcount_read returns -1 when shared memory section does not exist */
|
176
|
if ($refcount == 1 || $refcount == -1) {
|
177
|
$refdisplay = "";
|
178
|
} else {
|
179
|
$refdisplay = " (reference count " . $refcount . ")";
|
180
|
}
|
181
|
echo gettext("Read/Write") . $refdisplay;
|
182
|
if (!isset($config['system']['nanobsd_force_rw']))
|
183
|
echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read-Only") . "'>";
|
184
|
} else {
|
185
|
echo gettext("Read-Only");
|
186
|
if (!isset($config['system']['nanobsd_force_rw']))
|
187
|
echo "<br /><input type='submit' name='changero' value='" . gettext("Switch to Read/Write") . "'>";
|
188
|
} ?>
|
189
|
</form>
|
190
|
<br /><?php echo gettext("NOTE: This setting is only temporary, and can be switched dynamically in the background."); ?>
|
191
|
</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
|
<br /><input type='submit' name='setrw' value='<?php echo gettext("Save") ?>'>
|
199
|
</form>
|
200
|
</td>
|
201
|
</tr>
|
202
|
<tr>
|
203
|
<td colspan="2" valign="top" class=""> </td>
|
204
|
</tr>
|
205
|
<tr>
|
206
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
|
207
|
</tr>
|
208
|
<tr>
|
209
|
<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
|
210
|
<td width="78%" class="vtable">
|
211
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
212
|
<?=gettext("Destination slice:");?>
|
213
|
<select name='destslice'>
|
214
|
<option value='<?php echo $COMPLETE_PATH; ?>'>
|
215
|
<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
|
216
|
</option>
|
217
|
</select>
|
218
|
<br />
|
219
|
<?=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
|
<br /><input type='submit' name='duplicateslice' value='<?php echo gettext("Duplicate slice") ?>'>
|
221
|
</form>
|
222
|
</td>
|
223
|
</tr>
|
224
|
<tr>
|
225
|
<td colspan="2" valign="top" class=""> </td>
|
226
|
</tr>
|
227
|
<tr>
|
228
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Periodic Data Backup");?></td>
|
229
|
</tr>
|
230
|
<tr>
|
231
|
<td width="22%" valign="top" class="vncell"><?=gettext("RRD/DHCP Backup");?></td>
|
232
|
<td width="78%" class="vtable">
|
233
|
<?=gettext("These options have been relocated to");?> <a href="system_advanced_misc.php"><?=gettext("System > Advanced, Miscellaneous tab")?></a>.
|
234
|
</td>
|
235
|
</tr>
|
236
|
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
|
237
|
<tr>
|
238
|
<td colspan="2" valign="top" class=""> </td>
|
239
|
</tr>
|
240
|
<tr>
|
241
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
|
242
|
</tr>
|
243
|
<tr>
|
244
|
<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
|
245
|
<td width="78%" class="vtable">
|
246
|
<?php
|
247
|
if ($_POST['viewupgradelog']) {
|
248
|
echo "<textarea name='log' cols='80' rows='40'>";
|
249
|
echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/upgrade_log.txt"));
|
250
|
echo "\nFile list:\n";
|
251
|
echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/file_upgrade_log.txt"));
|
252
|
echo "\nMisc log:\n";
|
253
|
echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/firmware_update_misc_log.txt"));
|
254
|
echo "\nfdisk/bsdlabel log:\n";
|
255
|
echo str_ireplace("pfsense", $g['product_name'], file_get_contents("/conf/fdisk_upgrade_log.txt"));
|
256
|
echo "</textarea>";
|
257
|
} else {
|
258
|
echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
|
259
|
echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
|
260
|
}
|
261
|
?>
|
262
|
</td>
|
263
|
</tr>
|
264
|
<?php endif; ?>
|
265
|
<tr>
|
266
|
<td colspan="2" valign="top" class=""> </td>
|
267
|
</tr>
|
268
|
</table>
|
269
|
</div>
|
270
|
</td>
|
271
|
</tr>
|
272
|
</table>
|
273
|
<?php require("fend.inc"); ?>
|
274
|
</body>
|
275
|
</html>
|
276
|
|
277
|
<?php
|
278
|
|
279
|
// Clear the loading indicator
|
280
|
echo "<script type=\"text/javascript\">";
|
281
|
echo "jQuery('#loading').html('');";
|
282
|
echo "</script>";
|
283
|
|
284
|
?>
|