Project

General

Profile

Download (10.9 KB) Statistics
| Branch: | Tag: | Revision:
1 0b2e3c64 Colin Smith
<?php
2
/* $Id$ */
3
/*
4 2094568a Colin Smith
	system_firmware_settings.php
5 ce77a9c4 Phil Davis
	part of pfSense
6
	Copyright (C) 2005 Colin Smith
7 29aef6c4 Jim Thompson
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
8 ce77a9c4 Phil Davis
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9 0b2e3c64 Colin Smith
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31 1d333258 Scott Ullrich
/*
32
	pfSense_BUILDER_BINARIES:	/usr/bin/fetch
33
	pfSense_MODULE:	firmware
34
*/
35 0b2e3c64 Colin Smith
36 6b07c15a Matthew Grooms
##|+PRIV
37
##|*IDENT=page-system-firmware-settings
38
##|*NAME=System: Firmware: Settings page
39
##|*DESCR=Allow access to the 'System: Firmware: Settings' page.
40
##|*MATCH=system_firmware_settings.php*
41
##|-PRIV
42
43 0b2e3c64 Colin Smith
require("guiconfig.inc");
44
45
if ($_POST) {
46 a93bc299 Phil Davis
	unset($input_errors);
47
48
	/* input validation */
49
	if(($_POST['alturlenable'] == "yes") && (empty($_POST['firmwareurl']))) {
50
		$input_errors[] = gettext("A Firmware Auto Update Base URL must be specified when \"Use an unofficial server for firmware upgrades\" is enabled.");
51
	}
52
53 9471afe1 Colin Smith
	if (!$input_errors) {
54
		if($_POST['alturlenable'] == "yes") {
55 da55e467 Scott Ullrich
			$config['system']['firmware']['alturl']['enable'] = true;
56 9471afe1 Colin Smith
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
57
		} else {
58
			unset($config['system']['firmware']['alturl']['enable']);
59 da55e467 Scott Ullrich
			unset($config['system']['firmware']['alturl']['firmwareurl']);
60 52629104 Scott Ullrich
			unset($config['system']['firmware']['alturl']);
61 7a058f06 jim-p
			unset($config['system']['firmware']);
62 9471afe1 Colin Smith
		}
63 a0116247 Ermal
		if($_POST['allowinvalidsig'] == "yes")
64 7a058f06 jim-p
			$config['system']['firmware']['allowinvalidsig'] = true;
65
		else
66
			unset($config['system']['firmware']['allowinvalidsig']);
67
68
		if($_POST['disablecheck'] == "yes")
69
			$config['system']['firmware']['disablecheck'] = true;
70
		else
71
			unset($config['system']['firmware']['disablecheck']);
72 a0116247 Ermal
73 f0ce6758 Erik Fonnesbeck
		if($_POST['synconupgrade'] == "yes")
74
			$config['system']['gitsync']['synconupgrade'] = true;
75
		else
76
			unset($config['system']['gitsync']['synconupgrade']);
77
		$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
78
		$config['system']['gitsync']['branch'] = $_POST['branch'];
79
80 9471afe1 Colin Smith
		write_config();
81
	}
82 0b2e3c64 Colin Smith
}
83
84
$curcfg = $config['system']['firmware'];
85 f0ce6758 Erik Fonnesbeck
$gitcfg = $config['system']['gitsync'];
86 0b2e3c64 Colin Smith
87 8395f51e Carlos Eduardo Ramos
$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
88 4a76b802 Colin Fleming
$closehead = false;
89 52380979 Scott Ullrich
include("head.inc");
90
91 5f1c154d Renato Botelho
exec("/usr/bin/fetch -q -o {$g['tmp_path']}/manifest \"{$g['update_manifest']}\"");
92
if(file_exists("{$g['tmp_path']}/manifest")) {
93
	$preset_urls_split = explode("\n", file_get_contents("{$g['tmp_path']}/manifest"));
94 563f5b51 Scott Ullrich
}
95 52380979 Scott Ullrich
96 563f5b51 Scott Ullrich
?>
97 4a76b802 Colin Fleming
<script type="text/javascript">
98
//<![CDATA[
99 0b2e3c64 Colin Smith
100
101 9471afe1 Colin Smith
function enable_altfirmwareurl(enable_over) {  	 
102
	if (document.iform.alturlenable.checked || enable_over) { 	 
103
		document.iform.firmwareurl.disabled = 0; 	 
104
	} else { 	 
105 53075520 Scott Ullrich
		document.iform.firmwareurl.disabled = 1;
106 5d5f69a2 Scott Ullrich
		document.iform.firmwareurl.value = '';
107 9471afe1 Colin Smith
	} 	 
108
}
109
110 4a76b802 Colin Fleming
//]]>
111 0b2e3c64 Colin Smith
</script>
112 4a76b802 Colin Fleming
</head>
113 0b2e3c64 Colin Smith
114
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
115 b30cacb2 Bill Marquette
<?php include("fbegin.inc");?>
116 9471afe1 Colin Smith
<?php if ($input_errors) print_input_errors($input_errors); ?>
117 fd3e7e5d Scott Ullrich
118 0b2e3c64 Colin Smith
<form action="system_firmware_settings.php" method="post" name="iform" id="iform">
119
            <?php if ($savemsg) print_info_box($savemsg); ?>
