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 |
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 |
cf652f81
|
Chris Buechler
|
$statusmsg = gettext("Setting slice information, please wait...");
|
71 |
ae396e30
|
Scott Ullrich
|
echo <<<EOF
|
72 |
|
|
<div id="loading">
|
73 |
be6e1e8a
|
Scott Ullrich
|
<img src="/themes/metallic/images/misc/loader.gif">
|
74 |
cf652f81
|
Chris Buechler
|
$statusmsg
|
75 |
ae396e30
|
Scott Ullrich
|
<p/>
|
76 |
|
|
</div>
|
77 |
|
|
EOF;
|
78 |
2b5f276f
|
jim-p
|
nanobsd_switch_boot_slice();
|
79 |
9404a104
|
Renato Botelho
|
$savemsg = gettext("The boot slice has been set to") . " " . nanobsd_get_active_slice();
|
80 |
a3a22a4e
|
Scott Ullrich
|
// Survey slice info
|
81 |
08fd5444
|
jim-p
|
nanobsd_detect_slice_info();
|
82 |
a3a22a4e
|
Scott Ullrich
|
|
83 |
104c11c6
|
Scott Ullrich
|
}
|
84 |
|
|
|
85 |
|
|
if($_POST['destslice']) {
|
86 |
cf652f81
|
Chris Buechler
|
$statusmsg = gettext("Duplicating slice. Please wait, this will take a moment...");
|
87 |
ae396e30
|
Scott Ullrich
|
echo <<<EOF
|
88 |
|
|
<div id="loading">
|
89 |
be6e1e8a
|
Scott Ullrich
|
<img src="/themes/metallic/images/misc/loader.gif">
|
90 |
cf652f81
|
Chris Buechler
|
$statusmsg
|
91 |
ae396e30
|
Scott Ullrich
|
<p/>
|
92 |
|
|
</div>
|
93 |
|
|
EOF;
|
94 |
08fd5444
|
jim-p
|
if(nanobsd_clone_slice($_POST['destslice'])) {
|
95 |
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.");
|
96 |
08fd5444
|
jim-p
|
} else {
|
97 |
9404a104
|
Renato Botelho
|
$savemsg = gettext("There was an error while duplicating the slice. Operation aborted.");
|
98 |
104c11c6
|
Scott Ullrich
|
}
|
99 |
a3a22a4e
|
Scott Ullrich
|
// Re-Survey slice info
|
100 |
08fd5444
|
jim-p
|
nanobsd_detect_slice_info();
|
101 |
104c11c6
|
Scott Ullrich
|
}
|
102 |
|
|
|
103 |
85405c11
|
jim-p
|
if (isset($_POST['rrdbackup'])) {
|
104 |
|
|
$config['system']['rrdbackup'] = $_POST['rrdbackup'];
|
105 |
|
|
install_cron_job("/etc/rc.backup_rrd.sh", ($config['system']['rrdbackup'] > 0), $minute="0", "*/{$config['system']['rrdbackup']}");
|
106 |
|
|
}
|
107 |
|
|
if (isset($_POST['dhcpbackup'])) {
|
108 |
|
|
$config['system']['dhcpbackup'] = $_POST['dhcpbackup'];
|
109 |
|
|
install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}");
|
110 |
|
|
}
|
111 |
|
|
|
112 |
|
|
|
113 |
104c11c6
|
Scott Ullrich
|
if ($savemsg)
|
114 |
|
|
print_info_box($savemsg)
|
115 |
ae396e30
|
Scott Ullrich
|
|
116 |
104c11c6
|
Scott Ullrich
|
?>
|
117 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
118 |
|
|
<tr>
|
119 |
|
|
<td>
|
120 |
|
|
<!-- tabs here if you want them -->
|
121 |
|
|
</td>
|
122 |
|
|
</tr>
|
123 |
|
|
<tr>
|
124 |
|
|
<td id="mainarea">
|
125 |
|
|
<div class="tabcont">
|
126 |
|
|
<span class="vexpl">
|
127 |
|
|
<span class="red">
|
128 |
45a06eeb
|
Renato Botelho
|
<strong><?=gettext("NOTE:")?> </strong>
|
129 |
104c11c6
|
Scott Ullrich
|
</span>
|
130 |
9404a104
|
Renato Botelho
|
<?=gettext("The options on this page are intended for use by advanced users only.")?>
|
131 |
ae396e30
|
Scott Ullrich
|
<br/>
|
132 |
104c11c6
|
Scott Ullrich
|
</span>
|
133 |
ae396e30
|
Scott Ullrich
|
<p/>
|
134 |
104c11c6
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
135 |
|
|
<tr>
|
136 |
9404a104
|
Renato Botelho
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
|
137 |
104c11c6
|
Scott Ullrich
|
</tr>
|
138 |
b000d606
|
Scott Ullrich
|
<tr>
|
139 |
9404a104
|
Renato Botelho
|
<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
|
140 |
b000d606
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
141 |
e0d47cb9
|
Scott Ullrich
|
<?php echo $NANOBSD_SIZE; ?>
|
142 |
b000d606
|
Scott Ullrich
|
</td>
|
143 |
|
|
</tr>
|
144 |
104c11c6
|
Scott Ullrich
|
<tr>
|
145 |
9404a104
|
Renato Botelho
|
<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
|
146 |
104c11c6
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
147 |
|
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
148 |
aaaf679f
|
Carlos Eduardo Ramos
|
<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
|
149 |
9404a104
|
Renato Botelho
|
<br/><br/><?=gettext("This will switch the bootup slice to the alternate slice.");?>
|
150 |
104c11c6
|
Scott Ullrich
|
<br/>
|
151 |
2b5f276f
|
jim-p
|
<input type='hidden' name='bootslice' value='switch'>
|
152 |
|
|
<input type='submit' value='Switch Slice'></form>
|
153 |
104c11c6
|
Scott Ullrich
|
</td>
|
154 |
|
|
</tr>
|
155 |
|
|
<tr>
|
156 |
|
|
<td colspan="2" valign="top" class=""> </td>
|
157 |
|
|
</tr>
|
158 |
|
|
<tr>
|
159 |
9404a104
|
Renato Botelho
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
|
160 |
104c11c6
|
Scott Ullrich
|
</tr>
|
161 |
|
|
<tr>
|
162 |
9404a104
|
Renato Botelho
|
<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
|
163 |
104c11c6
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
164 |
c0948c6c
|
Renato Botelho
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
165 |
aaaf679f
|
Carlos Eduardo Ramos
|
<?=gettext("Destination slice:");?>
|
166 |
104c11c6
|
Scott Ullrich
|
<select name='destslice'>
|
167 |
|
|
<option value='<?php echo $COMPLETE_PATH; ?>'>
|
168 |
9cd8fd11
|
Scott Ullrich
|
<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
|
169 |
104c11c6
|
Scott Ullrich
|
</option>
|
170 |
|
|
</select>
|
171 |
|
|
<br/>
|
172 |
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.");?>
|
173 |
104c11c6
|
Scott Ullrich
|
</td>
|
174 |
|
|
</tr>
|
175 |
|
|
<tr>
|
176 |
28949aa1
|
Scott Ullrich
|
<td valign="top" class=""> </td><td><br/><input type='submit' value='Duplicate slice'></form></td>
|
177 |
104c11c6
|
Scott Ullrich
|
</tr>
|
178 |
85405c11
|
jim-p
|
<tr>
|
179 |
|
|
<td colspan="2" valign="top" class=""> </td>
|
180 |
|
|
</tr>
|
181 |
|
|
<tr>
|
182 |
|
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Periodic Data Backup");?></td>
|
183 |
|
|
</tr>
|
184 |
|
|
<tr>
|
185 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("RRD Backup");?></td>
|
186 |
|
|
<td width="78%" class="vtable">
|
187 |
|
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
188 |
aaaf679f
|
Carlos Eduardo Ramos
|
<?=gettext("Frequency:");?>
|
189 |
85405c11
|
jim-p
|
<select name='rrdbackup'>
|
190 |
aaaf679f
|
Carlos Eduardo Ramos
|
<option value='0' <? if (!isset($config['system']['rrdbackup']) || ($config['system']['rrdbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
191 |
85405c11
|
jim-p
|
<? for ($x=1; $x<=24; $x++) { ?>
|
192 |
aaaf679f
|
Carlos Eduardo Ramos
|
<option value='<?= $x ?>' <? if ($config['system']['rrdbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
|
193 |
85405c11
|
jim-p
|
<? } ?>
|
194 |
|
|
</select>
|
195 |
|
|
<br/>
|
196 |
|
|
<?=gettext("This will peridoically backup the RRD data so it can be restored automatically on the next boot. Keep in mind that the more frequent the backup, the more writes will happen to your media.");?>
|
197 |
|
|
<br/>
|
198 |
|
|
<br/>
|
199 |
|
|
</td>
|
200 |
|
|
</tr>
|
201 |
|
|
<tr>
|
202 |
|
|
<td width="22%" valign="top" class="vncell"><?=gettext("DHCP Leases Backup");?></td>
|
203 |
|
|
<td width="78%" class="vtable">
|
204 |
|
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
205 |
aaaf679f
|
Carlos Eduardo Ramos
|
<?=gettext("Frequency:");?>
|
206 |
85405c11
|
jim-p
|
<select name='dhcpbackup'>
|
207 |
aaaf679f
|
Carlos Eduardo Ramos
|
<option value='0' <? if (!isset($config['system']['dhcpbackup']) || ($config['system']['dhcpbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
208 |
85405c11
|
jim-p
|
<? for ($x=1; $x<=24; $x++) { ?>
|
209 |
aaaf679f
|
Carlos Eduardo Ramos
|
<option value='<?= $x ?>' <? if ($config['system']['dhcpbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
|
210 |
85405c11
|
jim-p
|
<? } ?>
|
211 |
|
|
</select>
|
212 |
|
|
<br/>
|
213 |
|
|
<?=gettext("This will peridoically backup the DHCP leases data so it can be restored automatically on the next boot. Keep in mind that the more frequent the backup, the more writes will happen to your media.");?>
|
214 |
|
|
<br/>
|
215 |
|
|
<br/>
|
216 |
|
|
</td>
|
217 |
|
|
</tr>
|
218 |
|
|
<tr>
|
219 |
aaaf679f
|
Carlos Eduardo Ramos
|
<td valign="top" class=""> </td><td><br/><input type='submit' value='<?=gettext("Save"); ?>'></form></td>
|
220 |
85405c11
|
jim-p
|
</tr>
|
221 |
bcb03f4b
|
Scott Ullrich
|
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
|
222 |
|
|
<tr>
|
223 |
|
|
<td colspan="2" valign="top" class=""> </td>
|
224 |
|
|
</tr>
|
225 |
|
|
<tr>
|
226 |
9404a104
|
Renato Botelho
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
|
227 |
bcb03f4b
|
Scott Ullrich
|
</tr>
|
228 |
|
|
<tr>
|
229 |
9404a104
|
Renato Botelho
|
<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
|
230 |
bcb03f4b
|
Scott Ullrich
|
<td width="78%" class="vtable">
|
231 |
|
|
<?php
|
232 |
|
|
if($_POST['viewupgradelog']) {
|
233 |
|
|
echo "<textarea name='log' cols='80' rows='40'>";
|
234 |
|
|
echo file_get_contents("/conf/upgrade_log.txt");
|
235 |
ad3c7724
|
Scott Ullrich
|
echo "\nFile list:\n";
|
236 |
dce5cc7c
|
Scott Ullrich
|
echo file_get_contents("/conf/file_upgrade_log.txt");
|
237 |
ad3c7724
|
Scott Ullrich
|
echo "\nMisc log:\n";
|
238 |
dce5cc7c
|
Scott Ullrich
|
echo file_get_contents("/conf/firmware_update_misc.log");
|
239 |
c5eb3a17
|
Scott Ullrich
|
echo "\nfdisk/bsdlabel log:\n";
|
240 |
|
|
echo file_get_contents("/conf/fdisk_upgrade_log.txt");
|
241 |
bcb03f4b
|
Scott Ullrich
|
echo "</textarea>";
|
242 |
|
|
} else {
|
243 |
|
|
echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
|
244 |
|
|
echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
|
245 |
|
|
}
|
246 |
|
|
?>
|
247 |
|
|
</td>
|
248 |
|
|
</tr>
|
249 |
|
|
<?php endif; ?>
|
250 |
104c11c6
|
Scott Ullrich
|
<tr>
|
251 |
|
|
<td colspan="2" valign="top" class=""> </td>
|
252 |
|
|
</tr>
|
253 |
|
|
</table>
|
254 |
|
|
</div>
|
255 |
|
|
</td>
|
256 |
|
|
</tr>
|
257 |
|
|
</table>
|
258 |
|
|
<?php require("fend.inc"); ?>
|
259 |
|
|
</body>
|
260 |
|
|
</html>
|
261 |
ae396e30
|
Scott Ullrich
|
|
262 |
|
|
<?php
|
263 |
|
|
|
264 |
be6e1e8a
|
Scott Ullrich
|
// Clear the loading indicator
|
265 |
ae396e30
|
Scott Ullrich
|
echo "<script type=\"text/javascript\">";
|
266 |
|
|
echo "$('loading').innerHTML = '';";
|
267 |
|
|
echo "</script>";
|
268 |
|
|
|
269 |
58cd9724
|
Renato Botelho
|
?>
|