tazpanel view index.cgi @ rev 546

Update po/fr.po (thanks llev)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Nov 11 10:40:12 2015 +0100 (2015-11-11)
parents bf55c6eae402
children e480cc8cc7eb
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 $(back_button)
123 </header>
124 <textarea form="editform" name="content" class="wide" rows="30" autofocus>$(htmlize < $file)</textarea>
125 </section>
126 EOT
127 #The space before textarea gets muddled when the form is submitted.
128 #It prevents anything else from getting messed up
129 ;;
131 setvar)
132 data="$(. $(GET file) ;eval echo \$$(GET var))"
133 cat <<EOT
134 <section>
135 <header>$(GET var)</header>
136 <form method="post" action="?file=$file" class="nogap">
137 <input type="hidden" name="var" value="$(GET var)">
138 <input type="text" name="content" value="${data:-$(GET default)}">
139 <button type="submit" data-icon="save">$(_ 'Save')</button>
140 </form>
141 </section>
142 EOT
143 ;;
145 diff)
146 cat <<EOT
147 <section>
148 $(back_button)
149 <pre id="diff">$(file_is_modified $file diff | syntax_highlighter diff)</pre>
150 </section>
151 EOT
152 ;;
154 *)
155 R=$(echo -en '\r')
156 if [ -n "$(POST content)" ]; then
157 if [ -n "$(POST var)" ]; then
158 sed -i "s|^\\($(POST var)=\\).*|\1\"$(POST content)\"|" $file
159 else
160 sed "s/$R /\n/g;s/$R%0//g" > $file <<EOT
161 $(POST content)
162 EOT
163 fi
164 fi
166 cat <<EOT
167 <section class="bigNoScrollable">
168 <header>
169 <span data-icon="text">${title:-$file}</span>
170 EOT
171 if [ -w "$file" ]; then
172 cat <<EOT
173 <form>
174 <input type="hidden" name="file" value="$file"/>
175 <button onclick='editFile(); return false' id="edit_button"
176 data-icon="edit">$(_ 'Edit')</button><!--
177 --><button onclick='saveFile("$file", "$title"); return false' id="save_button"
178 data-icon="save" style="display:none">$(_ 'Save')</button><!--
179 -->$(file_is_modified $file button)
180 </form>
181 EOT
182 elif [ -r "$file" ]; then
183 cat <<EOT
184 <form>
185 <input type="hidden" name="file" value="$file"/>
186 $(file_is_modified $file button)
187 </form>
188 EOT
189 fi
190 cat <<EOT
191 </header>
193 <div>
194 <pre id="fileContent" class="bigScrollable">
195 EOT
196 end_code=''
197 # Handle file type by extension as a Web Server does it.
198 case "$file" in
199 *.sh|*.cgi|*/receipt|*.conf)
200 echo '<code class="language-bash">'; end_code='</code>'
201 htmlize ;;
202 *.ini)
203 echo '<code class="language-ini">'; end_code='</code>'
204 htmlize ;;
205 *.conf|*.lst)
206 syntax_highlighter conf ;;
207 *Xorg.0.log)
208 syntax_highlighter xlog ;;
209 *dmesg.log)
210 syntax_highlighter kernel ;;
211 *)
212 htmlize ;;
213 esac < $file
214 cat <<EOT
215 $end_code</pre>
216 </div>
217 </section>
218 EOT
219 esac
220 ;;
224 *\ terminal\ *|*\ cmd\ *)
225 # Cmdline terminal
227 header; xhtml_header "$(_ 'Terminal')"
229 user="$REMOTE_USER"
230 HOME="$(getdb passwd | awk -F: -vu=$user '$1==u{print $6}')"
231 historyfile="$HOME/.ash_history"
233 cmd=$(GET cmd)
234 path="$(GET path)"; path="${path:-/tmp}"; cd "$path"
236 font="${TERM_FONT:-monospace}"
237 palette=$(echo $TERM_PALETTE | tr A-Z a-z)
239 [ -n "$cmd" -a "$cmd" != "$(tail -n1 $historyfile)" ] && echo "$cmd" >> $historyfile
242 # Terminal history
244 if [ "$cmd" == 'history' ]; then
245 cat <<EOT
246 <section>
247 <header>
248 $(_ 'History')
249 <form><button name="terminal" data-icon="terminal">$(_ 'Back')</button></form>
250 </header>
251 <form>
252 <input type="hidden" name="path" value="$path"/>
253 <pre class="term $palette" style="font-family: '$font'">
254 EOT
256 htmlize < $historyfile | awk -vrun="$(_ 'run')" -vpath="$path" -vq="'" '
257 BEGIN { num = 1; }
258 {
259 printf("%3d ", num);
260 cmd = $0;
261 gsub("%", "%25", cmd); gsub("+", "%2B", cmd); gsub(" ", "+", cmd);
262 gsub("\"", "%22", cmd); gsub("!", "%21", cmd); gsub(q, "%27", cmd);
263 printf("<a data-icon=\"run\" href=\"?cmd=%s&path=%s\">%s</a> ", cmd, path, run);
264 printf("<input type=\"checkbox\" name=\"rm\" value=\"%d\" id=\"hist%d\">", num, num);
265 printf("<label for=\"hist%d\">%s</label>\n", num, $0);
266 num++;
267 }'
269 cat <<EOT
270 </pre>
271 <footer>
272 <button name="rmhistory" data-icon="remove">$(_ 'Clear')</button>
273 </footer>
274 </form>
275 </section>
276 EOT
277 xhtml_footer
278 exit 0
279 fi
282 # Terminal window
284 cat <<EOT
285 <span id="num_hist"></span>
286 <section>
287 <pre class="term $palette" style="font-family: '$font'" onclick="document.getElementById('typeField').focus()">
288 EOT
289 if [ -n "$cmd" ]; then
290 term_prompt
291 echo "$cmd" | htmlize
292 fi
294 case "$cmd" in
295 usage|help)
296 _ 'Small non-interactive terminal emulator.'; echo
297 _ 'Run any command at your own risk, avoid interactive commands (%s)' 'nano, mc, ...'; echo
298 ;;
299 wget*)
300 dl='/var/cache/downloads'
301 [ ! -d "$dl" ] && mkdir -p $dl
302 _ 'Downloading to: %s' $dl; echo
303 cd $dl; $cmd 2>&1 ;;
304 cd|cd\ *)
305 path="${cmd#cd}"; path="${path:-$HOME}";
306 path="$(realpath $path)"; cd "$path" ;;
307 ls|ls\ *)
308 $cmd -w80 --color=always 2>&1 | filter_taztools_msgs ;;
309 cat)
310 # Cmd must be used with an arg.
311 _ '%s needs an argument' "$cmd" ;;
312 mc|nano|su)
313 # List of restricted (interactive) commands
314 _ "Please, don't run interactive command \"%s\"" "$cmd"; echo; echo ;;
315 *)
316 unset HTTP_REFERER # for fooling /lib/libtaz.sh formatting utils (<hr> in the terminal is so-so)
317 export DISPLAY=:0.0 # for run X applications
318 /bin/sh -c "$cmd" 2>&1 | htmlize | filter_taztools_msgs
319 ;;
320 esac
322 cat <<EOT
323 <form id="term">
324 <div class="cmdline" id="cmdline"><span id="prompt">$(term_prompt)</span><span id="typeField"> </span></div>
325 <input type="hidden" name="path" value="$(pwd)"/>
326 <input type="hidden" name="cmd" id="cmd"/>
327 </form>
328 </pre>
329 </section>
331 <form>
332 <button name="termsettings" data-icon="settings">$(_ 'Settings')</button>
333 <button name="cmd" value="history" data-icon="history">$(_ 'History')</button>
334 </form>
336 <script type="text/javascript">
337 with (document.getElementById('typeField')) {
338 contentEditable=true;
339 focus();
340 }
341 document.onkeydown=keydownHandler;
342 EOT
344 # Export history as array.
345 # Escape "all \"quotes\" in quotes", and all '\'
346 # (because \u, \x, \c has special meaning and can produce syntax error and stop js)
347 sed 's|\\|\\\\|g; s|"|\\"|g' $historyfile | awk '
348 BEGIN{ i=1; printf("ash_history=[") }
349 { printf("\"%s\",", $0); i++ }
350 END{
351 printf("\"\"];")
352 i--; printf("cur_hist=\"%d\";max_hist=\"%d\";", i, i)
353 }'
354 cat <<EOT
355 </script>
356 EOT
357 ;;
360 *\ rmhistory\ *)
361 # Manage shell commandline history
362 user="$REMOTE_USER"
363 HOME="$(getdb passwd | awk -F: -vu="$user" '$1==u{print $6}')"
364 historyfile="$HOME/.ash_history"
366 # Return sed command for removing history lines ('8d12d' to remove 8 and 12 lines)
367 rms=$(echo $QUERY_STRING | awk 'BEGIN{RS="&";FS="="}{if($1=="rm")printf "%dd", $2}')
369 if [ -n "$rms" ]; then
370 # Actually remove lines
371 sed -i $rms $historyfile
372 # Redirects back to the history table
373 header "HTTP/1.1 301 Moved Permanently" "Location: ?terminal&cmd=history&path=$(GET path)"
374 exit 0
375 fi
376 ;;
379 *\ termsettings\ *)
380 # Terminal settings
381 header; xhtml_header "$(_ 'Terminal')"
382 user="$REMOTE_USER"
383 font="$(GET font)"; font="${font:-$TERM_FONT}"
384 palette="$(GET palette)"; palette="${palette:-$TERM_PALETTE}"
385 pal=$(echo $palette | tr A-Z a-z)
387 # Add or change settings in TazPanel config
388 if [ -z "$TERM_FONT" ]; then
389 echo -e "\n# Terminal font family\nTERM_FONT=\"$font\"" >> $CONFIG
390 else
391 sed -i "s|TERM_FONT=.*|TERM_FONT=\"$font\"|" $CONFIG
392 fi
393 if [ -z "$TERM_PALETTE" ]; then
394 echo -e "\n# Terminal color palette\nTERM_PALETTE=\"$palette\"" >> $CONFIG
395 else
396 sed -i "s|TERM_PALETTE=.*|TERM_PALETTE=\"$palette\"|" $CONFIG
397 fi
399 cat <<EOT
400 <section style="position: absolute; top: 0; bottom: 0; left: 0; right: 0; margin: 0.5rem;">
401 <header>
402 $(_ 'Terminal settings')
403 <form>
404 <button name="terminal" data-icon="terminal">$(_ 'Terminal')</button>
405 </form>
406 </header>
407 <pre class="term $pal" style="height: auto; font-family: '$font'">
408 <span class='color31'>$user@$(hostname)</span>:<span class='color33'>~</span># palette
410 $(
411 for i in $(seq 30 37); do
412 for b in 0 1; do
413 for j in $(seq 40 47); do
414 echo -n "<span class=\"color$b color$i color$j\">$i:$j</span>"
415 done
416 done
417 echo
418 done
419 )
420 </pre>
421 <footer>
422 <form class="wide">
423 $(_ 'Font:')
424 <select name="font">
425 <option value="">$(_ 'Default')</option>
426 $(fc-list :spacing=mono:lang=en family | sed '/\.pcf/d;/,/d;s|\\-|-|g' | sort -u | \
427 awk -vfont="$font" '{
428 printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == font)?" selected":"", $0)
429 }')
430 </select>
431 $(_ 'Palette:')
432 <select name="palette">
433 $(echo -e 'Tango\nLinux\nXterm\nRxvt\nEcho' | awk -vpal="$palette" '{
434 printf("<option value=\"%s\"%s>%s</option>\n", $0, ($0 == pal)?" selected":"", $0)
435 }')
436 </select>
437 <button name="termsettings" data-icon="ok">$(_ 'Apply')</button>
438 </form>
439 </footer>
440 </section>
441 EOT
443 ;;
446 *\ top\ *)
447 header; xhtml_header "$(_ 'Process activity')"
449 r=$(GET refresh)
450 cat <<EOT
451 <form>
452 <p>$(_ 'Refresh:')
453 <input type="hidden" name="top"/>
454 <input type="radio" name="refresh" value="1" id="r1" $([ "$r" == 1 ] && echo checked) onchange="this.form.submit()"/>
455 <label for="r1">$(_ '1s' )</label>
456 <input type="radio" name="refresh" value="5" id="r2" $([ "$r" == 5 ] && echo checked) onchange="this.form.submit()"/>
457 <label for="r2">$(_ '5s' )</label>
458 <input type="radio" name="refresh" value="10" id="r3" $([ "$r" == 10 ] && echo checked) onchange="this.form.submit()"/>
459 <label for="r3">$(_ '10s' )</label>
460 <input type="radio" name="refresh" value="" id="r4" $([ -z "$r" ] && echo checked) onchange="this.form.submit()"/>
461 <label for="r4">$(_ 'none')</label>
462 </p>
463 </form>
464 EOT
465 [ -n "$r" ] && echo "<meta http-equiv=\"refresh\" content=\"$r\">"
467 [ "$(GET renice)" ] && renice $(GET renice)
468 [ "$(GET kill)" ] && kill $(GET kill)
469 if [ "$(GET pid)" ] && [ -d /proc/$(GET pid)/ ]; then
470 curpid=$(GET pid)
471 curnice=$(awk '{ print $19 }' /proc/$curpid/stat)
472 cat <<EOT
473 <section>
474 <header>
475 $(ps auxww | sed "/^ *$curpid /!d")
476 <form>
477 <input type="hidden" name="top"/>
478 <button type="submit" data-icon="remove" name="kill" value="$curpid">$(_ 'Kill')</button>
479 </form>
480 </header>
481 <form>
482 <p>$(_ 'Renice')[$curnice]
483 <input type="hidden" name="top"/>
484 EOT
485 values="+19 +15 +10 +5 +3 +1 0 -1 -3 -5 -10 -15 -19"
486 [ $(id -u) -eq 0 ] || values="+19 +15 +10 +5 +3 +1"
487 for i in $values ; do
488 cat <<EOT
489 <input type="radio" name="renice" value="$i $curpid" $([ $curnice -eq $i ] && echo checked) onchange="this.form.submit()"/>
490 <label>$i</label>
491 EOT
492 done
493 cat <<EOT
494 </p>
495 </form>
496 </section>
497 EOT
498 fi
499 echo '<section><div><pre class="term log">'
500 busybox top -n1 -b | htmlize | sed \
501 -e 's|^\( *\)\([0-9][0-9]*\)|\1<a href="?top\&amp;pid=\2">\2</a>|' \
502 -e 's|^[A-Z].*:|<span class="color1 color31">\0</span>|g' \
503 -e 's|^\ *PID|<span class="color1 color32">\0</span>|g'
504 echo '</pre></div></section>' ;;
507 *\ debug\ *)
508 header; xhtml_header "$(_ 'Debug')"
510 cat <<EOT
511 <h2>$(_ 'HTTP Environment')</h2>
513 <section>
514 <div>
515 <pre>$(httpinfo | syntax_highlighter conf)</pre>
516 </div>
517 </section>
518 EOT
519 ;;
522 *\ report\ *)
523 header; xhtml_header "$(_ 'System report')"
525 [ -d '/var/cache/slitaz' ] || mkdir -p /var/cache/slitaz
526 output='/var/cache/slitaz/sys-report.html'
528 cat <<EOT
529 <section>
530 <header>$(_ 'Reporting to: %s' "$output")</header>
531 <table class="wide zebra">
532 <tbody>
533 <tr><td>$(_ 'Creating report header...')</td>
534 EOT
535 cat > $output <<EOT
536 <!DOCTYPE html>
537 <html xmlns="http://www.w3.org/1999/xhtml">
538 <head>
539 <meta charset="utf-8"/>
540 <title>$(_ 'SliTaz system report')</title>
541 <style type="text/css">
542 body { padding: 20px 60px; font-size: 13px; }
543 h1, h2 { color: #444; }
544 pre { background: #f1f1f1; border: 1px solid #ddd;
545 padding: 10px; border-radius: 4px; }
546 span.diff-rm { color: red; }
547 span.diff-add { color: green; }
548 </style>
549 </head>
550 <body>
551 EOT
552 cat <<EOT
553 $(ok_status_t)
554 <tr><td>$(_ 'Creating system summary...')</td>
555 EOT
556 cat >> $output <<EOT
557 <h1>$(_ 'SliTaz system report')</h1>
558 $(_ 'Date:') $(date)
559 <pre>
560 uptime : $(uptime)
561 cmdline : $(cat /proc/cmdline)
562 version : $(cat /etc/slitaz-release)
563 packages : $(ls /var/lib/tazpkg/installed | wc -l) installed
564 kernel : $(uname -r)
565 </pre>
566 EOT
567 cat <<EOT
568 $(ok_status_t)
569 <tr><td>$(_ 'Getting hardware info...')</td>
570 EOT
571 cat >> $output <<EOT
572 <h2>free</h2>
573 <pre>$(free)</pre>
575 <h2>lspci -k</h2>
576 <pre>$(lspci -k)</pre>
578 <h2>lsusb</h2>
579 <pre>$(lsusb)</pre>
581 <h2>lsmod</h2>
582 <pre>$(lsmod)</pre>
584 EOT
585 cat <<EOT
586 $(ok_status_t)
587 <tr><td>$(_ 'Getting networking info...')</td>
588 EOT
589 cat >> $output <<EOT
590 <h2>ifconfig -a</h2>
591 <pre>$(ifconfig -a)</pre>
593 <h2>route -n</h2>
594 <pre>$(route -n)</pre>
596 <h2>/etc/resolv.conf</h2>
597 <pre>$(cat /etc/resolv.conf)</pre>
598 EOT
599 cat <<EOT
600 $(ok_status_t)
601 <tr><td>$(_ 'Getting filesystems info...')</td>
602 EOT
603 cat >> $output <<EOT
604 <h2>blkid</h2>
605 <pre>$(blkid)</pre>
607 <h2>fdisk -l</h2>
608 <pre>$(fdisk -l)</pre>
610 <h2>mount</h2>
611 <pre>$(mount)</pre>
613 <h2>df -h</h2>
614 <pre>$(df -h)</pre>
616 <h2>df -i</h2>
617 <pre>$(df -i)</pre>
618 EOT
619 cat <<EOT
620 $(ok_status_t)
621 <tr><td>$(_ 'Getting boot logs...')</td>
622 EOT
623 cat >> $output <<EOT
624 <h2>$(_ 'Kernel messages')</h2>
625 <pre>$(cat /var/log/dmesg.log)</pre>
627 <h2>$(_ 'Boot scripts')</h2>
628 <pre>$(filter_taztools_msgs < /var/log/boot.log)</pre>
629 EOT
630 cat <<EOT
631 $(ok_status_t)
632 <tr><td>$(_ 'Getting package list...')</td>
633 EOT
634 cat >> $output <<EOT
635 <h2>$(_ 'Packages')</h2>
636 EOT
637 ( cd /var/lib/tazpkg/installed
638 for i in * ; do
639 echo "$i $(. $i/receipt ; echo "$VERSION $DEPENDS" | xargs echo ;
640 echo "$PROVIDE" | sed 's/:[^ ]*//g' | xargs echo PROVIDE)"
641 done ) | awk '{
642 if ($1 == "PROVIDE") {
643 for (i = 2; i <= NF; i++) alias[$i] = 1
644 }
645 else { pkg[$1]=$0; idx[c++]=$1 }
646 }
647 function name(n)
648 {
649 split(pkg[n], x, " ")
650 return x[1] " (" x[2] ") "
651 }
652 END {
653 print "<pre>"
654 for (i in pkg) for (j = split(pkg[i], p, " "); j > 2; j--) {
655 if (pkg[p[j]] || alias[p[j]]) kill[p[j]]=1
656 else { miss=1 ; print "Missing dep " p[j] " for " name(p[1]) }
657 }
658 if (miss) print ""
659 n=0
660 for (i=0; i < c; i++) {
661 if (kill[idx[i]]) continue
662 printf "%s" name(idx[i])
663 if (n++ < 2) continue
664 printf "\n"
665 n=0
666 }
667 print "</pre>"
668 }
669 ' >> $output
670 if [ "$(ls report.d/* 2> /dev/null)" ]; then
671 cat <<EOT
672 $(ok_status_t)
673 <tr><td>$(_ 'Getting extra reports...')</td>
674 EOT
675 for i in report.d/* ; do
676 sh $i $i >> $output
677 done
678 fi
679 cat <<EOT
680 $(ok_status_t)
681 <tr><td>$(_ 'Creating report footer...')</td>
682 EOT
683 cat >> $output <<EOT
684 </body>
685 </html>
686 EOT
687 cat <<EOT
688 $(ok_status_t)
689 </tbody>
690 </table>
691 <footer>
692 <form><button name="file" value="$output" data-icon="view">$(_ 'View')</button></form>
693 </footer>
694 </section>
697 $(msg tip "$(_ 'This report can be attached with a bug report on:')
698 <a href="http://bugs.slitaz.org/" target="_blank">bugs.slitaz.org</a></p>")
699 EOT
700 ;;
703 *)
704 #
705 # Default xHTML content
706 #
707 header; xhtml_header "$(_ 'SliTaz administration and configuration Panel')"
708 [ -n "$(GET gen_locale)" ] && new_locale=$(GET gen_locale)
709 [ -n "$(GET rdate)" ] && echo ""
710 hostname=$(hostname)
712 cat <<EOT
713 <form class="nogap"><!--
714 --><button name="terminal" data-icon="terminal">$(_ 'Terminal')</button><!--
715 --><button name="top" data-icon="proc" >$(_ 'Process activity')</button><!--
716 --><button name="report" data-icon="report" data-root>$(_ 'Create a report')</button><!--
717 --></form>
719 <section>
720 <header>$(_ 'Summary')</header>
721 <table>
722 <tr><td>$(_ 'Host:')</td><td>$hostname</td></tr>
723 <tr><td>$(_ 'Uptime:')</td>
724 <td id="uptime">$(uptime | sed 's|\([0-9.:][0-9.:]*\)|<b>\1</b>|g')</td>
725 </tr>
726 <tr><td>$(_ 'Memory in Mb:')</td>
727 <td>$(free -m | grep Mem: | \
728 awk -vline="$(gettext 'Total: %d, Used: %d, Free: %d')" \
729 '{ printf(line, $2, $3, $4) }' | \
730 sed 's|\([0-9][0-9]*\)|<b>\1</b>|g')</td>
731 </tr>
732 <tr><td>$(_ 'Linux kernel:')</td>
733 <td>$(uname -r)</td>
734 </tr>
735 </table>
736 </section>
739 <section>
740 <header>
741 $(_ 'Network status')
742 <form action="network.cgi">
743 <button data-icon="wifi">$(_ 'Network')</button>
744 </form>
745 </header>
746 $(list_network_interfaces)
747 </section>
750 <section>
751 <header>
752 $(_ 'Filesystem usage statistics')
753 <form action="hardware.cgi">
754 <button data-icon="hdd">$(_ 'Disks')</button>
755 </form>
756 </header>
757 <table class="wide zebra center">
758 EOT
759 # Disk stats (management is done as hardware.cgi)
760 df_thead
761 echo '<tbody>'
762 df -h | grep ^/dev | while read fs size used av pct mp; do
763 cat <<EOT
764 <tr>
765 <td><span data-icon="hdd">${fs#/dev/}</span></td>
766 <td>$(blkid $fs | sed '/LABEL=/!d;s/.*LABEL="\([^"]*\).*/\1/')</td>
767 <td>$(blkid $fs | sed '/TYPE=/!d;s/.*TYPE="\([^"]*\).*/\1/')</td>
768 <td>$size</td>
769 <td>$av</td>
770 <td class="meter"><meter min="0" max="100" value="$(echo $pct | cut -d% -f1)"
771 low="$DU_WARN" high="$DU_CRIT" optimum="10"></meter>
772 <span>$used - $pct</span>
773 </td>
774 <td>$mp</td>
775 <td>$(blkid $fs | sed '/UUID=/!d;s/.*UUID="\([^"]*\).*/\1/')</td>
776 </tr>
777 EOT
778 done
779 cat <<EOT
780 </tbody>
781 </table>
782 </section>
784 <section>
785 <header>
786 $(_ 'Panel Activity')
787 <form>
788 <button name="file" value="$LOG_FILE" data-icon="view">$(_ 'View')</button>
789 </form>
790 </header>
791 <div>
792 <pre id="panel-activity">
793 $(tail -n 8 < $LOG_FILE | sort -r | syntax_highlighter activity)</pre>
794 </div>
795 </section>
796 EOT
797 ;;
798 esac
800 xhtml_footer
801 exit 0