120 4a76b802 Colin Fleming
              <table width="100%" border="0" cellpadding="0" cellspacing="0" summary="firmware settings">
121 0b2e3c64 Colin Smith
	<tr>
122
		<td>
123 4820d297 Scott Ullrich
<?php
124
	$tab_array = array();
125 3ff39566 Scott Ullrich
	$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
126
	$tab_array[] = array(gettext("Auto Update"), false, "system_firmware_check.php");
127
	$tab_array[] = array(gettext("Updater Settings"), true, "system_firmware_settings.php");
128
	if($g['hidedownloadbackup'] == false)
129
		$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
130 4820d297 Scott Ullrich
	display_top_tabs($tab_array);
131
?>
132 0b2e3c64 Colin Smith
		</td>
133
	</tr>
134 4a76b802 Colin Fleming
	<tr><td><div id="mainarea">
135
	      <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
136 0b2e3c64 Colin Smith
	<tr>
137 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></td>
138 0b2e3c64 Colin Smith
	</tr>
139 563f5b51 Scott Ullrich
<?php if(is_array($preset_urls_split)): ?>
140
	<tr>
141 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td>
142 563f5b51 Scott Ullrich
		<td class="vtable">
143 4a76b802 Colin Fleming
			<select name='preseturls' id='preseturls' onchange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; jQuery('#preseturls').parent().effect('highlight');">
144 563f5b51 Scott Ullrich
					<option></option>
145
				<?php 
146
					foreach($preset_urls_split as $pus) {
147 cfbfd941 smos
						$pus_text = explode("\t", $pus);
148 02f3e0bb jim-p
						if (empty($pus_text[0]))
149
							continue;
150
						if (stristr($pus_text[0], php_uname("m")) !== false) {
151
							$style = " style=\"font-weight: bold\"";
152
							$yourarch = " (Current architecture)";
153
						} else {
154
							$style = "";
155
							$yourarch = "";
156
						}
157
						echo "<option value='{$pus_text[1]}'{$style}>{$pus_text[0]}{$yourarch}</option>";
158 563f5b51 Scott Ullrich
					}
159
				?>
160
			</select>
161 8cd558b6 ayvis
		<br /><br /><?php echo sprintf(gettext("Entries denoted by \"Current architecture\" match the architecture of your current installation, such as %s. Changing architectures during an upgrade is not recommended, and may require a manual reboot after the update completes."), php_uname("m")); ?>
162 563f5b51 Scott Ullrich
		</td>
163
	</tr>
164
<?php endif; ?>
165 0b2e3c64 Colin Smith
	<tr>
166 8395f51e Carlos Eduardo Ramos
		<td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td>
167 9471afe1 Colin Smith
		<td class="vtable">
168 541e0b77 Chris Buechler
			<input name="alturlenable" type="checkbox" id="alturlenable" value="yes" onclick="enable_altfirmwareurl()" <?php if(isset($curcfg['alturl']['enable'])) echo "checked=\"checked\""; ?> /> <?=gettext("Use an unofficial server for firmware upgrades") ?><br />
169 4a76b802 Colin Fleming
			<table summary="alternative Base URL">
170
			<tr><td><?=gettext("Base URL:"); ?></td><td><input name="firmwareurl" type="text" class="formfld url" id="firmwareurl" size="64" value="<?php if($curcfg['alturl']['firmwareurl']) echo $curcfg['alturl']['firmwareurl']; else echo $g['']; ?>" /></td></tr>
171 9471afe1 Colin Smith
			</table>
172 359f32dc Scott Ullrich
			<span class="vexpl">
173 259159e0 Renato Botelho
				<?=gettext("This is where"); ?> <?php echo $g['product_name'] ?> <?=gettext("will check for newer firmware versions when the"); ?> <a href="system_firmware_check.php"><?=gettext("System: Firmware: Auto Update"); ?></a> <?=gettext("page is viewed."); ?>
174 8cd558b6 ayvis
				<br />
175 541e0b77 Chris Buechler
				<b><?=gettext("NOTE:"); ?></b> <?php printf(gettext("When a custom URL is configured, the system will not verify the image has an official digital signature")); ?>
176 359f32dc Scott Ullrich
				</span>
177
				</td>
178 9471afe1 Colin Smith
	</tr>
