httpd.tcl changes
John Schult
johndavid65 at h...
Sun, 10 Jun 2001 03:03:20 -0000
OK, I obviously had way too much time on my hands this weekend... I
hate pasting this code in this post (as I am sure the CRLFs are all
screwed up), but what the heck. If anyone actually cares enough to
use it, I am sure they will figure it out.
<snip>
proc page_header_start {title desc colspan} {
set ret [html_table_start "BGCOLOR=\"#F0F8FF\" BORDER=\"0\"
WIDTH=\"50\%\"" "" ""]
append ret "<TR BGCOLOR=\"#B0C4DE\"><TH ALIGN=\"CENTER\"
COLSPAN=\"$colspan\">$title</TH></TR>"
append ret "<TR BGCOLOR=\"#FFFFE0\"><TD ALIGN=\"CENTER\"
COLSPAN=\"$colspan\"><FONT SIZE=\"-2\">$desc</FONT></TD></TR>"
return $ret
}
proc page_header_end {} {
append ret [html_table_end]
return $ret
}
proc action_remount {chan path} {
if {[string index $path 0] == "/"} {
set path [string range $path 1 end]
}
puts $chan [html_start "TivoHack Web Remote"]
puts $chan [page_header_start "TiVoHack Web Root Remount" "This
widget is used to mount the root filesystem.  The table below
displays the current output of the mount command for the root
filesystem.  To change the mount option, click the button.
 Changes are reflected <B>immediately</B>." 4 ]
if {$path == "ro" } {
exec mount -oremount,ro /
} elseif {$path == "rw" } {
exec mount -oremount,rw /
}
puts $chan "<TR><TH>device</TH><TH>mount
point</TH><TH>type</TH><TH>options</TH></TR>"
# check to see how / is currently mounted
set output [exec mount]
set mount_out [ string range $output 0 [ string first ")"
$output ] ]
list $mount_out
set remount "ro"
set remount_txt "Read Only"
set option_color "green"
if { [regexp -nocase {\(ro\)} $mount_out] } {
set remount "rw"
set remount_txt "Read Write"
set option_color "red"
}
puts $chan "<TR ALIGN=\"CENTER\"><TD>[lindex $mount_out 0]
</TD><TD>[lindex $mount_out 2]</TD><TD>[lindex $mount_out 4]
</TD><TD><FONT COLOR=\"$option_color\">[lindex $mount_out 5]
</FONT></TD></TR>"
puts $chan "<TR><TD ALIGN=\"CENTER\" COLSPAN=\"4
\"><HR/></TD><TR>"
puts $chan "<TR><TD ALIGN=\"CENTER\" COLSPAN=\"4\">"
puts $chan "<FORM><INPUT TYPE=\"BUTTON\"
ONCLICK=\"location.href='$remount'\" VALUE=\"Remount As
$remount_txt\"/></FORM>"
puts $chan "</TD></TR>"
puts $chan [page_header_end]
puts $chan [html_end]
}
</snip>
Enjoy, I guess.
++john