tazpanel annotate index.cgi @ rev 429

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