tazpanel annotate index.cgi @ rev 437

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