tazpanel annotate index.cgi @ rev 434

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