tazpanel diff index.cgi @ rev 304
Added tag 1.5.5 for changeset fdfc6b494539
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri May 04 13:16:25 2012 +0300 (2012-05-04) |
parents | 72e9955ebdff |
children | 3e9acc16f728 |
line diff
1.1 --- a/index.cgi Wed Apr 11 20:12:41 2012 +0300 1.2 +++ b/index.cgi Fri May 04 13:16:25 2012 +0300 1.3 @@ -35,12 +35,18 @@ 1.4 button) 1.5 cat <<EOT 1.6 <a class="button" href='$SCRIPT_NAME?file=$1&action=diff'> 1.7 - <img src="$IMAGES/help.png" />`gettext "Differences"`</a> 1.8 + <img src="$IMAGES/help.png" />$(gettext 'Differences')</a> 1.9 EOT 1.10 esac 1.11 break 1.12 done 1.13 } 1.14 +# OK status in table 1.15 +ok_status_t() { 1.16 + echo " <td>[<span class='diff-add'> OK </span>]</td></tr>" 1.17 +} 1.18 + 1.19 + 1.20 1.21 # 1.22 # Things to do before displaying the page 1.23 @@ -67,16 +73,17 @@ 1.24 xhtml_header 1.25 echo "<h2>$file</h2>" ;; 1.26 esac 1.27 + 1.28 if [ "$(GET action)" == "edit" ]; then 1.29 cat <<EOT 1.30 <form method="post" action="$SCRIPT_NAME?file=$file"> 1.31 -<img src="$IMAGES/edit.png" /> 1.32 -<input type="submit" value="`gettext "Save"`"> 1.33 -<a class="button" href='$SCRIPT_NAME?file=$file&action=diff'> 1.34 - <img src="$IMAGES/help.png" />`gettext "Differences"`</a> 1.35 -<textarea name="content" rows="30" style="width: 100%;"> 1.36 -$(cat $file) 1.37 - </textarea> 1.38 + <img src="$IMAGES/edit.png" /> 1.39 + <input type="submit" value="$(gettext 'Save')"> 1.40 + <a class="button" href='$SCRIPT_NAME?file=$file&action=diff'> 1.41 + <img src="$IMAGES/help.png" />$(gettext 'Differences')</a> 1.42 + <textarea name="content" rows="30" style="width: 100%;"> 1.43 +$(cat $file | htmlize) 1.44 +</textarea> 1.45 </form> 1.46 EOT 1.47 #The space before textarea gets muddled when the form is submitted. 1.48 @@ -93,10 +100,13 @@ 1.49 cat <<EOT 1.50 <div id="actions"> 1.51 <a class="button" href='$SCRIPT_NAME?file=$file&action=edit'> 1.52 - <img src="$IMAGES/edit.png" />`gettext "Edit"`</a> 1.53 + <img src="$IMAGES/edit.png" />$(gettext 'Edit')</a> 1.54 EOT 1.55 file_is_modified $file button 1.56 - echo -e "</div>\n<pre>" 1.57 + cat << EOT 1.58 +</div> 1.59 +<pre> 1.60 +EOT 1.61 # Handle file type by extension as a Web Server does it. 1.62 case "$file" in 1.63 *.conf|*.lst) 1.64 @@ -104,10 +114,11 @@ 1.65 *.sh|*.cgi) 1.66 syntax_highlighter sh ;; 1.67 *) 1.68 - cat ;; 1.69 + cat | htmlize ;; 1.70 esac < $file 1.71 echo '</pre>' 1.72 fi ;; 1.73 + 1.74 *\ terminal\ *|*\ cmd\ *) 1.75 # Cmdline terminal. 1.76 commands='cat du help ls ping pwd who wget' 1.77 @@ -117,7 +128,7 @@ 1.78 cat << EOT 1.79 <form method="get" action="$SCRIPT_NAME"> 1.80 <div class="box"> 1.81 - root@$(hostname):~# <input type="text" name="cmd" style="width: 80%;" /> 1.82 + root@$(hostname):~# <input autofocus type="text" name="cmd" style="width: 80%;" /> 1.83 </div> 1.84 </form> 1.85 EOT 1.86 @@ -125,70 +136,84 @@ 1.87 # Allow only a few commands for the moment. 1.88 case "$cmd" in 1.89 usage|help) 1.90 - gettext "Small terminal emulator, commands options are supported." 1.91 + gettext 'Small terminal emulator, commands options are supported.' 1.92 echo "" 1.93 - gettext "Commands:"; echo " $commands" ;; 1.94 + eval_gettext 'Commands: $commands' 1.95 + echo ;; 1.96 wget*) 1.97 dl=/var/cache/downloads 1.98 [ ! -d "$dl" ] && mkdir -p $dl 1.99 - gettext "Downloading to:"; echo " $dl" 1.100 + eval_gettext 'Downloading to: $dl' && echo 1.101 cd $dl && $cmd ;; 1.102 du*|ls*|ping*|pwd|who) 1.103 $cmd ;; 1.104 cat*) 1.105 # Cmd must be used with an arg. 1.106 arg=$(echo $cmd | awk '{print $2}') 1.107 - [ "$arg" == "" ] && echo -n "$cmd " && \ 1.108 - gettext "needs an argument $arg" && exit 0 1.109 + [ "$arg" == "" ] && eval_gettext '$cmd needs an argument' && break 1.110 $cmd ;; 1.111 *) 1.112 [ "$cmd" == "" ] || \ 1.113 - gettext "Unknown command: $cmd" 1.114 - gettext "Commands:"; echo " $commands" ;; 1.115 + eval_gettext 'Unknown command: $cmd' && echo 1.116 + eval_gettext 'Commands: $commands' ;; 1.117 esac 1.118 echo '</pre>' ;; 1.119 *\ top\ *) 1.120 TITLE=$(gettext 'TazPanel - Process activity') 1.121 xhtml_header 1.122 - echo `gettext "Refresh: "` $(GET refresh) 1.123 - echo '<br/> 1.124 + echo $(gettext 'Refresh:') $(GET refresh) 1.125 + cat << EOT 1.126 +<br/> 1.127 <form method="get"> 1.128 <input type="hidden" name="top"/> 1.129 - <input type="submit" name="refresh" value="1s"/> 1.130 - <input type="submit" name="refresh" value="5s"/> 1.131 - <input type="submit" name="refresh" value="10s"/> 1.132 - <input type="submit" value="none"/> 1.133 -</form> ' 1.134 - [ -n $(GET refresh) ] && 1.135 - echo '<meta http-equiv="refresh" content="' $(GET refresh) '">' | sed "s/s //" 1.136 + <input type="submit" name="refresh" value="$(gettext '1s')"/> 1.137 + <input type="submit" name="refresh" value="$(gettext '5s')"/> 1.138 + <input type="submit" name="refresh" value="$(gettext '10s')"/> 1.139 + <input type="submit" value="$(gettext 'none')"/> 1.140 +</form> 1.141 +EOT 1.142 + if [ -n "$(GET refresh)" ]; then 1.143 + echo -n '<meta http-equiv="refresh" content="' 1.144 + echo -n "$(GET refresh)" | sed 's|\([^0-9]*\)\([0-9]\+\).*|\2|' 1.145 + echo '">' 1.146 + fi 1.147 1.148 echo '<pre>' 1.149 - top -n1 -b | sed \ 1.150 + top -n1 -b | htmlize | sed \ 1.151 -e s"#^[A-Z].*:\([^']\)#<span class='sh-comment'>\0</span>#"g \ 1.152 -e s"#PID.*\([^']\)#<span class='top'>\0</span>#"g 1.153 echo '</pre>' ;; 1.154 + 1.155 *\ debug\ *) 1.156 TITLE=$(gettext 'TazPanel - Debug') 1.157 xhtml_header 1.158 - echo '<h2>HTTP Environment</h2>' 1.159 - echo '<pre>' 1.160 - httpinfo 1.161 - echo '</pre>' ;; 1.162 + cat << EOT 1.163 +<h2>$(gettext 'HTTP Environment')</h2> 1.164 + 1.165 +<pre>$(httpinfo)</pre> 1.166 +EOT 1.167 + ;; 1.168 + 1.169 *\ report\ *) 1.170 TITLE=$(gettext 'TazPanel - System report') 1.171 [ -d /var/cache/slitaz ] || mkdir -p /var/cache/slitaz 1.172 output=/var/cache/slitaz/sys-report.html 1.173 xhtml_header 1.174 - echo "<h2>$(gettext "Reporting to:") $output</h2>" 1.175 - echo '<pre>' 1.176 - gettext "Creating report header... " 1.177 + cat << EOT 1.178 +<h2>$(eval_gettext 'Reporting to: $output')</h2> 1.179 +<table class="zebra"> 1.180 +<tbody> 1.181 + <tr><td>$(gettext 'Creating report header...')</td> 1.182 +EOT 1.183 cat > $output << EOT 1.184 <!DOCTYPE html> 1.185 <html xmlns="http://www.w3.org/1999/xhtml"> 1.186 <head> 1.187 - <title>SliTaz system report</title> 1.188 + <meta charset="utf-8" /> 1.189 + <title>$(gettext 'SliTaz system report')</title> 1.190 <style type="text/css"> 1.191 - body { padding: 20px 60px; font-size: 13px; } h1, h2 { color: #444; } 1.192 + body { padding: 20px 60px; font-size: 13px; } 1.193 + h1, h2 { color: #444; } 1.194 pre { background: #f1f1f1; border: 1px solid #ddd; 1.195 padding: 10px; border-radius: 4px; } 1.196 span.diff-rm { color: red; } 1.197 @@ -197,11 +222,13 @@ 1.198 </head> 1.199 <body> 1.200 EOT 1.201 - ok_status 1.202 - gettext "Creating system summary... " 1.203 + cat << EOT 1.204 + $(ok_status_t) 1.205 + <tr><td>$(gettext 'Creating system summary...')</td> 1.206 +EOT 1.207 cat >> $output << EOT 1.208 -<h1>SliTaz system report</h1> 1.209 -Date: $(date) 1.210 +<h1>$(gettext 'SliTaz system report')</h1> 1.211 +$(gettext 'Date:') $(date) 1.212 <pre> 1.213 uptime : $(uptime) 1.214 cmdline : $(cat /proc/cmdline) 1.215 @@ -210,94 +237,88 @@ 1.216 kernel : $(uname -r) 1.217 </pre> 1.218 EOT 1.219 - ok_status 1.220 - gettext "Getting hardware info... " 1.221 + cat << EOT 1.222 + $(ok_status_t) 1.223 + <tr><td>$(gettext 'Getting hardware info...')</td> 1.224 +EOT 1.225 cat >> $output << EOT 1.226 <h2>free</h2> 1.227 -<pre> 1.228 -$(free) 1.229 -</pre> 1.230 +<pre>$(free)</pre> 1.231 1.232 <h2>lspci -k</h2> 1.233 -<pre> 1.234 -$(lspci -k) 1.235 -</pre> 1.236 +<pre>$(lspci -k)</pre> 1.237 1.238 <h2>lsusb</h2> 1.239 -<pre> 1.240 -$(lsusb) 1.241 -</pre> 1.242 +<pre>$(lsusb)</pre> 1.243 1.244 <h2>lsmod</h2> 1.245 -<pre> 1.246 -$(lsmod) 1.247 -</pre> 1.248 +<pre>$(lsmod)</pre> 1.249 1.250 EOT 1.251 - ok_status 1.252 - gettext "Getting networking info... " 1.253 + cat << EOT 1.254 + $(ok_status_t) 1.255 + <tr><td>$(gettext 'Getting networking info...')</td> 1.256 +EOT 1.257 cat >> $output << EOT 1.258 <h2>ifconfig -a</h2> 1.259 -<pre> 1.260 -$(ifconfig -a) 1.261 -</pre> 1.262 +<pre>$(ifconfig -a)</pre> 1.263 + 1.264 <h2>route -n</h2> 1.265 -<pre> 1.266 -$(route -n) 1.267 -</pre> 1.268 +<pre>$(route -n)</pre> 1.269 + 1.270 <h2>/etc/resolv.conf</h2> 1.271 -<pre> 1.272 -$(cat /etc/resolv.conf) 1.273 -</pre> 1.274 +<pre>$(cat /etc/resolv.conf)</pre> 1.275 EOT 1.276 - ok_status 1.277 - gettext "Getting filesystems info..." 1.278 + cat << EOT 1.279 + $(ok_status_t) 1.280 + <tr><td>$(gettext 'Getting filesystems info...')</td> 1.281 +EOT 1.282 cat >> $output << EOT 1.283 <h2>blkid</h2> 1.284 -<pre> 1.285 -$(blkid) 1.286 -</pre> 1.287 +<pre>$(blkid)</pre> 1.288 + 1.289 <h2>fdisk -l</h2> 1.290 -<pre> 1.291 -$(fdisk -l) 1.292 -</pre> 1.293 +<pre>$(fdisk -l)</pre> 1.294 + 1.295 <h2>mount</h2> 1.296 -<pre> 1.297 -$(mount) 1.298 -</pre> 1.299 +<pre>$(mount)</pre> 1.300 + 1.301 <h2>df -h</h2> 1.302 -<pre> 1.303 -$(df -h) 1.304 -</pre> 1.305 +<pre>$(df -h)</pre> 1.306 + 1.307 <h2>df -i</h2> 1.308 -<pre> 1.309 -$(df -i) 1.310 -</pre> 1.311 +<pre>$(df -i)</pre> 1.312 EOT 1.313 - ok_status 1.314 - gettext "Getting boot logs... " 1.315 + cat << EOT 1.316 + $(ok_status_t) 1.317 + <tr><td>$(gettext 'Getting boot logs...')</td> 1.318 +EOT 1.319 cat >> $output << EOT 1.320 -<h2>$(gettext "Kernel messages")</h2> 1.321 -<pre> 1.322 -$(cat /var/log/dmesg.log) 1.323 -</pre> 1.324 -<h2>$(gettext "Boot scripts")</h2> 1.325 -<pre> 1.326 -$(cat /var/log/boot.log | filter_taztools_msgs) 1.327 -</pre> 1.328 +<h2>$(gettext 'Kernel messages')</h2> 1.329 +<pre>$(cat /var/log/dmesg.log)</pre> 1.330 + 1.331 +<h2>$(gettext 'Boot scripts')</h2> 1.332 +<pre>$(cat /var/log/boot.log | filter_taztools_msgs)</pre> 1.333 EOT 1.334 - ok_status 1.335 - gettext "Creating report footer... " 1.336 + cat << EOT 1.337 + $(ok_status_t) 1.338 + <tr><td>$(gettext 'Creating report footer...')</td> 1.339 +EOT 1.340 cat cat >> $output << EOT 1.341 </body> 1.342 </html> 1.343 EOT 1.344 - ok_status 1.345 - echo '</pre>' 1.346 - echo "<p><a class='button' href='$SCRIPT_NAME?file=$output'> 1.347 - $(gettext "View report")</a>" 1.348 - gettext "This report can be attached with a bug report on: " 1.349 - echo '<a href="http://bugs.slitaz.org/">bugs.slitaz.org</a></p>' ;; 1.350 + cat << EOT 1.351 + $(ok_status_t) 1.352 +</tbody> 1.353 +</table> 1.354 +<p><a class="button" href="$SCRIPT_NAME?file=$output"> 1.355 + <img src="/styles/default/images/browser.png" /> 1.356 + $(gettext 'View report')</a> 1.357 + $(gettext 'This report can be attached with a bug report on:') 1.358 + <a href="http://bugs.slitaz.org/">bugs.slitaz.org</a></p> 1.359 +EOT 1.360 + ;; 1.361 *) 1.362 # 1.363 # Default xHTML content 1.364 @@ -305,56 +326,81 @@ 1.365 xhtml_header 1.366 [ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale) 1.367 [ -n "$(GET rdate)" ] && echo "" 1.368 + hostname=$(hostname) 1.369 cat << EOT 1.370 <div id="wrapper"> 1.371 - <h2>$(gettext "Host:") $(hostname)</h2> 1.372 - <p>$(gettext "SliTaz administration and configuration Panel")<p> 1.373 + <h2>$(eval_gettext 'Host: $hostname')</h2> 1.374 + <p>$(gettext 'SliTaz administration and configuration Panel')<p> 1.375 </div> 1.376 <div id="actions"> 1.377 <a class="button" href="$SCRIPT_NAME?terminal"> 1.378 - <img src="$IMAGES/terminal.png" />$(gettext "Terminal")</a> 1.379 + <img src="$IMAGES/terminal.png" />$(gettext 'Terminal')</a> 1.380 <a class="button" href="$SCRIPT_NAME?top"> 1.381 - <img src="$IMAGES/monitor.png" />$(gettext "Process activity")</a> 1.382 + <img src="$IMAGES/monitor.png" />$(gettext 'Process activity')</a> 1.383 <a class="button" href="$SCRIPT_NAME?report"> 1.384 - <img src="$IMAGES/text.png" />$(gettext "Create a report")</a> 1.385 + <img src="$IMAGES/text.png" />$(gettext 'Create a report')</a> 1.386 </div> 1.387 1.388 -<h3>$(gettext "Summary")</h3> 1.389 +<h3>$(gettext 'Summary')</h3> 1.390 <div id="summary"> 1.391 -<pre> 1.392 -$(gettext "Uptime :")$(uptime) 1.393 -$(gettext "Memory in Mb :") $(free -m | grep Mem: | awk \ 1.394 - '{print "Total:", $2, "Used:", $3, "Free:", $4}') 1.395 -$(gettext "Linux kernel :") $(uname -r) 1.396 -</pre> 1.397 +<table> 1.398 + <tr><td>$(gettext 'Uptime:')</td> 1.399 + <td>$(uptime)</td> 1.400 + </tr> 1.401 + <tr><td>$(gettext 'Memory in Mb:')</td> 1.402 +EOT 1.403 + free -m | grep Mem: | awk '{print $2, $3, $4}' | while read memtotal memused memfree 1.404 + do 1.405 + cat << EOT 1.406 + <td>$(eval_gettext 'Total: $memtotal, Used: $memused, Free: $memfree')</td> 1.407 +EOT 1.408 + done 1.409 + cat << EOT 1.410 + </tr> 1.411 + <tr><td>$(gettext 'Linux kernel:')</td> 1.412 + <td>$(uname -r)</td> 1.413 + </tr> 1.414 +</table> 1.415 <!-- Close summary --> 1.416 </div> 1.417 1.418 -<h4>$(gettext "Network status")</h4> 1.419 +<h4>$(gettext 'Network status')</h4> 1.420 $(list_network_interfaces) 1.421 1.422 -<h4>$(gettext "Filesystem usage statistics")</h4> 1.423 +<h4>$(gettext 'Filesystem usage statistics')</h4> 1.424 EOT 1.425 # Disk stats (management is done as hardware.cgi) 1.426 - table_start 1.427 + cat << EOT 1.428 +<table class="zebra"> 1.429 +EOT 1.430 df_thead 1.431 + echo '<tbody>' 1.432 df -h | grep ^/dev | while read fs size used av pct mp 1.433 do 1.434 cat << EOT 1.435 <tr> 1.436 <td><a href="hardware.cgi"> 1.437 <img src="$IMAGES/harddisk.png" />${fs#/dev/}</a></td> 1.438 + <td>$(blkid -o value $fs | head -n1)</td> 1.439 + <td>$(blkid -o value $fs | tail -n1)</td> 1.440 <td>$size</td> 1.441 <td>$av</td> 1.442 - <td class="pct"><div class="pct" 1.443 - style="width: $pct;">$used - $pct</div></td> 1.444 + <td class="meter"><meter min="0" max="100" value="$(echo $pct | cut -d% -f1)" 1.445 + low="$DU_WARN" high="$DU_CRIT" optimum="10"></meter> 1.446 + <span>$used - $pct</span> 1.447 + </td> 1.448 <td>$mp</td> 1.449 </tr> 1.450 EOT 1.451 done 1.452 - table_end 1.453 cat << EOT 1.454 -<h3>$(gettext "Panel Activity")</h3> 1.455 +</tbody> 1.456 +</table> 1.457 +EOT 1.458 + 1.459 + 1.460 + cat << EOT 1.461 +<h3>$(gettext 'Panel Activity')</h3> 1.462 <pre id="panel-activity"> 1.463 $(cat $LOG_FILE | tail -n 8 | sort -r | syntax_highlighter activity) 1.464 </pre>