system_firmware_settings.php 11.3 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4 5 6 7
	Copyright (C) 2014 Deciso B.V.
	Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
	Copyright (C) 2005 Colin Smith
	All rights reserved.
Ad Schellevis's avatar
Ad Schellevis committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:

	1. Redistributions of source code must retain the above copyright notice,
	   this list of conditions and the following disclaimer.

	2. Redistributions in binary form must reproduce the above copyright
	   notice, this list of conditions and the following disclaimer in the
	   documentation and/or other materials provided with the distribution.

	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
	POSSIBILITY OF SUCH DAMAGE.
*/

31
require_once('guiconfig.inc');
Ad Schellevis's avatar
Ad Schellevis committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

if ($_POST) {
	if (!$input_errors) {
		if($_POST['alturlenable'] == "yes") {
			$config['system']['firmware']['alturl']['enable'] = true;
			$config['system']['firmware']['alturl']['firmwareurl'] = $_POST['firmwareurl'];
		} else {
			unset($config['system']['firmware']['alturl']['enable']);
			unset($config['system']['firmware']['alturl']['firmwareurl']);
			unset($config['system']['firmware']['alturl']);
			unset($config['system']['firmware']);
		}

		if($_POST['disablecheck'] == "yes")
			$config['system']['firmware']['disablecheck'] = true;
		else
			unset($config['system']['firmware']['disablecheck']);

		if($_POST['synconupgrade'] == "yes")
			$config['system']['gitsync']['synconupgrade'] = true;
		else
			unset($config['system']['gitsync']['synconupgrade']);
		$config['system']['gitsync']['repositoryurl'] = $_POST['repositoryurl'];
		$config['system']['gitsync']['branch'] = $_POST['branch'];

		write_config();
	}
}

$curcfg = $config['system']['firmware'];
$gitcfg = $config['system']['gitsync'];

$pgtitle = array(gettext("System"),gettext("Firmware"),gettext("Settings"));
$closehead = false;
include("head.inc");

68 69 70
exec("/usr/bin/fetch -q -o /tmp/manifest \"{$g['update_manifest']}\"");
if (file_exists('/tmp/manifest')) {
	$preset_urls_split = explode("\n", file_get_contents('/tmp/manifest'));
Ad Schellevis's avatar
Ad Schellevis committed
71 72 73
}

?>
74 75 76 77


<body>

Ad Schellevis's avatar
Ad Schellevis committed
78 79 80 81
<script type="text/javascript">
//<![CDATA[


82 83 84 85
function enable_altfirmwareurl(enable_over) {
	if (document.iform.alturlenable.checked || enable_over) {
		document.iform.firmwareurl.disabled = 0;
	} else {
Ad Schellevis's avatar
Ad Schellevis committed
86 87
		document.iform.firmwareurl.disabled = 1;
		document.iform.firmwareurl.value = '';
88
	}
Ad Schellevis's avatar
Ad Schellevis committed
89 90 91 92 93 94 95
}

//]]>
</script>

<?php include("fbegin.inc");?>

96 97 98
<!-- row -->
<section class="page-content-main">
	<div class="container-fluid">
99

100 101
        <div class="row">
            <?php
102 103
		if ($input_errors) print_input_errors($input_errors);
		if ($savemsg) print_info_box($savemsg);
104 105
            ?>
            <section class="col-xs-12">
106 107 108

                <? include('system_firmware_tabs.php'); ?>

109 110 111
                <div class="content-box tab-content">

                    <form action="system_firmware_settings.php" method="post" name="iform" id="iform">
112

113
                        <table class="table table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area" style="display:none"> <!--Unsupported Feuature, hide it-->
114 115 116 117 118 119
			    <thead>
				    <tr>
					<th colspan="2" valign="top" class="listtopic"><?=gettext("Firmware Branch"); ?></th>
				</tr>
			    </thead>

120
                            <tbody>
121

122
                            <?php if(is_array($preset_urls_split)): ?>
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
				<tr>
					<td valign="top" class="vncell"><?=gettext("Default Auto Update URLs"); ?></td>
					<td class="vtable">
						<select name='preseturls' id='preseturls' onchange="firmwareurl.value = preseturls.value; document.iform.firmwareurl.disabled = 0; alturlenable.checked=true; jQuery('#preseturls').parent().effect('highlight');">
								<option></option>
							<?php
								foreach($preset_urls_split as $pus) {
									$pus_text = explode("\t", $pus);
									if (empty($pus_text[0]))
										continue;
									if (stristr($pus_text[0], php_uname("m")) !== false) {
										$style = " style=\"font-weight: bold\"";
										$yourarch = " (Current architecture)";
									} else {
										$style = "";
										$yourarch = "";
									}
									echo "<option value='{$pus_text[1]}'{$style}>{$pus_text[0]}{$yourarch}</option>";
								}
							?>
						</select>
					<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")); ?>
					</td>
				</tr>
147
                            <?php endif; ?>
