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 |
|
|
$pgtitle = array("Diagnostics","NanoBSD");
|
50 |
|
|
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 |
80683b0d
|
Scott Ullrich
|
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
|
62 |
be6e1e8a
|
Scott Ullrich
|
|
63 |
ae396e30
|
Scott Ullrich
|
<?php include("fbegin.inc"); ?>
|
64 |
be6e1e8a
|
Scott Ullrich
|
|
65 |
ae396e30
|
Scott Ullrich
|
<?php
|
66 |
|
|
|
67 |
08fd5444
|
jim-p
|
$NANOBSD_SIZE = nanobsd_get_size();
|
68 |
62d01a53
|
Scott Ullrich
|
|
69 |
104c11c6
|
Scott Ullrich
|
if($_POST['bootslice']) {
|
70 |
ae396e30
|
Scott Ullrich
|
echo <<<EOF
|
71 |
|
|
<div id="loading">
|
72 |
be6e1e8a
|
Scott Ullrich
|
<img src="/themes/metallic/images/misc/loader.gif">
|
73 |
|
|
Setting slice information, please wait...
|
74 |
ae396e30
|
Scott Ullrich
|
<p/>
|
75 |
|
|
</div>
|
76 |
|
|
EOF;
|
77 |
2b5f276f
|
jim-p
|
nanobsd_switch_boot_slice();
|
78 |
08fd5444
|
jim-p
|
$savemsg = "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 |
ae396e30
|
Scott Ullrich
|
echo <<<EOF
|
86 |
|
|
<div id="loading">
|
87 |
be6e1e8a
|
Scott Ullrich
|
<img src="/themes/metallic/images/misc/loader.gif">
|
88 |
7f9bd1c2
|
Chris Buechler
|
Duplicating slice. Please wait, this will take a moment...
|
89 |
ae396e30
|
Scott Ullrich
|
<p/>
|
90 |
|
|
</div>
|
91 |
|
|
EOF;
|
92 |
08fd5444
|
jim-p
|
if(nanobsd_clone_slice($_POST['destslice'])) {
|
93 |
e5385806
|
Scott Ullrich
|
$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 |
08fd5444
|
jim-p
|
} else {
|
95 |
|
|
$savemsg = "There was an error while duplicating the slice. Operation aborted.";
|
96 |
104c11c6
|
Scott Ullrich
|
}
|
97 |
a3a22a4e
|
Scott Ullrich
|
// Re-Survey slice info
|
98 |
08fd5444
|
jim-p
|
nanobsd_detect_slice_info();
|
99 |
104c11c6
|
Scott Ullrich
|
}
|
100 |
|
|
|
101 |
|
|
if ($savemsg)
|
102 |
|
|
print_info_box($savemsg)
|
103 |
ae396e30
|
Scott Ullrich
|
|
104 |
104c11c6
|
Scott Ullrich
|
?>
|
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: </strong>
|
117 |
|
|
</span>
|
118 |
|
|
The options on this page are intended for use by advanced users only.
|
119 |
ae396e30
|
Scott Ullrich
|
<br/>
|
120 |
104c11c6
|
Scott Ullrich
|
</span>
|
121 |
ae396e30
|
Scott Ullrich
|
<p/>
|
122 |
104c11c6
|
Scott Ullrich
|
<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 |
b000d606
|
Scott Ullrich
|
<tr>
|
127 |
|
|
<td width="22%" valign="top" class="vncell">NanoBSD Image size</td>
|
128 |
|
|
<td width="78%" class="vtable">
|
129 |
e0d47cb9
|
Scott Ullrich
|
<?php echo $NANOBSD_SIZE; ?>
|
130 |
b000d606
|
Scott Ullrich
|
</td>
|
131 |
|
|
</tr>
|
132 |
104c11c6
|
Scott Ullrich
|
<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 |
2b5f276f
|
jim-p
|
Bootup slice is currently: <?php echo $ACTIVE_SLICE; ?>
|
137 |
|
|
<br/><br/>This will switch the bootup slice to the alternate slice.
|
138 |
104c11c6
|
Scott Ullrich
|
<br/>
|
139 |
2b5f276f
|
jim-p
|
<input type='hidden' name='bootslice' value='switch'>
|
140 |
|
|
<input type='submit' value='Switch Slice'></form>
|
141 |
104c11c6
|
Scott Ullrich
|
</td>
|
142 |
|
|
</tr>
|
143 |
|
|
<tr>
|
144 |
|
|
<td colspan="2" valign="top" class=""> </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 |
9cd8fd11
|
Scott Ullrich
|
<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
|
157 |
104c11c6
|
Scott Ullrich
|
</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 |
28949aa1
|
Scott Ullrich
|
<td valign="top" class=""> </td><td><br/><input type='submit' value='Duplicate slice'></form></td>
|
165 |
104c11c6
|
Scott Ullrich
|
</tr>
|
166 |
bcb03f4b
|
Scott Ullrich
|
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
|
167 |
|
|
<tr>
|
168 |
|
|
<td colspan="2" valign="top" class=""> </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 |
ad3c7724
|
Scott Ullrich
|
echo "\nFile list:\n";
|
181 |
dce5cc7c
|
Scott Ullrich
|
echo file_get_contents("/conf/file_upgrade_log.txt");
|
182 |
ad3c7724
|
Scott Ullrich
|
echo "\nMisc log:\n";
|
183 |
dce5cc7c
|
Scott Ullrich
|
echo file_get_contents("/conf/firmware_update_misc.log");
|
184 |
c5eb3a17
|
Scott Ullrich
|
echo "\nfdisk/bsdlabel log:\n";
|
185 |
|
|
echo file_get_contents("/conf/fdisk_upgrade_log.txt");
|
186 |
bcb03f4b
|
Scott Ullrich
|
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 |
104c11c6
|
Scott Ullrich
|
<tr>
|
196 |
|
|
<td colspan="2" valign="top" class=""> </td>
|
197 |
|
|
</tr>
|
198 |
|
|
</table>
|
199 |
|
|
</div>
|
200 |
|
|
</td>
|
201 |
|
|
</tr>
|
202 |
|
|
</table>
|
203 |
|
|
<?php require("fend.inc"); ?>
|
204 |
|
|
</body>
|
205 |
|
|
</html>
|
206 |
ae396e30
|
Scott Ullrich
|
|
207 |
|
|
<?php
|
208 |
|
|
|
209 |
be6e1e8a
|
Scott Ullrich
|
// Clear the loading indicator
|
210 |
ae396e30
|
Scott Ullrich
|
echo "<script type=\"text/javascript\">";
|
211 |
|
|
echo "$('loading').innerHTML = '';";
|
212 |
|
|
echo "</script>";
|
213 |
|
|
|
214 |
58cd9724
|
Renato Botelho
|
?>
|