1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
system_firmware_check.php
|
5
|
Copyright (C) 2008 Scott Ullrich <sullrich@gmail.com>
|
6
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
7
|
All rights reserved.
|
8
|
|
9
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
10
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
All rights reserved.
|
12
|
|
13
|
Redistribution and use in source and binary forms, with or without
|
14
|
modification, are permitted provided that the following conditions are met:
|
15
|
|
16
|
1. Redistributions of source code must retain the above copyright notice,
|
17
|
this list of conditions and the following disclaimer.
|
18
|
|
19
|
2. Redistributions in binary form must reproduce the above copyright
|
20
|
notice, this list of conditions and the following disclaimer in the
|
21
|
documentation and/or other materials provided with the distribution.
|
22
|
|
23
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
24
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
25
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
26
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
27
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
POSSIBILITY OF SUCH DAMAGE.
|
33
|
*/
|
34
|
/*
|
35
|
pfSense_MODULE: firmware
|
36
|
*/
|
37
|
|
38
|
##|+PRIV
|
39
|
##|*IDENT=page-system-firmware-autoupdate
|
40
|
##|*NAME=System: Firmware: Auto Update page
|
41
|
##|*DESCR=Allow access to the 'System: Firmware: Auto Update' page.
|
42
|
##|*MATCH=system_firmware_check.php*
|
43
|
##|-PRIV
|
44
|
|
45
|
$d_isfwfile = 1;
|
46
|
require("guiconfig.inc");
|
47
|
require_once("pfsense-utils.inc");
|
48
|
|
49
|
$curcfg = $config['system']['firmware'];
|
50
|
$pgtitle=array(gettext("System"), gettext("Firmware"), gettext("Auto Update"));
|
51
|
include("head.inc");
|
52
|
|
53
|
$tab_array = array();
|
54
|
$tab_array[] = array(gettext("Manual Update"), false, "system_firmware.php");
|
55
|
$tab_array[] = array(gettext("Auto Update"), true, "system_firmware_check.php");
|
56
|
$tab_array[] = array(gettext("Updater Settings"), false, "system_firmware_settings.php");
|
57
|
if($g['hidedownloadbackup'] == false)
|
58
|
$tab_array[] = array(gettext("Restore Full Backup"), false, "system_firmware_restorefullbackup.php");
|
59
|
display_top_tabs($tab_array);
|
60
|
?>
|
61
|
|
62
|
<form action="system_firmware_auto.php" method="post">
|
63
|
<div id="statusheading" class="panel panel-default">
|
64
|
<div class="panel-heading"><?=gettext('Update progress')?></div>
|
65
|
<div class="panel-body" name="output" id="output"></div>
|
66
|
</div>
|
67
|
|
68
|
<div id="backupdiv" style="visibility:hidden">
|
69
|
<?php if ($g['hidebackupbeforeupgrade'] === false): ?>
|
70
|
<br /><input type="checkbox" name="backupbeforeupgrade" id="backupbeforeupgrade" /><?=gettext("Perform full backup prior to upgrade")?>
|
71
|
<?php endif; ?>
|
72
|
</div>
|
73
|
<br />
|
74
|
<input id='invokeupgrade' class="btn btn-warning" style='visibility:hidden' type="submit" value="<?=gettext("Invoke Auto Upgrade"); ?>" />
|
75
|
|
76
|
<?php
|
77
|
|
78
|
/* Define necessary variables. */
|
79
|
if(isset($curcfg['alturl']['enable']))
|
80
|
$updater_url = "{$config['system']['firmware']['alturl']['firmwareurl']}";
|
81
|
else
|
82
|
$updater_url = $g['update_url'];
|
83
|
|
84
|
$needs_system_upgrade = false;
|
85
|
$static_text .= gettext("Downloading new version information...");
|
86
|
|
87
|
$nanosize = "";
|
88
|
if ($g['platform'] == "nanobsd") {
|
89
|
if (file_exists("/etc/nano_use_vga.txt"))
|
90
|
$nanosize = "-nanobsd-vga-";
|
91
|
else
|
92
|
$nanosize = "-nanobsd-";
|
93
|
|
94
|
$nanosize .= strtolower(trim(file_get_contents("/etc/nanosize.txt")));
|
95
|
}
|
96
|
|
97
|
if(download_file_with_progress_bar("{$updater_url}/version{$nanosize}", "/tmp/{$g['product_name']}_version", 'read_body', 5, 5) === true)
|
98
|
$remote_version = trim(@file_get_contents("/tmp/{$g['product_name']}_version"));
|
99
|
|
100
|
$static_text .= gettext("done") . "<br />";
|
101
|
|
102
|
if (!$remote_version) {
|
103
|
$static_text .= gettext("Unable to check for updates.") . "<br />";
|
104
|
|
105
|
if(isset($curcfg['alturl']['enable']))
|
106
|
$static_text .= gettext("Could not contact custom update server.") . "<br />";
|
107
|
else
|
108
|
$static_text .= sprintf(gettext('Could not contact %1$s update server %2$s%3$s'), $g['product_name'], $updater_url, "\\n");
|
109
|
|
110
|
panel_heading_class('danger');
|
111
|
} else {
|
112
|
$static_text .= gettext("Obtaining current version information...");
|
113
|
panel_text($static_text);
|
114
|
|
115
|
$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
|
116
|
$current_installed_version = trim(file_get_contents("/etc/version"));
|
117
|
|
118
|
$static_text .= "done<br />";
|
119
|
panel_text($static_text);
|
120
|
|
121
|
if (pfs_version_compare($current_installed_buildtime, $current_installed_version, $remote_version) == -1) {
|
122
|
$needs_system_upgrade = true;
|
123
|
} else {
|
124
|
$static_text .= "<br />" . gettext("You are on the latest version.") . "<br />";
|
125
|
panel_text($static_text);
|
126
|
panel_heading_class('success');
|
127
|
}
|
128
|
}
|
129
|
|
130
|
update_output_window($static_text);
|
131
|
if ($needs_system_upgrade == false) {
|
132
|
print("</form>");
|
133
|
require("foot.inc");
|
134
|
|
135
|
exit;
|
136
|
}
|
137
|
?>
|
138
|
<script>
|
139
|
events.push(function(){
|
140
|
$('#invokeupgrade').css('visibility','visible');
|
141
|
$('#backupdiv').css('visibility','visible');
|
142
|
});
|
143
|
</script>
|
144
|
<?php
|
145
|
|
146
|
$txt = gettext("A new version is now available") . "<br />";
|
147
|
$txt .= gettext("Current version") .": ". $current_installed_version . "<br />";
|
148
|
if ($g['platform'] == "nanobsd") {
|
149
|
$txt .= " " . gettext("NanoBSD Size") . " : " . trim(file_get_contents("/etc/nanosize.txt")) . "<br />";
|
150
|
}
|
151
|
$txt .= " " . gettext("Built On") .": ". $current_installed_buildtime . "<br />";
|
152
|
$txt .= " " . gettext("New version") .": ". htmlspecialchars($remote_version, ENT_QUOTES | ENT_HTML401). "<br /><br />";
|
153
|
$txt .= " " . gettext("Update source") .": ". $updater_url . "<br />";
|
154
|
panel_text($txt);
|
155
|
panel_heading_class('info');
|
156
|
?>
|
157
|
|
158
|
</form>
|
159
|
<?php
|
160
|
|
161
|
// Update the class of the message panel so that it's color changes
|
162
|
// Use danger, success, info, warning, default etc
|
163
|
function panel_heading_class($newclass = 'default') {
|
164
|
?>
|
165
|
<script>
|
166
|
events.push(function(){
|
167
|
$('#statusheading').removeClass().addClass('panel panel-' + '<?=$newclass?>');
|
168
|
});
|
169
|
</script>
|
170
|
<?php
|
171
|
}
|
172
|
|
173
|
// Update the text in the panel-heading
|
174
|
function panel_text($text) {
|
175
|
?>
|
176
|
<script>
|
177
|
events.push(function(){
|
178
|
$('#output').html('<?=$text?>');
|
179
|
});
|
180
|
</script>
|
181
|
<?php
|
182
|
}
|
183
|
|
184
|
include("foot.inc");
|