tazpanel diff boot.cgi @ rev 419
Bunch of changes. Development in progress, please note it have few known bugs.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Mar 24 03:39:08 2015 +0200 (2015-03-24) |
parents | 7475f4b95a7b |
children | 7488b357abd3 |
line diff
1.1 --- a/boot.cgi Sun Jan 18 18:59:01 2015 +0100 1.2 +++ b/boot.cgi Tue Mar 24 03:39:08 2015 +0200 1.3 @@ -2,73 +2,89 @@ 1.4 # 1.5 # Boot CGI script - All what happens before login (grub, rcS, slim) 1.6 # 1.7 -# Copyright (C) 2011-2014 SliTaz GNU/Linux - BSD License 1.8 +# Copyright (C) 2011-2015 SliTaz GNU/Linux - BSD License 1.9 # 1.10 1.11 + 1.12 # Common functions from libtazpanel and source main boot config file. 1.13 + 1.14 . lib/libtazpanel 1.15 . /etc/rcS.conf 1.16 +get_config 1.17 header 1.18 -get_config 1.19 1.20 TITLE=$(gettext 'TazPanel - Boot') 1.21 1.22 + 1.23 +# Print last 40 lines of given file with "more" link 1.24 + 1.25 loghead() 1.26 { 1.27 - tail -n 40 $1 | htmlize 1.28 + case $2 in 1.29 + htmlize) tail -n40 $1 | htmlize;; 1.30 + *) tail -n40;; 1.31 + esac 1.32 [ $(wc -l < $1) -gt 40 ] && cat <<EOT 1.33 -<hr /><a href="/index.cgi?file=$1">$(gettext 'Show more...')</a> 1.34 +<hr/><a href="/index.cgi?file=$1">$(gettext 'Show more...')</a> 1.35 EOT 1.36 } 1.37 1.38 + 1.39 # 1.40 # Commands 1.41 # 1.42 1.43 case " $(GET) " in 1.44 *\ log\ *) 1.45 - unset actboot actslim actxlog actkernel 1.46 + unset actboot actslim actxlog actkernel colors 1.47 case "$(GET log)" in 1.48 - boot) actboot=' class="active"' 1.49 - output="$(filter_taztools_msgs < /var/log/boot.log)" 1.50 - ;; 1.51 - slim) actslim=' class="active"' 1.52 - output="$(loghead /var/log/slim.log)" ;; 1.53 - xlog) actxlog=' class="active"' 1.54 - output="$(loghead /var/log/Xorg.0.log)" ;; 1.55 - *) actkernel=' class="active"' 1.56 - output="$(syntax_highlighter kernel < /var/log/dmesg.log)" 1.57 + boot) 1.58 + actboot=' class="active"' 1.59 + output="$(filter_taztools_msgs < /var/log/boot.log)" 1.60 + colors=' class="term log"';; 1.61 + slim) 1.62 + actslim=' class="active"' 1.63 + output="$(loghead /var/log/slim.log htmlize)" ;; 1.64 + xlog) 1.65 + actxlog=' class="active"' 1.66 + output="$(syntax_highlighter xlog < /var/log/Xorg.0.log | loghead /var/log/Xorg.0.log)" ;; 1.67 + *) 1.68 + actkernel=' class="active"' 1.69 + output="$(syntax_highlighter kernel < /var/log/dmesg.log | loghead /var/log/dmesg.log)" ;; 1.70 esac 1.71 xhtml_header 1.72 - cat << EOT 1.73 -<div id="wrapper"> 1.74 - <h2>$(gettext 'Boot log files')</h2> 1.75 -</div> 1.76 + cat <<EOT 1.77 +<h2>$(gettext 'Boot log files')</h2> 1.78 + 1.79 <ul id="tabs"> 1.80 <li$actkernel><a href="?log=kernel">$(gettext 'Kernel messages')</a></li> 1.81 - <li$actboot><a href="?log=boot">$(gettext 'Boot scripts')</a></li> 1.82 - <li$actxlog><a href="?log=xlog">$(gettext 'X server')</a></li> 1.83 - <li$actslim><a href="?log=slim">$(gettext 'X session')</a></li> 1.84 + <li$actboot ><a href="?log=boot" >$(gettext 'Boot scripts' )</a></li> 1.85 + <li$actxlog ><a href="?log=xlog" >$(gettext 'X server' )</a></li> 1.86 + <li$actslim ><a href="?log=slim" >$(gettext 'X session' )</a></li> 1.87 </ul> 1.88 -<pre> 1.89 -$output 1.90 -</pre> 1.91 + 1.92 +<section> 1.93 + <div> 1.94 + <pre$colors>$output</pre> 1.95 + </div> 1.96 +</section> 1.97 EOT 1.98 ;; 1.99 + 1.100 + 1.101 *\ daemons\ *) 1.102 # 1.103 # Everything until user login 1.104 # 1.105 - # Start and stop a daemon. I think we don't need a restart since 2 1.106 - # clicks and you are done 1.107 + # Start and stop a daemon. 1.108 + # (I think we don't need a 'restart' since 2 clicks and you are done) 1.109 . /etc/rcS.conf 1.110 xhtml_header 1.111 1.112 - cat << EOT 1.113 -<div id="wrapper"> 1.114 - <h2>$(gettext 'Manage daemons')</h2> 1.115 - <p>$(gettext 'Check, start and stop daemons on SliTaz')</p> 1.116 -</div> 1.117 + cat <<EOT 1.118 +<h2>$(gettext 'Manage daemons')</h2> 1.119 + 1.120 +<p>$(gettext 'Check, start and stop daemons on SliTaz')</p> 1.121 EOT 1.122 daemon=$(GET daemons) 1.123 case "$daemon" in 1.124 @@ -85,37 +101,34 @@ 1.125 done 1.126 echo "</pre>" ;; 1.127 esac 1.128 + 1.129 # Daemon list 1.130 - table_start 1.131 - cat << EOT 1.132 -<thead> 1.133 - <tr> 1.134 - <td>$(gettext 'Name')</td> 1.135 - <td>$(gettext 'Description')</td> 1.136 - <td>$(gettext 'Configuration')</td> 1.137 - <td>$(gettext 'Status')</td> 1.138 - <td>$(gettext 'Action')</td> 1.139 - <td>$(gettext 'PID')</td> 1.140 - </tr> 1.141 -</thead> 1.142 + cat <<EOT 1.143 +<section> 1.144 + <table class="zebra wide daemons"> 1.145 + <thead> 1.146 + <tr> 1.147 + <td>$(gettext 'Name')</td> 1.148 + <td>$(gettext 'Description')</td> 1.149 + <td>$(gettext 'Configuration')</td> 1.150 + <td>$(gettext 'Status')</td> 1.151 + <td>$(gettext 'Action')</td> 1.152 + <td>$(gettext 'PID')</td> 1.153 + </tr> 1.154 + </thead> 1.155 + <tbody> 1.156 EOT 1.157 cd /etc/init.d 1.158 - list="`ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d \ 1.159 - -e /firewall/d`" 1.160 - for name in $list 1.161 - do 1.162 - pkg="" 1.163 - pid="" 1.164 - status="" 1.165 - SHORT_DESC="" 1.166 + list="$(ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d -e /firewall/d)" 1.167 + for name in $list; do 1.168 + unset pkg pid status SHORT_DESC boot cfg 1.169 echo '<tr>' 1.170 # Name 1.171 echo "<td>$name</td>" 1.172 - # First check if daemon is started at bootime 1.173 + # First check if daemon is started at boottime 1.174 [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot" 1.175 # Standard SliTaz busybox daemons and firewall 1.176 echo -n "<td>" 1.177 - cfg="" 1.178 grep -qi "^${name}_OPTIONS=" /etc/daemons.conf && cfg="options|$cfg" 1.179 for i in /etc/slitaz /etc /etc/$name ; do 1.180 [ -s $i/$name.conf ] && cfg="edit::$i/$name.conf|$cfg" 1.181 @@ -156,6 +169,7 @@ 1.182 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam 1.183 if [ "$pkg" ]; then 1.184 unset SHORT_DESC TAZPANEL_DAEMON 1.185 +#FIXME $PKGS_DB 1.186 . $LOCALSTATE/installed/$pkg/receipt 1.187 echo -n "$SHORT_DESC" 1.188 cfg="${TAZPANEL_DAEMON:-$cfg|web::$WEB_SITE}" 1.189 @@ -167,44 +181,47 @@ 1.190 # Attempt to get daemon status 1.191 pidfile=$(find /var/run -name *$name*.pid) 1.192 [ "$pidfile" ] && pid=$(cat $pidfile) 1.193 - # dbus 1.194 + # Dbus 1.195 [ -f /var/run/${name}/pid ] && pid=$(cat /var/run/${name}/pid) 1.196 - # apache 1.197 + # Apache 1.198 [ "$name" = "apache" ] && pid=$(cat /var/run/$name/httpd.pid) 1.199 # Pidof works for many daemons 1.200 [ "$pid" ] || pid=$(pidof $name) 1.201 - echo -n "<td>" 1.202 - if [ "$cfg" ]; then 1.203 + 1.204 + echo -n "<td style='white-space: nowrap'>" 1.205 + if [ -n "$cfg" ]; then 1.206 IFS="|" 1.207 for i in $cfg ; do 1.208 IFS=":" 1.209 set -- $i 1.210 case "$1" in 1.211 - edit) cat <<EOT 1.212 -<a href="index.cgi?file=${3:-/etc/$name.conf}&action=edit"> 1.213 -<img title="${2:-$name Configuration}" src="$IMAGES/edit.png" /></a> 1.214 + edit) 1.215 + cat <<EOT 1.216 +<a href="index.cgi?file=${3:-/etc/$name.conf}&action=edit" title="${2:-$name Configuration}" data-img="conf"></a> 1.217 EOT 1.218 ;; 1.219 options) 1.220 - key=$(echo $name | tr [a-z] [A-Z])_OPTIONS 1.221 + key=$(echo -n $name | tr [a-z] [A-Z])_OPTIONS 1.222 cat <<EOT 1.223 -<a href="index.cgi?file=/etc/daemons.conf&action=setvar&var=$key&default=$3"> 1.224 -<img title="${2:-$key}" src="$IMAGES/tux.png" /></a> 1.225 +<a href="index.cgi?file=/etc/daemons.conf&action=setvar&var=$key&default=$3" title="${2:-$key}" data-img="opt"></a> 1.226 EOT 1.227 ;; 1.228 - man) cat <<EOT 1.229 -<a href="index.cgi?exec=man ${3:-$name}"> 1.230 -<img title="${2:-$name Manual}" src="$IMAGES/text.png" /></a> 1.231 + man) 1.232 + cat <<EOT 1.233 +<a href="index.cgi?exec=man ${3:-$name}&back=boot.cgi%3Fdaemons" title="${2:-$name Manual}" data-img="man"></a> 1.234 EOT 1.235 ;; 1.236 - help) cat <<EOT 1.237 -<a href="index.cgi?exec=$(which ${3:-$name}) --help"> 1.238 -<img title="${2:-$name Help}" src="$IMAGES/help.png" /></a> 1.239 + help) 1.240 + help='--help' 1.241 + case $name in 1.242 + cupsd|dropbear|gpm|slim|wpa_supplicant) help='-h' 1.243 + esac 1.244 + cat <<EOT 1.245 +<a href="index.cgi?exec=$(which ${3:-$name}) $help&back=boot.cgi%3Fdaemons" title="${2:-$name Help}" data-img="help"></a> 1.246 EOT 1.247 ;; 1.248 web) cat <<EOT 1.249 -<a href="${i#$1:$2:}"> 1.250 -<img title="${2:-$name website:} ${i#$1:$2:}" src="$IMAGES/browser.png" /></a> 1.251 +<a href="${i#$1:$2:}" title="${2:-$name website:} ${i#$1:$2:}" target="_blank" data-img="web"></a> 1.252 EOT 1.253 ;; 1.254 esac 1.255 @@ -212,28 +229,27 @@ 1.256 fi 1.257 echo "</td>" 1.258 if [ "$pid" ]; then 1.259 - cat << EOT 1.260 -<td><img src="$IMAGES/started.png" alt="Started" title="$(gettext 'Started')" /></td> 1.261 -<td><a href="?daemons=stop=$name"> 1.262 - <img src="$IMAGES/stop.png" alt="Stop" title="$(gettext 'Stop')" /></a></td> 1.263 + cat <<EOT 1.264 +<td><span title="$(gettext 'Started')" data-img="on"></span></td> 1.265 +<td><a href="?daemons=stop=$name" title="$(gettext 'Stop')" data-img="stop"></a></td> 1.266 <td> 1.267 EOT 1.268 for i in $pid; do 1.269 - cat << EOT 1.270 + cat <<EOT 1.271 <a href="?daemons=pid=$i">$i</a> 1.272 EOT 1.273 done 1.274 else 1.275 - cat << EOT 1.276 -<td><img src="$IMAGES/stopped.png" alt="Stopped" title="$(gettext 'Stopped')" /></td> 1.277 -<td><a href="?daemons=start=$name"> 1.278 - <img src="$IMAGES/start.png" alt="Start" title="$(gettext 'Start')" /></a></td> 1.279 + cat <<EOT 1.280 +<td><span title="$(gettext 'Stopped')" data-img="off"></span></td> 1.281 +<td><a href="?daemons=start=$name" title="$(gettext 'Start')" data-img="start"></a></td> 1.282 <td>----- 1.283 EOT 1.284 fi 1.285 echo '</td></tr>' 1.286 done 1.287 - table_end ;; 1.288 + echo '</thead></table></section>' ;; 1.289 + 1.290 1.291 *\ grub\ *) 1.292 GRUBMENU="/boot/grub/menu.lst" 1.293 @@ -247,93 +263,126 @@ 1.294 -e s"|splashimage=.*|splashimage=$splash|" \ 1.295 $GRUBMENU 1.296 fi 1.297 - default=$(cat $GRUBMENU | grep ^default | cut -d " " -f 2) 1.298 - timeout=$(cat $GRUBMENU | grep ^timeout | cut -d " " -f 2) 1.299 - splash=$(cat $GRUBMENU | grep ^splashimage | cut -d "=" -f 2) 1.300 + default=$(cat $GRUBMENU | grep ^default | cut -d' ' -f2) 1.301 + timeout=$(cat $GRUBMENU | grep ^timeout | cut -d' ' -f2) 1.302 + splash=$(cat $GRUBMENU | grep ^splashimage | cut -d' ' -f2) 1.303 xhtml_header 1.304 - cat << EOT 1.305 -<div id="wrapper"> 1.306 - <h2>$(gettext 'GRUB Boot loader')</h2> 1.307 + cat <<EOT 1.308 +<h2>$(gettext 'GRUB Boot loader')</h2> 1.309 1.310 - <p>$(gettext 'The first application started when the computer powers on')</p> 1.311 -</div> 1.312 +<p>$(gettext 'The first application started when the computer powers on')</p> 1.313 1.314 -<form method="get" action=""> 1.315 - <input type="hidden" name="grub" /> 1.316 -<table> 1.317 -<tr><td>$(gettext 'Default entry:')</td> 1.318 - <td><input type="text" name="default" value="$default" /></td></tr> 1.319 -<tr><td>$(gettext 'Timeout:')</td> 1.320 - <td><input type="text" name="timeout" value="$timeout" /></td></tr> 1.321 -<tr><td>$(gettext 'Splash image:')</td> 1.322 - <td><input type="text" name="splash" value="$splash" size="40" /></td></tr> 1.323 -</table> 1.324 - <input type="submit" value="$(gettext 'Change')" /> 1.325 - <a class="button" href="index.cgi?file=$GRUBMENU"> 1.326 - <img src="$IMAGES/text.png" />$(gettext 'View or edit menu.lst')</a> 1.327 +<form class="wide"> 1.328 + <section> 1.329 + <div> 1.330 + <input type="hidden" name="grub"/> 1.331 + <table> 1.332 + <tr><td>$(gettext 'Default entry:')</td> 1.333 + <td><input type="text" name="default" value="${default##*=}"/></td></tr> 1.334 + <tr><td>$(gettext 'Timeout:')</td> 1.335 + <td><input type="text" name="timeout" value="${timeout##*=}"/></td></tr> 1.336 + <tr><td>$(gettext 'Splash image:')</td> 1.337 + <td><input type="text" name="splash" value="${splash##*=}" size="40"/></td></tr> 1.338 + </table> 1.339 + </div> 1.340 + <footer> 1.341 + <button type="submit" data-icon="ok">$(gettext 'Change')</button> 1.342 + </footer> 1.343 + </section> 1.344 </form> 1.345 1.346 -<h3>$(gettext 'Boot entries')</h3> 1.347 +<form action="index.cgi"> 1.348 + <input type="hidden" name="file" value="$GRUBMENU"/> 1.349 + <button data-icon="text">$(gettext 'View or edit menu.lst')</button> 1.350 +</form> 1.351 + 1.352 + 1.353 +<section> 1.354 + <header>$(gettext 'Boot entries')</header> 1.355 + <div> 1.356 EOT 1.357 1.358 1.359 -menu=$(tail -q -n +$(grep -n ^title $GRUBMENU | head -n1 | cut -d: -f1) $GRUBMENU \ 1.360 - | sed -e "s|^$||g" \ 1.361 - | sed -e "s|^title|</pre></li>\n<p><strong>$(gettext 'Entry') #</strong></p>\n<pre>\0|g" \ 1.362 - | sed '/^[ \t]*$/d' \ 1.363 - | tail -q -n +2)"</pre>" 1.364 +menu=$(tail -q -n +$(grep -n ^title $GRUBMENU | head -n1 | cut -d: -f1) $GRUBMENU | \ 1.365 + sed -e "s|^$||g" | \ 1.366 + sed -e "s|^title|</pre></div>\n</section>\n\n<section>\n\t<header>$(gettext 'Entry') #</header>\n<div><pre style=\"white-space:pre-wrap\">\0|g" | \ 1.367 + sed '/^[ \t]*$/d' | \ 1.368 + tail -q -n +2)"</pre>" 1.369 1.370 entry='-1' 1.371 echo "$menu" | while read line 1.372 do 1.373 - if [ -n "$(echo $line | grep '#</strong>')" ]; then 1.374 + if [ -n "$(echo $line | grep '#</header>')" ]; then 1.375 entry=$(($entry + 1)) 1.376 fi 1.377 - echo $line | sed "s|#</strong>|$entry</strong>|" 1.378 + echo $line | sed "s|#</header>|$entry</header>|" 1.379 done 1.380 1.381 + echo '</section>' 1.382 + 1.383 + 1.384 # Here we could check if an entry for gpxe is present if not 1.385 # display a form to add it. 1.386 - [ -f "/boot/gpxe" ] && echo "<h3>gPXE</h3>" && \ 1.387 - gettext 'Web boot is available with gPXE' 1.388 + [ -f "/boot/gpxe" ] && cat <<EOT 1.389 +<section> 1.390 + <header>gPXE</header> 1.391 + <div>$(gettext 'Web boot is available with gPXE')</div> 1.392 +</section> 1.393 +EOT 1.394 ;; 1.395 + 1.396 + 1.397 *) 1.398 # 1.399 # Default content with summary 1.400 # 1.401 . /etc/rcS.conf 1.402 xhtml_header 1.403 - cat << EOT 1.404 -<div id="wrapper"> 1.405 - <h2>$(gettext 'Boot & Start services')</h2> 1.406 - <p>$(gettext 'Everything that happens before user login')</p> 1.407 -</div> 1.408 -<div> 1.409 - <a class="button" href="?log"> 1.410 - <img src="$IMAGES/text.png" />$(gettext 'Boot logs')</a> 1.411 - <a class="button" href="?daemons"> 1.412 - <img src="$IMAGES/recharge.png" />$(gettext 'Manage daemons')</a> 1.413 - <a class="button" href="?grub">$(gettext 'Boot loader')</a> 1.414 -</div> 1.415 + cat <<EOT 1.416 +<h2>$(gettext 'Boot & Start services')</h2> 1.417 1.418 -<h3>$(gettext 'Configuration files')</h3> 1.419 -<ul> 1.420 - <li>$(gettext 'Main configuration file:') 1.421 - <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li> 1.422 - <li>$(gettext 'Login manager settings:') 1.423 - <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li> 1.424 -</ul> 1.425 +<p>$(gettext 'Everything that happens before user login')</p> 1.426 1.427 -<h3>$(gettext 'Kernel cmdline')</h3> 1.428 +<form> 1.429 + <button name="log" data-icon="logs" >$(gettext 'Boot logs' )</button> 1.430 + <button name="daemons" data-icon="daemons">$(gettext 'Manage daemons')</button> 1.431 + <button name="grub" data-icon="grub" >$(gettext 'Boot loader' )</button> 1.432 +</form> 1.433 1.434 -<pre>$(cat /proc/cmdline)</pre> 1.435 1.436 -<h3>$(gettext 'Local startup commands')</h3> 1.437 +<section> 1.438 + <header>$(gettext 'Configuration files')</header> 1.439 + <form action="index.cgi" class="wide"> 1.440 + <table> 1.441 + <tr><td>$(gettext 'Main configuration file:') <b>rcS.conf</b></td> 1.442 + <td><button name="file" value="/etc/rcS.conf" data-icon="view">$(gettext 'View')</button></td></tr> 1.443 + <tr><td>$(gettext 'Login manager settings:') <b>slim.conf</b></td> 1.444 + <td><button name="file" value="/etc/slim.conf" data-icon="view">$(gettext 'View')</button></td></tr> 1.445 + </table> 1.446 + </form> 1.447 +</section> 1.448 1.449 -<pre>$(cat /etc/init.d/local.sh | syntax_highlighter sh)</pre> 1.450 1.451 -<a class="button" href="index.cgi?file=/etc/init.d/local.sh&action=edit"> 1.452 -<img src="$IMAGES/edit.png" />$(gettext 'Edit script')</a> 1.453 +<section> 1.454 + <header>$(gettext 'Kernel cmdline')</header> 1.455 + <div> 1.456 + <pre>$(cat /proc/cmdline)</pre> 1.457 + </div> 1.458 +</section> 1.459 + 1.460 + 1.461 +<section> 1.462 + <header>$(gettext 'Local startup commands')</header> 1.463 + <div> 1.464 + <pre>$(cat /etc/init.d/local.sh | syntax_highlighter sh)</pre> 1.465 + </div> 1.466 + <footer> 1.467 + <form action="index.cgi"> 1.468 + <input type="hidden" name="file" value="/etc/init.d/local.sh"/> 1.469 + <button name="action" value="edit" data-icon="edit">$(gettext 'Edit script')</button> 1.470 + </form> 1.471 + </footer> 1.472 +</section> 1.473 EOT 1.474 ;; 1.475 esac