2011-06-28 00:20:31 +00:00
|
|
|
#!/mod/bin/jimsh
|
|
|
|
|
|
|
|
package require cgi
|
2011-07-11 23:29:21 +00:00
|
|
|
source /mod/var/mongoose/lib/setup
|
|
|
|
require pkg.class
|
2011-06-28 00:20:31 +00:00
|
|
|
|
|
|
|
puts "Content-Type: text/html"
|
2011-07-11 23:29:21 +00:00
|
|
|
puts "Transfer-Encoding: chunked"
|
2011-06-28 00:20:31 +00:00
|
|
|
puts ""
|
|
|
|
|
|
|
|
cgi_input
|
|
|
|
#cgi_dump
|
|
|
|
|
|
|
|
#set _cgi(cmd) {remove binutils}
|
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
if {![dict exists $_cgi cmd]} { set _cgi(cmd) update }
|
2011-06-28 00:20:31 +00:00
|
|
|
|
|
|
|
set cmd [dict get $_cgi cmd]
|
|
|
|
|
2011-07-11 23:29:21 +00:00
|
|
|
proc chunk {chk} {
|
|
|
|
puts -nonewline [format "%x\r\n" [string length $chk]]
|
|
|
|
puts -nonewline "$chk\r\n"
|
|
|
|
flush stdout
|
|
|
|
}
|
|
|
|
|
|
|
|
# Kick the browser into life...
|
|
|
|
chunk [string range [format "%301d" 0] 1 end-1]
|
|
|
|
|
|
|
|
#puts [exec /mod/var/mongoose/lib/opkg {*}$cmd]
|
|
|
|
set bcmd "|/mod/var/mongoose/lib/opkg $cmd"
|
|
|
|
set fd [open $bcmd r]
|
|
|
|
while {[gets $fd line] >= 0} {
|
|
|
|
chunk "$line\r\n"
|
|
|
|
}
|
|
|
|
close $fd
|
|
|
|
|
|
|
|
if {$cmd eq "update"} {
|
|
|
|
chunk "Updating package meta information\r\n"
|
|
|
|
pkg fetchmeta
|
|
|
|
chunk "Done.\r\n"
|
|
|
|
}
|
|
|
|
|
|
|
|
chunk ""
|
|
|
|
puts "\r\n"
|
2011-06-28 00:20:31 +00:00
|
|
|
|