mirror of
https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git
synced 2023-10-10 13:37:40 +02:00
Install firmware from url
This commit is contained in:
parent
9a9457ee95
commit
98c23ccba0
@ -993,17 +993,22 @@ proc ::rmupdate::get_latest_firmware_version {} {
|
|||||||
return [lindex $versions 0]
|
return [lindex $versions 0]
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ::rmupdate::download_firmware {version} {
|
proc ::rmupdate::download_firmware {{download_url ""} {version ""}} {
|
||||||
variable img_dir
|
variable img_dir
|
||||||
variable install_log
|
variable install_log
|
||||||
|
|
||||||
set image_file "${img_dir}/RaspberryMatic-${version}.img"
|
if {$version == ""} {
|
||||||
set download_url ""
|
set image_file "${img_dir}/RaspberryMatic-${version}.img"
|
||||||
foreach e [get_available_firmware_downloads] {
|
} else {
|
||||||
set v [get_version_from_filename $e]
|
set image_file "${img_dir}/RaspberryMatic-unknown.img"
|
||||||
if {$v == $version} {
|
}
|
||||||
set download_url $e
|
if {$download_url == ""} {
|
||||||
break
|
foreach e [get_available_firmware_downloads] {
|
||||||
|
set v [get_version_from_filename $e]
|
||||||
|
if {$v == $version} {
|
||||||
|
set download_url $e
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {$download_url == ""} {
|
if {$download_url == ""} {
|
||||||
@ -1038,6 +1043,9 @@ proc ::rmupdate::download_firmware {version} {
|
|||||||
exec /usr/bin/unzip "${archive_file}" "${img_file}" -o -d "${img_dir}" 2>/dev/null
|
exec /usr/bin/unzip "${archive_file}" "${img_file}" -o -d "${img_dir}" 2>/dev/null
|
||||||
set img_file "${img_dir}/${img_file}"
|
set img_file "${img_dir}/${img_file}"
|
||||||
#puts "${img_file} ${image_file}"
|
#puts "${img_file} ${image_file}"
|
||||||
|
if {$version == ""} {
|
||||||
|
set image_file $img_file
|
||||||
|
}
|
||||||
if {$img_file != $image_file} {
|
if {$img_file != $image_file} {
|
||||||
file rename $img_file $image_file
|
file rename $img_file $image_file
|
||||||
}
|
}
|
||||||
@ -1174,9 +1182,11 @@ proc ::rmupdate::delete_firmware_image {version} {
|
|||||||
catch { eval {file delete [glob "${img_dir}/*${version}*.zip"]} }
|
catch { eval {file delete [glob "${img_dir}/*${version}*.zip"]} }
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ::rmupdate::install_firmware_version {version lang {reboot 1} {keep_download 0} {dryrun 0}} {
|
proc ::rmupdate::install_firmware {{download_url ""} {version ""} {lang ""} {reboot 1} {keep_download 0} {dryrun 0}} {
|
||||||
variable language
|
variable language
|
||||||
set language $lang
|
if {$lang != ""} {
|
||||||
|
set language $lang
|
||||||
|
}
|
||||||
if {[get_running_installation] != ""} {
|
if {[get_running_installation] != ""} {
|
||||||
error [i18n "Another install process is running."]
|
error [i18n "Another install process is running."]
|
||||||
}
|
}
|
||||||
@ -1184,19 +1194,23 @@ proc ::rmupdate::install_firmware_version {version lang {reboot 1} {keep_downloa
|
|||||||
error [i18n "System not upgradeable."]
|
error [i18n "System not upgradeable."]
|
||||||
}
|
}
|
||||||
|
|
||||||
set_running_installation "Firmware ${version}"
|
|
||||||
|
|
||||||
set firmware_image ""
|
set firmware_image ""
|
||||||
|
if {$version == ""} {
|
||||||
foreach e [get_available_firmware_images] {
|
set_running_installation "Firmware unknown"
|
||||||
set v [get_version_from_filename $e]
|
set keep_download 0
|
||||||
if {$v == $version} {
|
} else {
|
||||||
set firmware_image $e
|
set_running_installation "Firmware ${version}"
|
||||||
break
|
foreach e [get_available_firmware_images] {
|
||||||
|
set v [get_version_from_filename $e]
|
||||||
|
if {$v == $version} {
|
||||||
|
set firmware_image $e
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if {$firmware_image == ""} {
|
if {$firmware_image == ""} {
|
||||||
set firmware_image [download_firmware $version]
|
set firmware_image [download_firmware $download_url $version]
|
||||||
}
|
}
|
||||||
|
|
||||||
get_system_device
|
get_system_device
|
||||||
@ -1221,8 +1235,9 @@ proc ::rmupdate::install_firmware_version {version lang {reboot 1} {keep_downloa
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc ::rmupdate::install_latest_version {{reboot 1} {dryrun 0}} {
|
proc ::rmupdate::install_latest_version {{reboot 1} {dryrun 0}} {
|
||||||
|
variable language
|
||||||
set latest_version [get_latest_firmware_version]
|
set latest_version [get_latest_firmware_version]
|
||||||
return install_firmware_version $latest_version $reboot $dryrun
|
return install_firmware "" $latest_version $language $reboot $dryrun
|
||||||
}
|
}
|
||||||
|
|
||||||
proc ::rmupdate::is_firmware_up_to_date {} {
|
proc ::rmupdate::is_firmware_up_to_date {} {
|
||||||
|
@ -116,6 +116,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
function disable_buttons() {
|
function disable_buttons() {
|
||||||
$('#install-latest-firmware-button').addClass('disabled');
|
$('#install-latest-firmware-button').addClass('disabled');
|
||||||
|
$('#install-firmware-url-button').addClass('disabled');
|
||||||
$('[data-install-firmware-version]').addClass('disabled');
|
$('[data-install-firmware-version]').addClass('disabled');
|
||||||
$('[data-delete-firmware-version]').addClass('disabled');
|
$('[data-delete-firmware-version]').addClass('disabled');
|
||||||
$('[data-update-addon-id]').addClass('disabled');
|
$('[data-update-addon-id]').addClass('disabled');
|
||||||
@ -127,6 +128,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
function reset_buttons() {
|
function reset_buttons() {
|
||||||
$('#install-latest-firmware-button').removeClass('loading');
|
$('#install-latest-firmware-button').removeClass('loading');
|
||||||
$('#install-latest-firmware-button').removeClass('disabled');
|
$('#install-latest-firmware-button').removeClass('disabled');
|
||||||
|
$('#install-firmware-url-button').removeClass('loading');
|
||||||
|
$('#install-firmware-url-button').removeClass('disabled');
|
||||||
$('[data-install-firmware-version]').removeClass('loading');
|
$('[data-install-firmware-version]').removeClass('loading');
|
||||||
$('[data-install-firmware-version]').removeClass('disabled');
|
$('[data-install-firmware-version]').removeClass('disabled');
|
||||||
$('[data-delete-firmware-version]').removeClass('disabled');
|
$('[data-delete-firmware-version]').removeClass('disabled');
|
||||||
@ -212,7 +215,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_firmware(version) {
|
function install_firmware(download_url, version) {
|
||||||
$('#log-content').html('');
|
$('#log-content').html('');
|
||||||
$('#install-progress').progress("reset");
|
$('#install-progress').progress("reset");
|
||||||
$('#modal-log').modal('show');
|
$('#modal-log').modal('show');
|
||||||
@ -220,8 +223,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
var reboot = $('#reboot-after-install').is(':checked');
|
var reboot = $('#reboot-after-install').is(':checked');
|
||||||
var keep_download = ! $('#delete-download-after-install').is(':checked');
|
var keep_download = ! $('#delete-download-after-install').is(':checked');
|
||||||
var dryrun = $('#dryrun').is(':checked');
|
var dryrun = $('#dryrun').is(':checked');
|
||||||
set_running_installation("Firmware " + version);
|
if (version) {
|
||||||
rest("POST", "/start_install_firmware", JSON.stringify({"language": language, "version":version, "reboot":reboot, "dryrun":dryrun, "keep_download": keep_download}),
|
set_running_installation("Firmware " + version);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
set_running_installation("Firmware unknown");
|
||||||
|
}
|
||||||
|
if (!download_url) download_url = "";
|
||||||
|
if (!version) version = "";
|
||||||
|
rest("POST", "/start_install_firmware", JSON.stringify({"download_url": download_url, "version":version, "language": language, "reboot":reboot, "dryrun":dryrun, "keep_download": keep_download}),
|
||||||
function(data) {
|
function(data) {
|
||||||
// We are not expecting a response
|
// We are not expecting a response
|
||||||
},
|
},
|
||||||
@ -237,7 +247,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
|
|
||||||
function install_latest_firmware() {
|
function install_latest_firmware() {
|
||||||
if (latest_firmware && latest_firmware != '?') {
|
if (latest_firmware && latest_firmware != '?') {
|
||||||
install_firmware(latest_firmware);
|
install_firmware(null, latest_firmware);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -258,7 +268,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
var disabled = ((fw.image || fw.url) && fw.supported ? '' : 'disabled');
|
var disabled = ((fw.image || fw.url) && fw.supported ? '' : 'disabled');
|
||||||
var binstall = $('<div class="ui '+ color +' basic '+ disabled +' button">').attr('data-install-firmware-version', fw.version).append($('<i class="sign in icon">'), i18next.t('install'));
|
var binstall = $('<div class="ui '+ color +' basic '+ disabled +' button">').attr('data-install-firmware-version', fw.version).append($('<i class="sign in icon">'), i18next.t('install'));
|
||||||
binstall.click(function() {
|
binstall.click(function() {
|
||||||
install_firmware(this.getAttribute('data-install-firmware-version'));
|
install_firmware(null, this.getAttribute('data-install-firmware-version'));
|
||||||
});
|
});
|
||||||
var bcls = '';
|
var bcls = '';
|
||||||
if (!fw.image) bcls = 'disabled';
|
if (!fw.image) bcls = 'disabled';
|
||||||
@ -808,6 +818,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
$('th').localize();
|
$('th').localize();
|
||||||
$('label').localize();
|
$('label').localize();
|
||||||
$('#install-addon-url-button').contents().last()[0].textContent = i18next.t('install');
|
$('#install-addon-url-button').contents().last()[0].textContent = i18next.t('install');
|
||||||
|
$('#install-firmware-url-button').contents().last()[0].textContent = i18next.t('install');
|
||||||
$('#install-addon-file-button').contents().last()[0].textContent = i18next.t('choose_addon_file');
|
$('#install-addon-file-button').contents().last()[0].textContent = i18next.t('choose_addon_file');
|
||||||
});
|
});
|
||||||
var form_config = {
|
var form_config = {
|
||||||
@ -914,6 +925,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
<div id="dimmer-firmware-info" class="ui active inverted dimmer">
|
<div id="dimmer-firmware-info" class="ui active inverted dimmer">
|
||||||
<div class="ui loader" data-i18n="loading"></div>
|
<div class="ui loader" data-i18n="loading"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div style="width: 100%" class="ui action input">
|
||||||
|
<input id="install-firmware-url-input" type="text" placeholder="http://.../RaspberryMatic.zip"/>
|
||||||
|
<button id="install-firmware-url-button" class="ui green right labeled icon button" onclick="install_firmware($('#install-firmware-url-input').val());">
|
||||||
|
<i class="sign in icon"></i>
|
||||||
|
install
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
<table id="firmware-info" class="ui celled stackable table">
|
<table id="firmware-info" class="ui celled stackable table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -70,40 +70,37 @@ proc process {} {
|
|||||||
} elseif {[lindex $path 1] == "get_addon_info"} {
|
} elseif {[lindex $path 1] == "get_addon_info"} {
|
||||||
return [rmupdate::get_addon_info 1 1 1]
|
return [rmupdate::get_addon_info 1 1 1]
|
||||||
} elseif {[lindex $path 1] == "start_install_firmware"} {
|
} elseif {[lindex $path 1] == "start_install_firmware"} {
|
||||||
regexp {\"version\"\s*:\s*\"([\d\.]+)\"} $data match version
|
regexp {\"download_url\"\s*:\s*\"([^\"]*)\"} $data match download_url
|
||||||
|
regexp {\"version\"\s*:\s*\"([\d\.]*)\"} $data match version
|
||||||
regexp {\"language\"\s*:\s*\"([^\"]+)\"} $data match lang
|
regexp {\"language\"\s*:\s*\"([^\"]+)\"} $data match lang
|
||||||
regexp {\"reboot\"\s*:\s*(true|false)} $data match reboot
|
regexp {\"reboot\"\s*:\s*(true|false)} $data match reboot
|
||||||
regexp {\"dryrun\"\s*:\s*(true|false)} $data match dryrun
|
regexp {\"dryrun\"\s*:\s*(true|false)} $data match dryrun
|
||||||
regexp {\"keep_download\"\s*:\s*(true|false)} $data match keep_download
|
regexp {\"keep_download\"\s*:\s*(true|false)} $data match keep_download
|
||||||
if { [info exists version] && $version != "" } {
|
if { ![info exists reboot] } {
|
||||||
if { ![info exists reboot] } {
|
set reboot "true"
|
||||||
set reboot "true"
|
|
||||||
}
|
|
||||||
if {$reboot == "true"} {
|
|
||||||
set reboot 1
|
|
||||||
} else {
|
|
||||||
set reboot 0
|
|
||||||
}
|
|
||||||
if { ![info exists dryrun] } {
|
|
||||||
set dryrun "false"
|
|
||||||
}
|
|
||||||
if {$dryrun == "true"} {
|
|
||||||
set dryrun 1
|
|
||||||
} else {
|
|
||||||
set dryrun 0
|
|
||||||
}
|
|
||||||
if { ![info exists keep_download] } {
|
|
||||||
set keep_download "false"
|
|
||||||
}
|
|
||||||
if {$keep_download == "true"} {
|
|
||||||
set keep_download 1
|
|
||||||
} else {
|
|
||||||
set keep_download 0
|
|
||||||
}
|
|
||||||
return "\"[rmupdate::install_firmware_version $version $lang $reboot $keep_download $dryrun]\""
|
|
||||||
} else {
|
|
||||||
error "Invalid version: ${data}"
|
|
||||||
}
|
}
|
||||||
|
if {$reboot == "true"} {
|
||||||
|
set reboot 1
|
||||||
|
} else {
|
||||||
|
set reboot 0
|
||||||
|
}
|
||||||
|
if { ![info exists dryrun] } {
|
||||||
|
set dryrun "false"
|
||||||
|
}
|
||||||
|
if {$dryrun == "true"} {
|
||||||
|
set dryrun 1
|
||||||
|
} else {
|
||||||
|
set dryrun 0
|
||||||
|
}
|
||||||
|
if { ![info exists keep_download] } {
|
||||||
|
set keep_download "false"
|
||||||
|
}
|
||||||
|
if {$keep_download == "true"} {
|
||||||
|
set keep_download 1
|
||||||
|
} else {
|
||||||
|
set keep_download 0
|
||||||
|
}
|
||||||
|
return "\"[rmupdate::install_firmware $download_url $version $lang $reboot $keep_download $dryrun]\""
|
||||||
} elseif {[lindex $path 1] == "install_addon"} {
|
} elseif {[lindex $path 1] == "install_addon"} {
|
||||||
regexp {\"addon_id\"\s*:\s*\"([^\"]+)\"} $data match addon_id
|
regexp {\"addon_id\"\s*:\s*\"([^\"]+)\"} $data match addon_id
|
||||||
if { ![info exists addon_id] } {
|
if { ![info exists addon_id] } {
|
||||||
|
Loading…
Reference in New Issue
Block a user