diff --git a/webif/include/diskcheck.jim b/webif/include/diskcheck.jim index 9299ecff..e79660af 100755 --- a/webif/include/diskcheck.jim +++ b/webif/include/diskcheck.jim @@ -2,77 +2,119 @@ source /mod/webif/lib/setup require system.class - -if {[system model] eq "HDR"} { - require settings.class -set smartattrs {realloc pending offline spinretry} - -set smartattribs(SMART_status) "Unknown" -foreach sa $smartattrs { - set smartattribs(SMART_$sa) 0 - set smartattribs(SMART_ack_$sa) 0 -} - -foreach line [[settings] smartdata] { - lassign $line x name x n x t - if {$name eq "SMART_status"} { - set smartattribs($name) $t - } else { - set smartattribs($name) $n +proc {system disksmart} {} { + set smartmsg "" + + set smartattrs {realloc pending offline spinretry} + + set smartattribs(SMART_status) "Unknown" + foreach sa $smartattrs { + set smartattribs(SMART_$sa) 0 + set smartattribs(SMART_ack_$sa) 0 } -} - -# (SMART_ack_status 0 SMART_ack_pending 0 SMART_status PASSED SMART_pending 7 SMART_ack_realloc 0 SMART_ack_offline 0 SMART_realloc 0 SMART_offline 7) - -set smartmsg "" -if {$smartattribs(SMART_status) ne "PASSED"} { - append smartmsg \ - "Disk overall health assessment is: $smartattribs(SMART_status)\n" -} - -foreach sa $smartattrs { - if {$smartattribs(SMART_$sa) != $smartattribs(SMART_ack_$sa)} { - append smartmsg \ - "Disk $sa sector count is: $smartattribs(SMART_$sa)" - if {$smartattribs(SMART_ack_$sa) > 0} { - append smartmsg " (was $smartattribs(SMART_ack_$sa))" + + foreach line [[settings] smartdata] { + lassign $line x name x n x t + if {$name eq "SMART_status"} { + set smartattribs($name) $t + } else { + set smartattribs($name) $n } - append smartmsg "\n" } + + # (SMART_ack_status 0 SMART_ack_pending 0 SMART_status PASSED SMART_pending 7 SMART_ack_realloc 0 SMART_ack_offline 0 SMART_realloc 0 SMART_offline 7) + + if {$smartattribs(SMART_status) ne "PASSED"} { + append smartmsg \ + "Disk overall health assessment is: $smartattribs(SMART_status)\n" + } + + foreach sa $smartattrs { + if {$smartattribs(SMART_$sa) != $smartattribs(SMART_ack_$sa)} { + append smartmsg \ + "Disk $sa sector count is: $smartattribs(SMART_$sa)" + if {$smartattribs(SMART_ack_$sa) > 0} { + append smartmsg " (was $smartattribs(SMART_ack_$sa))" + } + append smartmsg "\n" + } + } + return $smartmsg } -if {$smartmsg ne ""} { +proc {system diskro} {} { + if {[system model] eq "HDR"} { + set dev {/mnt/hd[1-3]} + } else { + set dev [system diskpart] + } + + # Python re: no POSIX character classes + # Jim TCL regex: no \x character classes + # Why not have both ... + set s {[[:blank:]]} + set a {[[:alnum:]]} + set nc {[^,]} + set roparts [lsearch -all -inline -regexp \ + [split [file read /proc/mounts] "\n\r"] \ + "${s}${dev}${s}+${a}+${s}*(${s}|${nc}+,)ro(,|$|${s})"] + return [join [lmap line $roparts \ + {format "Filesystem %s on %s is read-only" [lindex $line 1] [lindex $line 0]}] "\n"] +} + +set smartmsg [system disksmart] +set romsg [system diskro] + +if {$smartmsg ne "" || $romsg ne ""} { if {![dict exists $env SCRIPT_NAME]} { set env(SCRIPT_NAME) "" } - puts " -
+ puts { +
!! WARNING !! -

-There are potential hardware problems with the internal hard disk on -this device. -

+

} + set problems " " + if {$smartmsg ne ""} { + append problems "potential hardware" + } + if {$romsg ne ""} { + if {[string index $problems end] ne " "} { + append problems " and/or " + } + append problems "filesystem" + } + if {[string index $problems end] ne " "} { + append problems " " + } + puts [format " +There are %sproblems with the hard disk on +this system. +

" $problems] + if {$smartmsg ne ""} { + puts " [string map {"\n" "
"} $smartmsg] - " +
+" + } + if {$romsg ne ""} { + puts " +[string map {"\n" "
"} $romsg] +

+" + } if {$env(SCRIPT_NAME) ne "/diag/disk.jim"} { puts " -
- Go to disk diagnostics - " +Go to Disk Diagnostics +" } else { puts " -
- Don't panic; for help, visit - - wiki.hummy.tv - - " +
+Don't panic; for help, visit +wiki.hummy.tv +" } puts "
- " -} - +" } diff --git a/webif/include/notify.jim b/webif/include/notify.jim index 300f7c17..137ce36c 100755 --- a/webif/include/notify.jim +++ b/webif/include/notify.jim @@ -5,7 +5,7 @@ if {[file exists /mod/tmp/notify.log]} { source /mod/webif/lib/setup puts { -
+
!! WARNING !!

You have pending system notifications: