proc action_update {chan path env} { global source_dir set submit "" eval $env puts $chan [html_start "Update distribution"] if {$submit == "Update"} { if {$file == ""} { puts $chan "Error: No File Specified

" } else { set filepath "$source_dir/uploads/$file" if { [catch { set fsize [file size $filepath] }] == 1} { puts $chan "Error Opening File" } elseif {$fsize == 0} { puts $chan "Error: File Empty

" file delete $filepath } elseif {[file extension $filepath] == ".tgz"} { if { [catch {exec sh -c "$source_dir/.dist/extract.sh $source_dir \"$filepath\""} output] == 1} { puts $chan "

$output

" puts $chan "Error Updating Package

" } else { puts $chan "

$output

" puts $chan "Successfully Updated Package

" catch {update_stats $chan} #set ::reload "quit" } catch {file delete $filepath} } elseif {[file extension $filepath] == ".itcl"} { catch {exec sh -c "dos2unix \"$filepath\""} set modpath "$source_dir/libs/$file" if {[file exists $modpath]} { puts $chan "Updated module: $file

" file delete $modpath file rename $filepath $modpath } else { set modpath "$source_dir/modules/$file" if {[file exists $modpath]} { puts $chan "Updated module: $file

" file delete $modpath } else { puts $chan "Installed module: $file

" } file rename $filepath $modpath } puts $chan "Changes will not take effect until a [html_link "/restart/1" "Quick Reload"] is performed.

" } else { puts $chan "Error: File must end in .tgz

" file delete $filepath } } } else { if {[info exists file]} { # If the attachment's Content-Type is not binary then # the submit=Update is not passed via the environment. # The file is still uploaded, so we could just ignore # the fact that the submit variable was not set and # process it... but as we don't currently need to # handle text files we will display an error and clean # up the file. puts $chan "Error loading file: the file may not have been binary

" set filepath "$source_dir/uploads/$file" if {[file exists $filepath] == 1} { catch {file delete $filepath} } } if {[file writable "$source_dir/uploads"]} { puts $chan "Experimental

" puts $chan "You are currently running v$TWP::DIST_VERSION

" puts $chan "This module allows you to update the software without losing" puts $chan "your custom configurations.
It's designed to work with" puts $chan "the bundles distributed at " puts $chan "[html_link "http://thomson.tivo.googlepages.com/TivoWebPlus" "thomson.tivo.googlepages.com"].

" puts $chan "Only distributions installed in a \"TivoWebPlus\" directory" puts $chan "can be updated via the bundles.

" puts $chan [html_form_start "POST" "/update" "enctype='multipart/form-data'"] puts $chan "File must be in bundle format with a .tgz extension.
" puts $chan [html_table_start "" "" ""] puts $chan [tr "" [td [html_link "http://thomson.tivo.googlepages.com/TivoWebPlus" "TWP Bundle"]] [td [html_form_input {file" accept="application/x-compressed" size="48} "file" ""]]] puts $chan [html_table_end] puts $chan [html_form_input "submit" "submit" "Update"] puts $chan "


NOTE: If the above links no longer work then you may wish to try [html_link "http://beam.to/twp" "http://beam.to/twp"] or [html_link "http://www.dealdatabase.com/forum/showthread.php?t=44756&page=10" "DealDatabase"]" puts $chan [html_form_end] } else { puts $chan "Error: the uploads directory does not look like it's writable

" } } puts $chan [html_end] } proc update_stats {chan} { if {$::sf_stats == 1} { if {[file exists $::source_dir/.dist/version]} { set fd [open $::source_dir/.dist/version "r"] gets $fd dist close $fd } else { set dist $TWP::DIST_VERSION } regsub -all { } "$dist&sw=$::tivoswversion&tv=$::tvStandard" {_} ver puts $chan "" } } register_module "update" "Update" "Update the TWP software"