2 title
: L
.tr('Flash operations'),
4 testUpgrade
: L
.rpc
.declare({
5 object
: 'luci2.system',
6 method
: 'upgrade_test',
10 startUpgrade
: L
.rpc
.declare({
11 object
: 'luci2.system',
12 method
: 'upgrade_start',
16 cleanUpgrade
: L
.rpc
.declare({
17 object
: 'luci2.system',
18 method
: 'upgrade_clean'
21 restoreBackup
: L
.rpc
.declare({
22 object
: 'luci2.system',
23 method
: 'backup_restore'
26 cleanBackup
: L
.rpc
.declare({
27 object
: 'luci2.system',
28 method
: 'backup_clean'
31 getBackupConfig
: L
.rpc
.declare({
32 object
: 'luci2.system',
33 method
: 'backup_config_get',
34 expect
: { config
: '' }
37 setBackupConfig
: L
.rpc
.declare({
38 object
: 'luci2.system',
39 method
: 'backup_config_set',
43 listBackup
: L
.rpc
.declare({
44 object
: 'luci2.system',
45 method
: 'backup_list',
46 expect
: { files
: [ ] }
49 testReset
: L
.rpc
.declare({
50 object
: 'luci2.system',
52 expect
: { supported
: false }
55 startReset
: L
.rpc
.declare({
56 object
: 'luci2.system',
60 handleFlashUpload: function() {
63 L
.tr('Firmware upload'),
64 L
.tr('Select the sysupgrade image to flash and click "%s" to proceed.').format(L
.tr('Ok')), {
65 filename
: '/tmp/firmware.bin',
66 success: function(info
) {
67 self
.handleFlashVerify(info
);
73 handleFlashVerify: function(info
) {
75 self
.testUpgrade().then(function(res
) {
79 L
.tr('Verify firmware'), [
80 $('<p />').text(L
.tr('The firmware image was uploaded completely. Please verify the checksum and file size below, then click "%s" to start the flash procedure.').format(L
.tr('Ok'))),
83 .append($('<strong />').text(L
.tr('Checksum') + ': '))
84 .append(info
.checksum
))
86 .append($('<strong />').text(L
.tr('Size') + ': '))
87 .append('%1024mB'.format(info
.size
))),
89 .append($('<input />')
90 .attr('type', 'checkbox')
91 .prop('checked', true))
93 .append(L
.tr('Keep configuration when reflashing'))
97 //self.startUpgrade().then(function() {
109 L
.tr('Invalid image'), [
110 $('<p />').text(L
.tr('Firmware image verification failed, the "sysupgrade" command responded with the message below:')),
112 .addClass('alert-message')
113 .text(res
.stdout
|| res
.stderr
),
114 $('<p />').text(L
.tr('Image verification failed with code %d.').format(res
.code
))
118 self
.cleanUpgrade().then(function() {
128 handleBackupUpload: function() {
131 L
.tr('Backup restore'),
132 L
.tr('Select the backup archive to restore and click "%s" to proceed.').format(L
.tr('Ok')), {
133 filename
: '/tmp/backup.tar.gz',
134 success: function(info
) {
135 self
.handleBackupVerify(info
);
141 handleBackupVerify: function(info
) {
144 L
.tr('Backup restore'), [
145 $('<p />').text(L
.tr('The backup archive was uploaded completely. Please verify the checksum and file size below, then click "%s" to restore the archive.').format(L
.tr('Ok'))),
148 .append($('<strong />').text(L
.tr('Checksum') + ': '))
149 .append(info
.checksum
))
151 .append($('<strong />').text(L
.tr('Size') + ': '))
152 .append('%1024mB'.format(info
.size
)))
155 confirm: function() {
156 self
.handleBackupRestore();
162 handleBackupRestore: function() {
164 self
.restoreBackup().then(function(res
) {
168 L
.tr('Backup restore'), [
169 $('<p />').text(L
.tr('The backup was successfully restored, it is advised to reboot the system now in order to apply all configuration changes.')),
171 .addClass('cbi-button')
172 .attr('type', 'button')
173 .attr('value', L
.tr('Reboot system'))
174 .click(function() { alert('Reboot...'); })
178 self
.cleanBackup().then(function() {
188 L
.tr('Backup restore'), [
189 $('<p />').text(L
.tr('Backup restoration failed, the "sysupgrade" command responded with the message below:')),
191 .addClass('alert-message')
192 .text(res
.stdout
|| res
.stderr
),
193 $('<p />').text(L
.tr('Backup restoration failed with code %d.').format(res
.code
))
197 self
.cleanBackup().then(function() {
207 handleBackupDownload: function() {
208 var form
= $('#btn_backup').parent();
210 form
.find('[name=sessionid]').val(L
.globals
.sid
);
214 handleReset: function() {
216 L
.ui
.dialog(L
.tr('Really reset all changes?'), L
.tr('This will reset the system to its initial configuration, all changes made since the initial flash will be lost!'), {
218 confirm: function() {
219 //self.startReset().then(function() {
228 execute: function() {
231 self
.testReset().then(function(reset_avail
) {
233 $('#btn_reset').prop('disabled', true);
236 if (!self
.options
.acls
.backup
) {
237 $('#btn_restore, #btn_save, textarea').prop('disabled', true);
240 $('#btn_backup').click(function() { self
.handleBackupDownload(); });
241 $('#btn_restore').click(function() { self
.handleBackupUpload(); });
244 if (!self
.options
.acls
.upgrade
) {
245 $('#btn_flash, #btn_reset').prop('disabled', true);
248 $('#btn_flash').click(function() { self
.handleFlashUpload(); });
249 $('#btn_reset').click(function() { self
.handleReset(); });
252 return self
.getBackupConfig();
253 }).then(function(config
) {
255 .attr('rows', (config
.match(/\n/g) || [ ]).length
+ 1)
260 var data
= ($('textarea').val() || '').replace(/\r/g, '').replace(/\n?$/, '\n');
262 self
.setBackupConfig(data
).then(function() {
264 .attr('rows', (data
.match(/\n/g) || [ ]).length
+ 1)
274 self
.listBackup().then(function(list
) {
277 L
.tr('Backup file list'),
279 .css('width', '100%')
280 .attr('rows', list
.length
)
281 .prop('readonly', true)
282 .addClass('form-control')
283 .val(list
.join('\n')),