tazpanel view index.cgi @ rev 520
PROVIDE support in package list report
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Aug 04 11:16:14 2015 +0200 (2015-08-04) |
parents | 06a4d2cde715 |
children | c0997cc494ed |
line source
1 #!/bin/sh
2 #
3 # Main CGI interface for TazPanel. In on word: KISS. Use the main CSS form
4 # command so we are faster and do not load unneeded functions. If necessary
5 # you can use the lib/ dir to handle external resources.
6 #
7 # Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License
8 #
11 # Common functions from libtazpanel
13 . lib/libtazpanel
14 get_config
16 TITLE='TazPanel'
20 # Check whether a configuration file has been modified after installation
22 file_is_modified() {
23 grep -l " $1$" $INSTALLED/*/md5sum | while read file; do
25 # Found, but can we do diff?
26 [ "$(grep -h " $1$" $file)" != "$(md5sum $1)" ] || break
27 orig=$(dirname $file)/volatile.cpio.gz
28 zcat $orig 2>/dev/null | cpio -t 2>/dev/null | grep -q "^${1#/}$" || break
30 case "$2" in
31 diff)
32 tmp=$(mktemp -d)
33 ( cd $tmp; zcat $orig | cpio -id ${1#/} )
34 diff -abu $tmp$1 $1 | sed "s|$tmp||"
35 rm -rf $tmp;;
36 button)
37 echo -n '<button name="action" value="diff" data-icon="diff">'$(_ 'Differences')'</button>';;
38 esac
39 break
40 done
41 }
44 # OK status in table
46 ok_status_t() {
47 echo '<td><span class="diff-add" data-img="ok"></span></td></tr>'
48 }
52 # Terminal prompt
54 term_prompt() {
55 if [ "$user" == 'root' ]; then
56 local color1='color31' sign='#'
57 else
58 local color1='color32' sign='$'
59 fi
60 echo -n "<span class='$color1'>$user@$(hostname)</span>:<span class='color33'>"
61 pwd | sed "s|^$HOME|~|" | tr -d '\n'; echo -n "</span>$sign "
62 }
66 #
67 # Commands
68 #
70 case " $(GET) " in
73 *\ exec\ *)
74 # Execute command and display its result in a terminal-like window
76 header; xhtml_header "$(_ 'exec')"
78 exec="$(GET exec)"
79 font="${TERM_FONT:-monospace}"
80 palette=$(echo $TERM_PALETTE | tr A-Z a-z)
82 cat <<EOT
83 <section>
84 <header>
85 $exec
86 $(back_button "$(GET back)" "$(GET back_caption)" "$(GET back_icon)")
87 </header>
88 <div class="term_">
89 <pre class="term $palette" style="font-family: '$font'">$($exec 2>&1 | htmlize | filter_taztools_msgs)</pre>
90 </div>
91 </section>
92 EOT
93 ;;
96 *\ file\ *)
97 #
98 # Handle files
99 #
100 header
101 file="$(GET file)"
102 action="$(POST action)"; [ -z "$action" ] && action="$(GET action)" # receive 'action' both on POST or GET
103 title="$(POST title)"; [ -z "$title" ] && title="$(GET title)" # (optional)
105 case $file in
106 *.html)
107 cat $file; exit 0 ;;
108 *)
109 xhtml_header "$(_ 'File')";;
110 esac
112 case "$action" in
113 edit)
114 cat <<EOT
115 <section>
116 <header>
117 <span data-icon="edit">${title:-$file}</span>
118 <form id="editform" method="post" action="?file=$file">
119 <button data-icon="save">$(_ 'Save')</button>
120 <button name="action" value="diff" data-icon="diff">$(_ 'Differences')</button>
121 </form>
122 </header>
123 <textarea form="editform" name="content" class="wide" rows="30" autofocus>$(htmlize < $file)</textarea>
124 </section>
125 EOT
126 #The space before textarea gets muddled when the form is submitted.
127 #It prevents anything else from getting messed up
128 ;;
130 setvar)
131 data="$(. $(GET file) ;eval echo \$$(GET var))"
132 cat <<EOT
133 <section>
134 <header>$(GET var)</header>
135 <form method="post" action="?file=$file" class="nogap">
136 <input type="hidden" name="var" value="$(GET var)">
137 <input type="text" name="content" value="${data:-$(GET default)}">
138 <button type="submit" data-icon="save">$(_ 'Save')</button>
139 </form>
140 </section>
141 EOT
142 ;;
144 diff)
145 cat <<EOT
146 <section>
147 <pre id="diff">$(file_is_modified $file diff | syntax_highlighter diff)</pre>
148 </section>
149 EOT
150 ;;
152 *)
153 R=$(echo -en '\r')
154 if [ -n "$(POST content)" ]; then
155 if [ -n "$(POST var)" ]; then
156 sed -i "s|^\\($(POST var)=\\).*|\1\"$(POST content)\"|" $file
157 else
158 sed "s/$R /\n/g;s/$R%0//g" > $file <<EOT
159 $(POST content)
160 EOT
161 fi
162 fi
164 cat <<EOT
165 <section class="bigNoScrollable">
166 <header>
167 <span data-icon="text">${title:-$file}</span>
168 EOT
169 if [ -w "$file" ]; then
170 cat <<EOT
171 <form>
172 <input type="hidden" name="file" value="$file"/>
173 <button onclick='editFile(); return false' id="edit_button"
174 data-icon="edit">$(_ 'Edit')</button><!--
175 --><button onclick='saveFile("$file", "$title"); return false' id="save_button"
176 data-icon="save" style="display:none">$(_ 'Save')</button><!--
177 -->$(file_is_modified $file button)
178 </form>
179 EOT
180 elif [ -r "$file" ]; then
181 cat <<EOT
182 <form>
183 <input type="hidden" name="file" value="$file"/>
184 $(file_is_modified $file button)
185 </form>
186 EOT
187 fi
188 cat <<EOT
189 </header>
191 <div>
192 <pre id="fileContent" class="bigScrollable">
193 EOT
194 end_code=''
195 # Handle file type by extension as a Web Server does it.
196 case "$file" in
197 *.sh|*.cgi|*/receipt|*.conf)
198 echo '<code class="language-bash">'; end_code='</code>'
199 htmlize ;;
200 *.ini)
201 echo '<code class="language-ini">'; end_code='</code>'
202 htmlize ;;
203 *.conf|*.lst)
204 syntax_highlighter conf ;;
205 *Xorg.0.log)
206 syntax_highlighter xlog ;;
207 *dmesg.log)
208 syntax_highlighter kernel ;;
209 *)
210 htmlize ;;
211 esac < $file
212 cat <<EOT
213 $end_code</pre>
214 </div>
215 </section>
216 EOT
217 esac
218 ;;
222 *\ terminal\ *|*\ cmd\ *)
223 # Cmdline terminal
225 header; xhtml_header "$(_ 'Terminal')"
227 user="$REMOTE_USER"
228 HOME="$(getdb passwd | awk -F: -vu=$user '$1==u{print $6}')"
229 historyfile="$HOME/.ash_history"
231 cmd=$(GET cmd)
232 path="$(GET path)"; path="${path:-/tmp}"; cd "$path"
234 font="${TERM_FONT:-monospace}"
235 palette=$(echo $TERM_PALETTE | tr A-Z a-z)
237 [ -n "$cmd" -a "$cmd" != "$(tail -n1 $historyfile)" ] && echo "$cmd" >> $historyfile
240 # Terminal history
242 if [ "$cmd" == 'history' ]; then
243 cat <<EOT
244 <section>
245 <header>
246 $(_ 'History')
247 <form><button name="terminal" data-icon="terminal">$(_ 'Back')</button></form>
248 </header>
249 <form>
250 <input type="hidden" name="path" value="$path"/>
251 <pre class="term $palette" style="font-family: '$font'">
252 EOT
254 htmlize < $historyfile | awk -vrun="$(_ 'run')" -vpath="$path" -vq="'" '
255 BEGIN { num = 1; }
256 {
257 printf("%3d ", num);
258 cmd = $0;
259 gsub("%", "%25", cmd); gsub("+", "%2B", cmd); gsub(" ", "+", cmd);
260 gsub("\"", "%22", cmd); gsub("!", "%21", cmd); gsub(q, "%27", cmd);
261 printf("<a data-icon=\"run\" href=\"?cmd=%s&path=%s\">%s</a> ", cmd, path, run);
262 printf("<input type=\"checkbox\" name=\"rm\" value=\"%d\" id=\"hist%d\">", num, num);
263 printf("<label for=\"hist%d\">%s</label>\n", num, $0);
264 num++;
265 }'
267 cat <<EOT
268 </pre>
269 <footer>
270 <button name="rmhistory" data-icon="remove">$(_ 'Clear')</button>
271 </footer>
272 </form>
273 </section>
274 EOT
275 xhtml_footer
276 exit 0
277 fi
280 # Terminal window
282 cat <<EOT
283 <span id="num_hist"></span>
284 <section>
285 <pre class="term $palette" style="font-family: '$font'" onclick="document.getElementById('typeField').focus()">
286 EOT
287 if [ -n "$cmd" ]; then
288 term_prompt
289 echo "$cmd" | htmlize
290 fi
292 case "$cmd" in
293 usage|help)
294 _ 'Small non-interactive terminal emulator.'; echo
295 _ 'Run any command at your own risk, avoid interactive commands (%s)' 'nano, mc, ...'; echo
296 ;;
297 wget*)
298 dl='/var/cache/downloads'
299 [ ! -d "$dl" ] && mkdir -p $dl
300 _ 'Downloading to: %s' $dl; echo
301 cd $dl; $cmd 2>&1 ;;
302 cd|cd\ *)
303 path="${cmd#cd}"; path="${path:-$HOME}";
304 path="$(realpath $path)"; cd "$path" ;;
305 ls|ls\ *)
306 $cmd -w80 --color=always 2>&1 | filter_taztools_msgs ;;
307 cat)
308 # Cmd must be used with an arg.
309 _ '%s needs an argument' "$cmd" ;;
310 mc|nano|su)
311 # List of restricted (interactive) commands
312 _ "Please, don't run interactive command \"%s\"" "$cmd"; echo; echo ;;
313 *)
314 unset HTTP_REFERER # for fooling /lib/libtaz.sh formatting utils (<hr> in the terminal is so-so)
315 export DISPLAY=:0.0 # for run X applications
316 /bin/sh -c "$cmd" 2>&1 | htmlize | filter_taztools_msgs
317 ;;
318 esac
320 cat <<EOT
321 <form id="term">
322 <div class="cmdline" id="cmdline"><span id="prompt">$(term_prompt)</span><span id="typeField"> </span></div>
323 <input type="hidden" name="path" value="$(pwd)"/>
324 <input type="hidden" name="cmd" id="cmd"/>
325 </form>
326 </pre>
327 </section>
329 <form>
330 <button name="termsettings" data-icon="settings">$(_ 'Settings')</button>
331 <button name="cmd" value="history" data-icon="history">$(_ 'History')</button>
332 </form>
334 <script type="text/javascript">
335 with (document.getElementById('typeField')) {
336 contentEditable=true;
337 focus();
338 }
339 document.onkeydown=keydownHandler;
340 EOT
342 # Export history as array.
343 # Escape "all \"quotes\" in quotes", and all '\'
344 # (because \u, \x, \c has special meaning and can produce syntax error and stop js)
345 sed 's|\\|\\\\|g; s|"|\\"|g' $historyfile | awk '
346 BEGIN{ i=1; printf("ash_history=[") }
347 { printf("\"%s\",", $0); i++ }
348 END{
349 printf("\"\"];")
350 i--; printf("cur_hist=\"%d\";max_hist=\"%d\";", i, i)
351 }'
352 cat <<EOT
353 </script>
354 EOT
355 ;;
358 *\ rmhistory\ *)
359 # Manage shell commandline history
360 user="$REMOTE_USER"
361 HOME="$(getdb passwd | awk -F: -vu="$user" '$1==u{print $6}')"
362 historyfile="$HOME/.ash_history"
364 # Return sed command for removing history lines ('8d12d' to remove 8 and 12 lines)
365 rms=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="rm")printf "%dd", $2}')
367 if [ -n "$rms" ]; then
368 # Actually remove lines
369 sed -i $rms $historyfile
370 # Redirects back to the history table
371 header "HTTP/1.1 301 Moved Permanently" "Location: ?terminal&cmd=history&path=$(GET path)"
372 exit 0
373 fi
374 ;;
377 *\ termsettings\ *)
378 # Terminal settings
379 header; xhtml_header "$(_ 'Terminal')"
380 user="$REMOTE_USER"
381 font="$(GET font)"; font="${font:-$TERM_FONT}"
382 palette="$(GET palette)"; palette="${palette:-$TERM_PALETTE}"
383 pal=$(echo $palette | tr A-Z a-z)
385 # Add or change settings in TazPanel config
386 if [ -z "$TERM_FONT" ]; then
387 echo -e "\n# Terminal font family\nTERM_FONT=\"$font\"" >> $CONFIG
388 else
389 sed -i "s|TERM_FONT=.*|TERM_FONT=\"$font\"|" $CONFIG
390 fi
391 if [ -z "$TERM_PALETTE" ]; then
392 echo -e "\n# Terminal color palette\nTERM_PALETTE=\"$palette\"" >> $CONFIG
393 else
394 sed -i "s|TERM_PALETTE=.*|TERM_PALETTE=\"$palette\"|" $CONFIG
395 fi
397 cat <<EOT
398 <section style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0.5rem;">
399 <header>
400 $(_ 'Terminal settings')
401 <form>
402 <button name="terminal" data-icon="terminal">$(_ 'Terminal')</button>
403 </form>
404 </header>
405 <pre class="term $pal" style="height: auto; font-family: '$font'">
406 <span class='color31'>$user@$(hostname)</span>:<span class='color33'>~</span># palette
408 $(
409 for i in $(seq 30 37); do
410 for b in 0 1; do
411 for j in $(seq 40 47); do
412 echo -n "<span class=\"color$b color$i color$j\">$i:$j</span>"
413 done
414 done
415 echo
416 done
417 )
418 </pre>
419 <footer>
420 <form class="wide">
421 $(_ 'Font:')
422 <select name="font">
423 <option value="">$(_ 'Default')</option>
424 $(fc-list :spacing=mono:lang=en family | sed '/\.pcf/d;/,/d;s|\\-|-|g' | sort -u | \
425 awk -vfont="$font" '{
426 printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == font)?" selected":"", $0)
427 }')
428 </select>
429 $(_ 'Palette:')
430 <select name="palette">
431 $(echo -e 'Tango\nLinux\nXterm\nRxvt\nEcho' | awk -vpal="$palette" '{
432 printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == pal)?" selected":"", $0)
433 }')
434 </select>
435 <button name="termsettings" data-icon="ok">$(_ 'Apply')</button>
436 </form>
437 </footer>
438 </section>
439 EOT
441 ;;
444 *\ top\ *)
445 header; xhtml_header "$(_ 'Process activity')"
447 r=$(GET refresh)
448 cat <<EOT
449 <form>
450 <p>$(_ 'Refresh:')
451 <input type="hidden" name="top"/>
452 <input type="radio" name="refresh" value="1" id="r1" $([ "$r" == 1 ] && echo checked) onchange="this.form.submit()"/>
453 <label for="r1">$(_ '1s' )</label>
454 <input type="radio" name="refresh" value="5" id="r2" $([ "$r" == 5 ] && echo checked) onchange="this.form.submit()"/>
455 <label for="r2">$(_ '5s' )</label>
456 <input type="radio" name="refresh" value="10" id="r3" $([ "$r" == 10 ] && echo checked) onchange="this.form.submit()"/>
457 <label for="r3">$(_ '10s' )</label>
458 <input type="radio" name="refresh" value="" id="r4" $([ -z "$r" ] && echo checked) onchange="this.form.submit()"/>
459 <label for="r4">$(_ 'none')</label>
460 </p>
461 </form>
462 EOT
463 [ -n "$r" ] && echo "<meta http-equiv=\"refresh\" content=\"$r\">"
465 echo '<section><div><pre class="term log">'
466 top -n1 -b | htmlize | sed \
467 -e 's|^[A-Z].*:|<span class="color1 color31">\0</span>|g' \
468 -e 's|^\ *PID|<span class="color1 color32">\0</span>|g'
469 echo '</pre></div></section>' ;;
472 *\ debug\ *)
473 header; xhtml_header "$(_ 'Debug')"
475 cat <<EOT
476 <h2>$(_ 'HTTP Environment')</h2>
478 <section>
479 <div>
480 <pre>$(httpinfo | syntax_highlighter conf)</pre>
481 </div>
482 </section>
483 EOT
484 ;;
487 *\ report\ *)
488 header; xhtml_header "$(_ 'System report')"
490 [ -d '/var/cache/slitaz' ] || mkdir -p /var/cache/slitaz
491 output='/var/cache/slitaz/sys-report.html'
493 cat <<EOT
494 <section>
495 <header>$(_ 'Reporting to: %s' "$output")</header>
496 <table class="wide zebra">
497 <tbody>
498 <tr><td>$(_ 'Creating report header...')</td>
499 EOT
500 cat > $output <<EOT
501 <!DOCTYPE html>
502 <html xmlns="http://www.w3.org/1999/xhtml">
503 <head>
504 <meta charset="utf-8"/>
505 <title>$(_ 'SliTaz system report')</title>
506 <style type="text/css">
507 body { padding: 20px 60px; font-size: 13px; }
508 h1, h2 { color: #444; }
509 pre { background: #f1f1f1; border: 1px solid #ddd;
510 padding: 10px; border-radius: 4px; }
511 span.diff-rm { color: red; }
512 span.diff-add { color: green; }
513 </style>
514 </head>
515 <body>
516 EOT
517 cat <<EOT
518 $(ok_status_t)
519 <tr><td>$(_ 'Creating system summary...')</td>
520 EOT
521 cat >> $output <<EOT
522 <h1>$(_ 'SliTaz system report')</h1>
523 $(_ 'Date:') $(date)
524 <pre>
525 uptime : $(uptime)
526 cmdline : $(cat /proc/cmdline)
527 version : $(cat /etc/slitaz-release)
528 packages : $(ls /var/lib/tazpkg/installed | wc -l) installed
529 kernel : $(uname -r)
530 </pre>
531 EOT
532 cat <<EOT
533 $(ok_status_t)
534 <tr><td>$(_ 'Getting hardware info...')</td>
535 EOT
536 cat >> $output <<EOT
537 <h2>free</h2>
538 <pre>$(free)</pre>
540 <h2>lspci -k</h2>
541 <pre>$(lspci -k)</pre>
543 <h2>lsusb</h2>
544 <pre>$(lsusb)</pre>
546 <h2>lsmod</h2>
547 <pre>$(lsmod)</pre>
549 EOT
550 cat <<EOT
551 $(ok_status_t)
552 <tr><td>$(_ 'Getting networking info...')</td>
553 EOT
554 cat >> $output <<EOT
555 <h2>ifconfig -a</h2>
556 <pre>$(ifconfig -a)</pre>
558 <h2>route -n</h2>
559 <pre>$(route -n)</pre>
561 <h2>/etc/resolv.conf</h2>
562 <pre>$(cat /etc/resolv.conf)</pre>
563 EOT
564 cat <<EOT
565 $(ok_status_t)
566 <tr><td>$(_ 'Getting filesystems info...')</td>
567 EOT
568 cat >> $output <<EOT
569 <h2>blkid</h2>
570 <pre>$(blkid)</pre>
572 <h2>fdisk -l</h2>
573 <pre>$(fdisk -l)</pre>
575 <h2>mount</h2>
576 <pre>$(mount)</pre>
578 <h2>df -h</h2>
579 <pre>$(df -h)</pre>
581 <h2>df -i</h2>
582 <pre>$(df -i)</pre>
583 EOT
584 cat <<EOT
585 $(ok_status_t)
586 <tr><td>$(_ 'Getting boot logs...')</td>
587 EOT
588 cat >> $output <<EOT
589 <h2>$(_ 'Kernel messages')</h2>
590 <pre>$(cat /var/log/dmesg.log)</pre>
592 <h2>$(_ 'Boot scripts')</h2>
593 <pre>$(filter_taztools_msgs < /var/log/boot.log)</pre>
594 EOT
595 cat <<EOT
596 $(ok_status_t)
597 <tr><td>$(_ 'Getting package list...')</td>
598 EOT
599 cat >> $output <<EOT
600 <h2>$(_ 'Packages')</h2>
601 EOT
602 ( cd /var/lib/tazpkg/installed
603 for i in * ; do
604 echo "$i $(. $i/receipt ; echo "$VERSION $DEPENDS" | xargs echo ;
605 echo "$PROVIDE" | sed 's/:[^ ]*//g' | xargs echo PROVIDE)"
606 done ) | awk '{
607 if ($1 == "PROVIDE") {
608 for (i = 2; i <= NF; i++) alias[$i] = 1
609 }
610 else { pkg[$1]=$0; idx[c++]=$1 }
611 }
612 function name(n)
613 {
614 split(pkg[n], x, " ")
615 return x[1] " (" x[2] ") "
616 }
617 END {
618 print "<pre>"
619 for (i in pkg) for (j = split(pkg[i], p, " "); j > 2; j--) {
620 if (pkg[p[j]] || alias[p[j]]) kill[p[j]]=1
621 else print "Missing dep " p[j] " for " name(p[1])
622 }
623 print ""
624 n=0
625 for (i=0; i < c; i++) {
626 if (kill[idx[i]]) continue
627 printf "%s" name(idx[i])
628 if (n++ < 2) continue
629 printf "\n"
630 n=0
631 }
632 print "</pre>"
633 }
634 ' >> $output
635 if [ "$(ls report.d/* 2> /dev/null)" ]; then
636 cat <<EOT
637 $(ok_status_t)
638 <tr><td>$(_ 'Getting extra reports...')</td>
639 EOT
640 for i in report.d/* ; do
641 sh $i $i >> $output
642 done
643 fi
644 cat <<EOT
645 $(ok_status_t)
646 <tr><td>$(_ 'Creating report footer...')</td>
647 EOT
648 cat >> $output <<EOT
649 </body>
650 </html>
651 EOT
652 cat <<EOT
653 $(ok_status_t)
654 </tbody>
655 </table>
656 <footer>
657 <form><button name="file" value="$output" data-icon="view">$(_ 'View')</button></form>
658 </footer>
659 </section>
662 $(msg tip "$(_ 'This report can be attached with a bug report on:')
663 <a href="http://bugs.slitaz.org/" target="_blank">bugs.slitaz.org</a></p>")
664 EOT
665 ;;
668 *)
669 #
670 # Default xHTML content
671 #
672 header; xhtml_header "$(_ 'SliTaz administration and configuration Panel')"
673 [ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale)
674 [ -n "$(GET rdate)" ] && echo ""
675 hostname=$(hostname)
677 cat <<EOT
678 <form class="nogap"><!--
679 --><button name="terminal" data-icon="terminal">$(_ 'Terminal')</button><!--
680 --><button name="top" data-icon="proc" >$(_ 'Process activity')</button><!--
681 --><button name="report" data-icon="report" data-root>$(_ 'Create a report')</button><!--
682 --></form>
684 <section>
685 <header>$(_ 'Summary')</header>
686 <table>
687 <tr><td>$(_ 'Host:')</td><td>$hostname</td></tr>
688 <tr><td>$(_ 'Uptime:')</td>
689 <td id="uptime">$(uptime | sed 's|\([0-9.:][0-9.:]*\)|<b>\1</b>|g')</td>
690 </tr>
691 <tr><td>$(_ 'Memory in Mb:')</td>
692 <td>$(free -m | grep Mem: | \
693 awk -vline="$(gettext 'Total: %d, Used: %d, Free: %d')" \
694 '{ printf(line, $2, $3, $4) }' | \
695 sed 's|\([0-9][0-9]*\)|<b>\1</b>|g')</td>
696 </tr>
697 <tr><td>$(_ 'Linux kernel:')</td>
698 <td>$(uname -r)</td>
699 </tr>
700 </table>
701 </section>
704 <section>
705 <header>
706 $(_ 'Network status')
707 <form action="network.cgi">
708 <button data-icon="wifi">$(_ 'Network')</button>
709 </form>
710 </header>
711 $(list_network_interfaces)
712 </section>
715 <section>
716 <header>
717 $(_ 'Filesystem usage statistics')
718 <form action="hardware.cgi">
719 <button data-icon="hdd">$(_ 'Disks')</button>
720 </form>
721 </header>
722 <table class="wide zebra center">
723 EOT
724 # Disk stats (management is done as hardware.cgi)
725 df_thead
726 echo '<tbody>'
727 df -h | grep ^/dev | while read fs size used av pct mp; do
728 cat <<EOT
729 <tr>
730 <td><span data-icon="hdd">${fs#/dev/}</span></td>
731 <td>$(blkid $fs | sed '/LABEL=/!d;s/.*LABEL="\([^"]*\).*/\1/')</td>
732 <td>$(blkid $fs | sed '/TYPE=/!d;s/.*TYPE="\([^"]*\).*/\1/')</td>
733 <td>$size</td>
734 <td>$av</td>
735 <td class="meter"><meter min="0" max="100" value="$(echo $pct | cut -d% -f1)"
736 low="$DU_WARN" high="$DU_CRIT" optimum="10"></meter>
737 <span>$used - $pct</span>
738 </td>
739 <td>$mp</td>
740 <td>$(blkid $fs | sed '/UUID=/!d;s/.*UUID="\([^"]*\).*/\1/')</td>
741 </tr>
742 EOT
743 done
744 cat <<EOT
745 </tbody>
746 </table>
747 </section>
749 <section>
750 <header>
751 $(_ 'Panel Activity')
752 <form>
753 <button name="file" value="$LOG_FILE" data-icon="view">$(_ 'View')</button>
754 </form>
755 </header>
756 <div>
757 <pre id="panel-activity">
758 $(tail -n 8 < $LOG_FILE | sort -r | syntax_highlighter activity)</pre>
759 </div>
760 </section>
761 EOT
762 ;;
763 esac
765 xhtml_footer
766 exit 0