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 /sbin/sysctl /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/metallic/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/metallic/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 (isset($_POST['rrdbackup'])) {
|
103
|
$config['system']['rrdbackup'] = $_POST['rrdbackup'];
|
104
|
install_cron_job("/etc/rc.backup_rrd.sh", ($config['system']['rrdbackup'] > 0), $minute="0", "*/{$config['system']['rrdbackup']}");
|
105
|
}
|
106
|
if (isset($_POST['dhcpbackup'])) {
|
107
|
$config['system']['dhcpbackup'] = $_POST['dhcpbackup'];
|
108
|
install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}");
|
109
|
}
|
110
|
|
111
|
|
112
|
if ($savemsg)
|
113
|
print_info_box($savemsg)
|
114
|
|
115
|
?>
|
116
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
117
|
<tr>
|
118
|
<td>
|
119
|
<!-- tabs here if you want them -->
|
120
|
</td>
|
121
|
</tr>
|
122
|
<tr>
|
123
|
<td id="mainarea">
|
124
|
<div class="tabcont">
|
125
|
<span class="vexpl">
|
126
|
<span class="red">
|
127
|
<strong><?=gettext("NOTE:")?> </strong>
|
128
|
</span>
|
129
|
<?=gettext("The options on this page are intended for use by advanced users only.")?>
|
130
|
<br/>
|
131
|
</span>
|
132
|
<p/>
|
133
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
134
|
<tr>
|
135
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
|
136
|
</tr>
|
137
|
<tr>
|
138
|
<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
|
139
|
<td width="78%" class="vtable">
|
140
|
<?php echo $NANOBSD_SIZE; ?>
|
141
|
</td>
|
142
|
</tr>
|
143
|
<tr>
|
144
|
<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
|
145
|
<td width="78%" class="vtable">
|
146
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
147
|
<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
|
148
|
<br/><br/><?=gettext("This will switch the bootup slice to the alternate slice.");?>
|
149
|
<br/>
|
150
|
<input type='hidden' name='bootslice' value='switch'>
|
151
|
<input type='submit' value='Switch Slice'></form>
|
152
|
</td>
|
153
|
</tr>
|
154
|
<tr>
|
155
|
<td colspan="2" valign="top" class=""> </td>
|
156
|
</tr>
|
157
|
<tr>
|
158
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
|
159
|
</tr>
|
160
|
<tr>
|
161
|
<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
|
162
|
<td width="78%" class="vtable">
|
163
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
164
|
<?=gettext("Destination slice:");?>
|
165
|
<select name='destslice'>
|
166
|
<option value='<?php echo $COMPLETE_PATH; ?>'>
|
167
|
<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
|
168
|
</option>
|
169
|
</select>
|
170
|
<br/>
|
171
|
<?=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.");?>
|
172
|
</td>
|
173
|
</tr>
|
174
|
<tr>
|
175
|
<td valign="top" class=""> </td><td><br/><input type='submit' value='Duplicate slice'></form></td>
|
176
|
</tr>
|
177
|
<tr>
|
178
|
<td colspan="2" valign="top" class=""> </td>
|
179
|
</tr>
|
180
|
<tr>
|
181
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("Periodic Data Backup");?></td>
|
182
|
</tr>
|
183
|
<tr>
|
184
|
<td width="22%" valign="top" class="vncell"><?=gettext("RRD Backup");?></td>
|
185
|
<td width="78%" class="vtable">
|
186
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
187
|
<?=gettext("Frequency:");?>
|
188
|
<select name='rrdbackup'>
|
189
|
<option value='0' <? if (!isset($config['system']['rrdbackup']) || ($config['system']['rrdbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
190
|
<? for ($x=1; $x<=24; $x++) { ?>
|
191
|
<option value='<?= $x ?>' <? if ($config['system']['rrdbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
|
192
|
<? } ?>
|
193
|
</select>
|
194
|
<br/>
|
195
|
<?=gettext("This will periodically 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.");?>
|
196
|
<br/>
|
197
|
<br/>
|
198
|
</td>
|
199
|
</tr>
|
200
|
<tr>
|
201
|
<td width="22%" valign="top" class="vncell"><?=gettext("DHCP Leases Backup");?></td>
|
202
|
<td width="78%" class="vtable">
|
203
|
<form action="diag_nanobsd.php" method="post" name="iform">
|
204
|
<?=gettext("Frequency:");?>
|
205
|
<select name='dhcpbackup'>
|
206
|
<option value='0' <? if (!isset($config['system']['dhcpbackup']) || ($config['system']['dhcpbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
|
207
|
<? for ($x=1; $x<=24; $x++) { ?>
|
208
|
<option value='<?= $x ?>' <? if ($config['system']['dhcpbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
|
209
|
<? } ?>
|
210
|
</select>
|
211
|
<br/>
|
212
|
<?=gettext("This will periodically 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.");?>
|
213
|
<br/>
|
214
|
<br/>
|
215
|
</td>
|
216
|
</tr>
|
217
|
<tr>
|
218
|
<td valign="top" class=""> </td><td><br/><input type='submit' value='<?=gettext("Save"); ?>'></form></td>
|
219
|
</tr>
|
220
|
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
|
221
|
<tr>
|
222
|
<td colspan="2" valign="top" class=""> </td>
|
223
|
</tr>
|
224
|
<tr>
|
225
|
<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
|
226
|
</tr>
|
227
|
<tr>
|
228
|
<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
|
229
|
<td width="78%" class="vtable">
|
230
|
<?php
|
231
|
if($_POST['viewupgradelog']) {
|
232
|
echo "<textarea name='log' cols='80' rows='40'>";
|
233
|
echo file_get_contents("/conf/upgrade_log.txt");
|
234
|
echo "\nFile list:\n";
|
235
|
echo file_get_contents("/conf/file_upgrade_log.txt");
|
236
|
echo "\nMisc log:\n";
|
237
|
echo file_get_contents("/conf/firmware_update_misc_log.txt");
|
238
|
echo "\nfdisk/bsdlabel log:\n";
|
239
|
echo file_get_contents("/conf/fdisk_upgrade_log.txt");
|
240
|
echo "</textarea>";
|
241
|
} else {
|
242
|
echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
|
243
|
echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
|
244
|
}
|
245
|
?>
|
246
|
</td>
|
247
|
</tr>
|
248
|
<?php endif; ?>
|
249
|
<tr>
|
250
|
<td colspan="2" valign="top" class=""> </td>
|
251
|
</tr>
|
252
|
</table>
|
253
|
</div>
|
254
|
</td>
|
255
|
</tr>
|
256
|
</table>
|
257
|
<?php require("fend.inc"); ?>
|
258
|
</body>
|
259
|
</html>
|
260
|
|
261
|
<?php
|
262
|
|
263
|
// Clear the loading indicator
|
264
|
echo "<script type=\"text/javascript\">";
|
265
|
echo "jQuery('#loading').html('');";
|
266
|
echo "</script>";
|
267
|
|
268
|
?>
|