1
0
mirror of https://github.com/j-a-n/raspberrymatic-addon-rmupdate.git synced 2023-10-10 11:37:40 +00:00

Upload and install addon from file

This commit is contained in:
Jan Schneider
2018-01-29 00:04:12 +01:00
parent d3b87c5dfc
commit 6fa4ba262e
3 changed files with 119 additions and 44 deletions

View File

@@ -23,12 +23,26 @@ proc process {} {
global env
if { [info exists env(QUERY_STRING)] } {
set query $env(QUERY_STRING)
set path [split $query {/}]
set plen [expr [llength $path] - 1]
if {[lindex $path 1] == "install_addon_archive"} {
set archive_file "/tmp/uploaded_addon.tar.gz"
catch {fconfigure stdin -translation binary}
catch {fconfigure stdin -encoding binary}
set out [open $archive_file w]
catch {fconfigure $out -translation binary}
catch {fconfigure $out -encoding binary}
puts -nonewline $out [read stdin]
close $out
set res [rmupdate::install_addon "" "file://${archive_file}"]
return "\"${res}\""
}
set data ""
if { [info exists env(CONTENT_LENGTH)] } {
set data [read stdin $env(CONTENT_LENGTH)]
}
set path [split $query {/}]
set plen [expr [llength $path] - 1]
if {[lindex $path 1] == "version"} {
return "\"[rmupdate::version]\""