Project

General

Profile

Download (7.19 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 ($savemsg)
104
	print_info_box($savemsg)
105

    
106
?>
107
<table width="100%" border="0" cellpadding="0" cellspacing="0">
108
	<tr>
109
		<td>
110
			<!-- tabs here if you want them -->
111
		</td>
112
	</tr>
113
	<tr>
114
		<td id="mainarea">
115
			<div class="tabcont">
116
				<span class="vexpl">
117
					<span class="red">
118
						<strong><?=gettext("NOTE") . ":"?>&nbsp;</strong>
119
					</span>
120
					<?=gettext("The options on this page are intended for use by advanced users only.")?>
121
					<br/>&nbsp;
122
				</span>
123
				<p/>
124
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
125
					<tr>
126
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Bootup information");?></td>
127
					</tr>
128
					<tr>						
129
						<td width="22%" valign="top" class="vncell"><?=gettext("NanoBSD Image size");?></td>
130
						<td width="78%" class="vtable">
131
							<?php echo $NANOBSD_SIZE; ?>
132
						</td>
133
					</tr>
134
					<tr>
135
						<td width="22%" valign="top" class="vncell"><?=gettext("Bootup");?></td>
136
						<td width="78%" class="vtable">
137
							<form action="diag_nanobsd.php" method="post" name="iform">
138
								<?=gettext("Bootup slice is currently");?>: <?php echo $ACTIVE_SLICE; ?>
139
								<br/><br/><?=gettext("This will switch the bootup slice to the alternate slice.");?>
140
								<br/>
141
								<input type='hidden' name='bootslice' value='switch'>
142
								<input type='submit' value='Switch Slice'></form>
143
						</td>
144
					</tr>
145
					<tr>
146
						<td colspan="2" valign="top" class="">&nbsp;</td>
147
					</tr>					
148
					<tr>
149
						<td colspan="2" valign="top" class="listtopic"><?=gettext("Duplicate bootup slice to alternate");?></td>
150
					</tr>
151
					<tr>
152
						<td width="22%" valign="top" class="vncell"><?=gettext("Duplicate bootup slice");?></td>
153
						<td width="78%" class="vtable">
154
							<form action="diag_nanobsd.php" method="post" name="iform">						
155
								<?=gettext("Destination slice");?>:							
156
								<select name='destslice'>
157
									<option value='<?php echo $COMPLETE_PATH; ?>'>
158
										<?php echo "{$COMPLETE_BOOT_PATH} -> {$TOFLASH}"; ?>
159
									</option>
160
								</select>
161
								<br/>
162
								<?=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.");?>
163
						</td>
164
					</tr>
165
					<tr>
166
						<td valign="top" class="">&nbsp;</td><td><br/><input type='submit' value='Duplicate slice'></form></td>
167
					</tr>
168
<?php if(file_exists("/conf/upgrade_log.txt")): ?>
169
					<tr>
170
						<td colspan="2" valign="top" class="">&nbsp;</td>
171
					</tr>					
172
					<tr>
173
						<td colspan="2" valign="top" class="listtopic"><?=gettext("View upgrade log");?></td>
174
					</tr>
175
					<tr>
176
						<td width="22%" valign="top" class="vncell"><?=gettext("View previous upgrade log");?></td>
177
						<td width="78%" class="vtable">
178
						<?php
179
							if($_POST['viewupgradelog']) {
180
								echo "<textarea name='log' cols='80' rows='40'>";
181
								echo file_get_contents("/conf/upgrade_log.txt");
182
								echo "\nFile list:\n";
183
								echo file_get_contents("/conf/file_upgrade_log.txt");
184
								echo "\nMisc log:\n";
185
								echo file_get_contents("/conf/firmware_update_misc.log");
186
								echo "\nfdisk/bsdlabel log:\n";
187
								echo file_get_contents("/conf/fdisk_upgrade_log.txt");
188
								echo "</textarea>";
189
							} else {
190
								echo "<form action='diag_nanobsd.php' method='post' name='iform'>";
191
								echo "<input type='submit' name='viewupgradelog' value='View upgrade log'>";
192
							}
193
						?>
194
						</td>
195
					</tr>
196
<?php endif; ?>
197
					<tr>
198
						<td colspan="2" valign="top" class="">&nbsp;</td>
199
					</tr>					
200
				</table>
201
			</div>
202
		</td>
203
	</tr>
204
</table>
205
<?php require("fend.inc"); ?>
206
</body>
207
</html>
208

    
209
<?php
210

    
211
// Clear the loading indicator
212
echo "<script type=\"text/javascript\">";
213
echo "$('loading').innerHTML = '';";
214
echo "</script>";	
215

    
216
?>
(27-27/222)