148 149 150 151 152 153 154 155 156 157 158
				<tr>
					<td valign="top" class="vncell"><?=gettext("Firmware Auto Update URL"); ?></td>
					<td class="vtable">
						<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 />
						<table summary="alternative Base URL">
						<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>
						</table>
						<span class="vexpl">
							<?=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."); ?>
							<br />
							<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")); ?>
159 160
                                        </span>
                                    </td>
161
				</tr>
162 163
                            </tbody>
                        </table>
164

165 166
                        <table class="table table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
                            <thead>
167 168 169
				    <tr>
					<th colspan="2" valign="top" class="listtopic"><?=gettext("Updates"); ?></th>
				</tr>
170
                            </thead>
171

172
                            <tbody>
173 174 175 176 177 178 179 180
				<tr>
					<td width="22%" valign="top" class="vncell"><?=gettext("Dashboard check"); ?></td>
					<td width="78%" class="vtable">
						<input name="disablecheck" type="checkbox" id="disablecheck" value="yes" <?php if (isset($curcfg['disablecheck'])) echo "checked=\"checked\""; ?> />
						<br />
						<?=gettext("Disable the automatic dashboard auto-update check."); ?>
					</td>
				</tr>
181 182
                            </tbody>
                        </table>
183 184

                        <?php if(file_exists("/usr/local/bin/git") && $g['platform'] == "pfSense"): ?>
185
                        <table class="table table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area" style="display:none"> <!--Unsupported Feuature, hide it-->
186

187
                            <thead>
188 189 190
				    <tr>
					<th colspan="2" valign="top" class="listtopic"><?=gettext("Gitsync"); ?></th>
				</tr>
191
                            </thead>
192 193 194 195 196 197 198 199 200 201 202

				<tbody>

				<tr>
					<td width="22%" valign="top" class="vncell"><?=gettext("Auto sync on update"); ?></td>
					<td width="78%" class="vtable">
						<input name="synconupgrade" type="checkbox" id="synconupgrade" value="yes" <?php if (isset($gitcfg['synconupgrade'])) echo "checked=\"checked\""; ?> />
						<br />
						<?=gettext("After updating, sync with the following repository/branch before reboot."); ?>
					</td>
				</tr>
203
                                <?php
204 205 206 207 208 209
					if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
						exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git config remote.origin.url", $output_str);
						if(is_array($output_str) && !empty($output_str[0]))
							$lastrepositoryurl = $output_str[0];
						unset($output_str);
					}
210
                                ?>
211 212 213 214
				<tr>
					<td width="22%" valign="top" class="vncell"><?=gettext("Repository URL"); ?></td>
					<td width="78%" class="vtable">
						<input name="repositoryurl" type="text" class="formfld url" id="repositoryurl" size="64" value="<?php if ($gitcfg['repositoryurl']) echo $gitcfg['repositoryurl']; ?>" />
215
                                        <?php if($lastrepositoryurl): ?>
216
						    <br />
217 218 219 220
                                            <?=sprintf(gettext("The most recently used repository was %s"), $lastrepositoryurl); ?>
                                            <br />
                                            <?=gettext("This will be used if the field is left blank."); ?>
                                        <?php endif; ?>
221 222
					</td>
				</tr>
223
                                <?php
224 225 226 227 228 229 230 231 232 233 234 235
					if(is_dir("/root/pfsense/pfSenseGITREPO/pfSenseGITREPO")) {
						exec("cd /root/pfsense/pfSenseGITREPO/pfSenseGITREPO && git branch", $output_str);
						if(is_array($output_str)) {
							foreach($output_str as $output_line) {
								if(strstr($output_line, '* ')) {
									$lastbranch = substr($output_line, 2);
									break;
								}
							}
						}
						unset($output_str);
					}
236
                                ?>
237 238 239 240
				<tr>
					<td width="22%" valign="top" class="vncell"><?=gettext("Branch name"); ?></td>
					<td width="78%" class="vtable">
						<input name="branch" type="text" class="formfld unknown" id="branch" size="64" value="<?php if ($gitcfg['branch']) echo $gitcfg['branch']; ?>" />
241
                                        <?php if($lastbranch): ?>
242
						    <br />
243 244
                                            <?=sprintf(gettext("The most recently used branch was %s"), $lastbranch); ?>
                                        <?php else: ?>
245
						    <br />
246 247
                                            <?=gettext("Usually the branch name is master"); ?>
                                        <?php endif; ?>
248 249 250 251 252 253
						<br />
						<?=gettext("Note: Sync will not be performed if a branch is not specified."); ?>
					</td>
				</tr>
				</tbody>

254 255
                        </table>
                        <?php endif; ?>
256 257

                        <table class="table table-striped __nomb" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
258 259 260 261 262 263 264
                           <tr>
                                <td width="22%" valign="top">&nbsp;</td>
                                <td width="78%">
                                    <input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save"); ?>" />
                                </td>
                            </tr>
                        </table>
265 266

			</form>
267 268 269 270 271 272 273 274 275 276 277 278 279

                </div>
            </section>
        </div>
	</div>
</section>

<script type="text/javascript">
//<![CDATA[
enable_altfirmwareurl();
//]]>
</script>

280
<?php include("foot.inc"); ?>