Project

General

Profile

Download (9.85 KB) Statistics
| Branch: | Tag: | Revision:
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
<script src="/javascript/scriptaculous/prototype.js" type="text/javascript"></script>
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/metallic/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/metallic/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 (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
if ($savemsg)
114
	print_info_box($savemsg)
115

    
116
?>
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
						<strong><?=gettext("NOTE:")?>&nbsp;</strong>
129
					</span>
130
					<?=gettext("The options on this page are intended for use by advanced users only.")?>
131
					<br/>&nbsp;
132
				</span>
133
				<p/>
134
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
135
					<tr>
136
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
137
					</tr>
138
					<tr>						
139
						<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
140
						<td width="78%" class="vtable">
141
							<?php echo $NANOBSD_SIZE; ?>
142
						</td>
143
					</tr>
144
					<tr>
145
						<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
146
						<td width="78%" class="vtable">
147
							<form action="diag_nanobsd.php" method="post" name="iform">
148
								<?=gettext("Bootup slice is currently:");?> <?php echo $ACTIVE_SLICE; ?>
149
								<br/><br/><?=gettext("This will switch the bootup slice to the alternate slice.");?>
150
								<br/>
151
								<input type='hidden' name='bootslice' value='switch'>
152
								<input type='submit' value='Switch Slice'></form>
153
						</td>
154
					</tr>
155
					<tr>
156
						<td colspan="2" valign="top" class="">&nbsp;</td>
157
					</tr>					
158
					<tr>
159
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
160
					</tr>
161
					<tr>
162
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
163
						<td width="78%" class="vtable">
164
							<form action="diag_nanobsd.php" method="post" name="iform">						
165
								<?=gettext("Destination slice:");?>
166
								<select name='destslice'>
167
									<option value='<?php echo $COMPLETE_PATH; ?>'>
168
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
169
									</option>
170
								</select>
171
								<br/>
172
								<?=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
						</td>
174
					</tr>
175
					<tr>
176
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Duplicate slice'></form></td>
177
					</tr>
178
					<tr>
179
						<td colspan="2" valign="top" class="">&nbsp;</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
								<?=gettext("Frequency:");?>
189
								<select name='rrdbackup'>
190
									<option value='0' <? if (!isset($config['system']['rrdbackup']) || ($config['system']['rrdbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
191
								<? for ($x=1; $x<=24; $x++) { ?>
192
									<option value='<?= $x ?>' <? if ($config['system']['rrdbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
193
								<? } ?>
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
								<?=gettext("Frequency:");?>
206
								<select name='dhcpbackup'>
207
									<option value='0' <? if (!isset($config['system']['dhcpbackup']) || ($config['system']['dhcpbackup'] == 0)) echo "selected"; ?>><?=gettext("Disable"); ?></option>
208
								<? for ($x=1; $x<=24; $x++) { ?>
209
									<option value='<?= $x ?>' <? if ($config['system']['dhcpbackup'] == $x) echo "selected"; ?>><?= $x ?> <?=gettext("hour"); ?><? if ($x>1) echo "s"; ?></option>
210
								<? } ?>
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
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='<?=gettext("Save"); ?>'></form></td>
220
					</tr>
221
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
222
					<tr>
223
						<td colspan="2" valign="top" class="">&nbsp;</td>
224
					</tr>					
225
					<tr>
226
						<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
227
					</tr>
228
					<tr>
229
						<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
230
						<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
								echo "\nFile list:\n";
236
								echo file_get_contents("/conf/file_upgrade_log.txt");
237
								echo "\nMisc log:\n";
238
								echo file_get_contents("/conf/firmware_update_misc.log");
239
								echo "\nfdisk/bsdlabel log:\n";
240
								echo file_get_contents("/conf/fdisk_upgrade_log.txt");
241
								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
					<tr>
251
						<td colspan="2" valign="top" class="">&nbsp;</td>
252
					</tr>					
253
				</table>
254
			</div>
255
		</td>
256
	</tr>
257
</table>
258
<?php require("fend.inc"); ?>
259
</body>
260
</html>
261

    
262
<?php
263

    
264
// Clear the loading indicator
265
echo "<script type=\"text/javascript\">";
266
echo "$('loading').innerHTML = '';";
267
echo "</script>";	
268

    
269
?>
(27-27/222)