179 a0116247 Ermal
	<tr>
180
		<td colspan="2" class="list" height="12">&nbsp;</td>
181
	</tr>
182
	<tr>
183 8395f51e Carlos Eduardo Ramos
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></td>
184 a0116247 Ermal
	</tr>
185
	<tr>
186 3395ba20 jim-p
		<td width="22%" valign="top" class="vncell"><?=gettext("Unsigned images"); ?></td>
187 a0116247 Ermal
		<td width="78%" class="vtable">
188 4a76b802 Colin Fleming
			<input name="allowinvalidsig" type="checkbox" id="allowinvalidsig" value="yes" <?php if (isset($curcfg['allowinvalidsig'])) echo "checked=\"checked\""; ?> />
189 a0116247 Ermal
			<br />
190 3395ba20 jim-p
			<?=gettext("Allow auto-update firmware images with a missing or invalid digital signature to be used."); ?>
191 a0116247 Ermal
		</td>
192
	</tr>
193 7a058f06 jim-p
	<tr>
194
		<td width="22%" valign="top" class="vncell"><?=gettext("Dashboard check"); ?></td>
195
		<td width="78%" class="vtable">
196 4a76b802 Colin Fleming
			<input name="disablecheck" type="checkbox" id="disablecheck" value="yes" <?php if (isset($curcfg['disablecheck'])) echo "checked=\"checked\""; ?> />
197 7a058f06 jim-p
			<br />
198
			<?=gettext("Disable the automatic dashboard auto-update check."); ?>
199
		</td>
200
	</tr>
201 2d539f40 Erik Fonnesbeck
<?php if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): ?>
202 f0ce6758 Erik Fonnesbeck
	<tr>
203
		<td colspan="2" class="list" height="12">&nbsp;</td>
204
	</tr>
205
	<tr>
206
		<td colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></td>
207
	</tr>
208
	<tr>
209
		<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
210
		<td width="78%" class="vtable">
211 4a76b802 Colin Fleming
			<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked=\"checked\""; ?> />
212 f0ce6758 Erik Fonnesbeck
			<br />
213
			<?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
214
		</td>
215
	</tr>
216 b5efd82a Erik Fonnesbeck
<?php
217
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
218
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str);
219
		if(is_array($output_str) && !empty($output_str[0]))
220
			$lastrepositoryurl = $output_str[0];
221
		unset($output_str);
222
	}
223
?>
224 f0ce6758 Erik Fonnesbeck
	<tr>
225
		<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
226
		<td width="78%" class="vtable">
227 de467f00 N0YB
			<input name="repositoryurl" type="text" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>" />
228 b5efd82a Erik Fonnesbeck
<?php if($lastrepositoryurl): ?>
229
			<br />
230
			<?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?>
231
			<br />
232
			<?=gettext("This will be used if the field is left blank."); ?>
233
<?php endif; ?>
234 f0ce6758 Erik Fonnesbeck
		</td>
235
	</tr>
236 b5efd82a Erik Fonnesbeck
<?php
237
	if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
238
		exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str);
239
		if(is_array($output_str)) {
240
			foreach($output_str as $output_line) {
241
				if(strstr($output_line, '* ')) {
242
					$lastbranch = substr($output_line, 2);
243
					break;
244
				}
245
			}
246
		}
247
		unset($output_str);
248
	}
249
?>
250 f0ce6758 Erik Fonnesbeck
	<tr>
251
		<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
252
		<td width="78%" class="vtable">
253 de467f00 N0YB
			<input name="branch" type="text" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>" />
254 b5efd82a Erik Fonnesbeck
<?php if($lastbranch): ?>
255
			<br />
256
			<?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?>
257
<?php else: ?>
258
			<br />
259
			<?=gettext("Usually the branch name is master"); ?>
260
<?php endif; ?>
261 f0ce6758 Erik Fonnesbeck
			<br />
262 b5efd82a Erik Fonnesbeck
			<?=gettext("Note: Sync will not be performed if a branch is not specified."); ?>
263 f0ce6758 Erik Fonnesbeck
		</td>
264
	</tr>
265
<?php endif; ?>
266 4a76b802 Colin Fleming
	<tr><td><script type="text/javascript">
267
	//<![CDATA[
268
	enable_altfirmwareurl();
269
	//]]>
270
	</script></td></tr>
271 0b2e3c64 Colin Smith
                <tr>
272
                  <td width="22%" valign="top">&nbsp;</td>
273
                  <td width="78%">
274 4a76b802 Colin Fleming
                    <input name="Submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
275 0b2e3c64 Colin Smith
                  </td>
276
                </tr>
277 e12d98ea Bill Marquette
              </table></div></td></tr></table>
278 0b2e3c64 Colin Smith
</form>
279
<?php include("fend.inc"); ?>
280
</body>
281
</html>