# # SysAdmin - A System Administration module for OzTivo image # proc action_sysadmin {chan path env} { global bin_dir global tivoswversion puts $chan [html_start ""] puts $chan [html_link "/sysadmin/remount" "Remount"] if {[file exists /etc/oztivo-version] || [file exists /etc/oztivo_version]} { puts $chan " | [html_link "/sysadmin/pal-ntsc" "PAL-NTSC"]" } if {[PrefixMatches "3.0" $tivoswversion] && [file exists ${bin_dir}/evtswitchfix]} { puts $chan " | [html_link "/sysadmin/evtfix" "EvtFix"]" } puts $chan " | [html_link "/script" "RunScript"]" puts $chan " | [html_link "/sysadmin/debug" "Debug"]" if {[PrefixMatches "6.3" $tivoswversion]} { puts $chan " | [html_link "/sysadmin/npk_dump" "NpkDump"]" } if {[string index $path 0] == "/"} { set path [string range $path 1 end] if {$path != ""} { puts $chan "
" if {[string range $path 0 6] == "remount"} { sysadmin_remount $chan $path } elseif {[string range $path 0 7] == "pal-ntsc"} { sysadmin_pal-ntsc $chan $path } elseif {[string range $path 0 5] == "evtfix"} { sysadmin_evtfix $chan $path } elseif {[string range $path 0 4] == "debug"} { sysadmin_debug $chan $path } elseif {[string range $path 0 8] == "npk_dump"} { sysadmin_npk_dump $chan $path } } } puts $chan [html_end] } proc sysadmin_remount {chan path} { if {$path == "remount-ro"} { exec mount -oremount,ro / } elseif {$path == "remount-rw"} { exec mount -oremount,rw / } puts $chan "Root Filesystem is currently " set status [exec mount | sed -n "s,.*on / .*(,(,p"] if {$status == "(ro)"} { puts $chan "READ ONLY
" } else { puts $chan "READ WRITE
" } puts $chan "
Remount:
" puts $chan "[html_link "remount-ro" "Read Only"]
" puts $chan "[html_link "remount-rw" "Read Write"]
" } # remember to "dbrm /State/GeneralConfig Complete" after setting PAL GS to make tivo come up in GS. proc sysadmin_pal-ntsc {chan path} { set bootargs "[exec bootpage -p /dev/hda]" set bootmsg "Current TiVo Boot Parameters:" puts $chan "ozTiVo Video Switching Utility

" puts $chan "Options:
" puts -nonewline $chan [html_link "pal-ntsc-PAL" "Set PAL"] puts $chan "
" puts -nonewline $chan [html_link "pal-ntsc-NTSC" "Set NTSC"] puts $chan "
" puts -nonewline $chan [html_link "pal-ntsc-GS" "Set PAL Guided Setup Mode"] puts $chan "
" if {$path == "pal-ntsc-PAL" } { if {! [regexp TV_STD $bootargs ] } { append bootargs " TV_STD=NTSC" } regsub -all TV_STD=NTSC $bootargs TV_STD=PAL newbootargs regsub -all " GS=\[01\]" $newbootargs "" newbootargs set bootmsg "TiVo set to PAL mode. Please reboot for change to take effect. Boot params are now:" set bootargs "$newbootargs" exec bootpage -P "$bootargs" /dev/hda } elseif {$path == "pal-ntsc-NTSC" } { regsub -all " TV_STD=PAL" $bootargs "" newbootargs regsub -all " GS=\[01\]" $newbootargs "" newbootargs set bootmsg "TiVo set to NTSC mode. Please reboot for change to take effect. Boot params are now:" set bootargs "$newbootargs" exec bootpage -P "$bootargs" /dev/hda } elseif {$path == "pal-ntsc-GS" } { if {! [regexp TV_STD $bootargs ] } { append bootargs " TV_STD=NTSC" } if {! [regexp GS=0 $bootargs ] } { append bootargs " GS=0" } regsub -all GS=0 $bootargs GS=1 newbootargs regsub -all TV_STD=NTSC $newbootargs TV_STD=PAL newbootargs set bootmsg "TiVo set for PAL Guided Setup. Please Reboot." set bootargs "$newbootargs" exec bootpage -P "$bootargs" /dev/hda } puts $chan "
$bootmsg

" puts $chan "$bootargs

" } proc sysadmin_evtfix {chan path} { global bin_dir if {$path == "evtfix-exec"} { catch {exec sh -c "${bin_dir}/evtswitchfix 2>&1"} output puts $chan "
$output
" } else { puts $chan "Eventswitcher Bug Fixer
" puts $chan "[html_link "http://minnie.tuhs.org/twiki/bin/view/Software/EvtSwitchFixer" "Beta version 2"]
" puts $chan "Copyright Martijn van Oosterhout

" puts $chan "!!!WARNING!!! This program messes with other programs while they are running.
" puts $chan "Absolutly no warranty, use at your own risk.
" puts $chan "
[html_link "evtfix-exec" "Run EventSwitchFix"]
" } } proc sysadmin_debug {chan path} { debug_pvars "#0" [info globals] $chan } proc sysadmin_npk_dump {chan path} { global db if [PrefixMatches "6.3" $::tivoswversion] { ForeachMfsFileTrans fsid name type "/SeasonPass/User" "" 20 { set sp [db $db openid $fsid] set npk "n/a" set callsign "n/a" set name "n/a" catch {set npk [dbobj $sp get NpkChannelDefinition]} if {[catch {set station [dbobj $sp get Station]}] == 0} { catch {set callsign [dbobj $station get CallSign]} catch {set name [dbobj $station get Name]} } puts $chan "$callsign, $name, $npk
" } } } register_module "sysadmin" "SysAdmin" "General System Administration tasks"