tazpanel annotate boot.cgi @ rev 366
boot.cgi/daemon: add website
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sat Jun 29 21:29:35 2013 +0200 (2013-06-29) |
parents | 4a8f56bb08cb |
children | 6e181d55abdc |
rev | line source |
---|---|
pankso@50 | 1 #!/bin/sh |
pankso@50 | 2 # |
paul@82 | 3 # Boot CGI script - All what happens before login (grub, rcS, slim) |
pankso@50 | 4 # |
pankso@112 | 5 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License |
pankso@50 | 6 # |
pankso@50 | 7 |
pankso@50 | 8 # Common functions from libtazpanel and source main boot config file. |
pankso@50 | 9 . lib/libtazpanel |
pankso@50 | 10 . /etc/rcS.conf |
pascal@81 | 11 header |
pankso@50 | 12 get_config |
pankso@50 | 13 |
al@292 | 14 TITLE=$(gettext 'TazPanel - Boot') |
pankso@50 | 15 |
pankso@50 | 16 # |
pankso@50 | 17 # Commands |
pankso@50 | 18 # |
pankso@50 | 19 |
pascal@81 | 20 case " $(GET) " in |
pascal@130 | 21 *\ log\ *) |
pascal@130 | 22 xhtml_header |
pascal@130 | 23 cat << EOT |
pascal@130 | 24 <div id="wrapper"> |
al@303 | 25 <h2>$(gettext 'Boot log files')</h2> |
pascal@130 | 26 </div> |
pascal@137 | 27 <div> |
pascal@137 | 28 <a class="button" href="#kernel"> |
al@303 | 29 <img src="$IMAGES/tux.png" />$(gettext 'Kernel messages')</a> |
al@303 | 30 <a class="button" href="#boot">$(gettext 'Boot scripts')</a> |
al@303 | 31 <a class="button" href="#slim">$(gettext 'X server')</a> |
pascal@137 | 32 </div> |
al@303 | 33 |
al@303 | 34 <h3 id="kernel">$(gettext 'Kernel messages')</h3> |
al@303 | 35 |
al@303 | 36 <pre>$(cat /var/log/dmesg.log | syntax_highlighter kernel)</pre> |
al@303 | 37 |
al@303 | 38 <h3 id="boot">$(gettext 'Boot scripts')</h3> |
al@303 | 39 |
al@303 | 40 <pre>$(cat /var/log/boot.log | filter_taztools_msgs)</pre> |
al@303 | 41 |
al@303 | 42 <h3 id="slim">$(gettext 'X server')</h3> |
al@303 | 43 |
pascal@130 | 44 <pre> |
al@303 | 45 $(tail -n 40 /var/log/slim.log | htmlize) |
al@303 | 46 <hr /><a href="/index.cgi?file=/var/log/slim.log">$(gettext 'Show more...')</a> |
al@303 | 47 </pre> |
pascal@130 | 48 EOT |
pascal@130 | 49 ;; |
pascal@81 | 50 *\ daemons\ *) |
pankso@51 | 51 # |
pankso@51 | 52 # Everything until user login |
pankso@51 | 53 # |
al@292 | 54 # Start and stop a daemon. I think we don't need a restart since 2 |
paul@52 | 55 # clicks and you are done |
pankso@51 | 56 . /etc/rcS.conf |
pankso@51 | 57 xhtml_header |
al@292 | 58 |
pankso@51 | 59 cat << EOT |
pankso@51 | 60 <div id="wrapper"> |
al@303 | 61 <h2>$(gettext 'Manage daemons')</h2> |
al@303 | 62 <p>$(gettext 'Check, start and stop daemons on SliTaz')</p> |
pankso@51 | 63 </div> |
pankso@51 | 64 EOT |
pascal@143 | 65 daemon=$(GET daemons) |
pascal@143 | 66 case "$daemon" in |
pascal@143 | 67 start=*) |
pascal@143 | 68 sleep 1 |
pascal@143 | 69 /etc/init.d/${daemon#start=} start | log ;; |
pascal@143 | 70 stop=*) |
pascal@143 | 71 /etc/init.d/${daemon#stop=} stop | log ;; |
pascal@143 | 72 pid=*) |
pascal@143 | 73 echo "<pre>" |
pascal@143 | 74 ps ww | sed "1p;/^ *${daemon#pid=} /!d" |
pascal@143 | 75 echo "</pre>" ;; |
pascal@143 | 76 esac |
paul@205 | 77 # Daemon list |
pankso@51 | 78 table_start |
pankso@51 | 79 cat << EOT |
pankso@51 | 80 <thead> |
pankso@51 | 81 <tr> |
al@303 | 82 <td>$(gettext 'Name')</td> |
al@303 | 83 <td>$(gettext 'Description')</td> |
pascal@366 | 84 <td>$(gettext 'Configuration')</td> |
al@303 | 85 <td>$(gettext 'Status')</td> |
al@303 | 86 <td>$(gettext 'Action')</td> |
al@303 | 87 <td>$(gettext 'PID')</td> |
pankso@51 | 88 </tr> |
pankso@51 | 89 </thead> |
pankso@51 | 90 EOT |
pankso@51 | 91 cd /etc/init.d |
pankso@51 | 92 list="`ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d \ |
pankso@51 | 93 -e /firewall/d`" |
pankso@51 | 94 for name in $list |
pankso@51 | 95 do |
pankso@51 | 96 pkg="" |
pankso@51 | 97 pid="" |
pankso@51 | 98 status="" |
pankso@51 | 99 SHORT_DESC="" |
pankso@51 | 100 echo '<tr>' |
pankso@51 | 101 # Name |
pankso@51 | 102 echo "<td>$name</td>" |
paul@52 | 103 # First check if daemon is started at bootime |
pankso@51 | 104 [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot" |
paul@52 | 105 # Standard SliTaz busybox daemons and firewall |
al@303 | 106 echo -n "<td>" |
pascal@364 | 107 cfg="" |
pascal@364 | 108 grep -qi "^${name}_OPTIONS=" /etc/daemons.conf && cfg="options|$cfg" |
pascal@364 | 109 [ -s /etc/$name.conf ] && cfg="edit|$cfg" |
pascal@364 | 110 [ -n "$(which $name)" ] && cfg="man|help|$cfg" |
pankso@51 | 111 case "$name" in |
pankso@51 | 112 firewall) |
al@303 | 113 gettext 'SliTaz Firewall with iptable rules' ;; |
pankso@51 | 114 httpd) |
al@303 | 115 gettext 'Small and fast web server with CGI support' ;; |
pankso@51 | 116 ntpd) |
al@303 | 117 gettext 'Network time protocol daemon' ;; |
pankso@51 | 118 ftpd) |
pascal@364 | 119 cfg="man|help|edit::/etc/inetd.conf" |
al@303 | 120 gettext 'Anonymous FTP server' ;; |
pankso@51 | 121 udhcpd) |
al@303 | 122 gettext 'Busybox DHCP server' ;; |
pankso@51 | 123 syslogd|klogd) |
al@303 | 124 gettext 'Linux Kernel log daemon' ;; |
pankso@76 | 125 crond) |
pascal@364 | 126 # FIXME crontab |
al@303 | 127 gettext 'Execute scheduled commands' ;; |
pankso@76 | 128 dnsd) |
pascal@364 | 129 cfg="man|help|edit|options::-d" |
al@303 | 130 gettext 'Small static DNS server daemon' ;; |
pankso@76 | 131 tftpd) |
pascal@364 | 132 cfg="man|help|edit::/etc/inetd.conf" |
al@303 | 133 gettext 'Transfer a file on tftp request' ;; |
pankso@76 | 134 inetd) |
al@303 | 135 gettext 'Listen for network connections and launch programs' ;; |
pankso@76 | 136 zcip) |
pascal@364 | 137 cfg="man|help|edit:Script:/etc/zcip.script|options::eth0 /etc/zcip.script" |
al@303 | 138 gettext 'Manage a ZeroConf IPv4 link-local address' ;; |
pankso@51 | 139 *) |
paul@205 | 140 # Description from receipt |
pankso@51 | 141 [ -d "$LOCALSTATE/installed/$name" ] && pkg=$name |
pankso@51 | 142 [ -d "$LOCALSTATE/installed/${name%d}" ] && pkg=${name%d} |
pankso@51 | 143 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam |
pankso@51 | 144 if [ "$pkg" ]; then |
pascal@364 | 145 unset SHORT_DESC TAZPANEL_DAEMON |
pankso@51 | 146 . $LOCALSTATE/installed/$pkg/receipt |
al@303 | 147 echo -n "$SHORT_DESC" |
pascal@366 | 148 cfg="${TAZPANEL_DAEMON:-$cfg|web::$WEB_SITE}" |
pankso@51 | 149 else |
al@303 | 150 echo -n "----" |
pankso@51 | 151 fi ;; |
pankso@51 | 152 esac |
al@303 | 153 echo "</td>" |
paul@205 | 154 # Attempt to get daemon status |
al@303 | 155 pidfile=$(find /var/run -name *$name*.pid) |
al@303 | 156 [ "$pidfile" ] && pid=$(cat $pidfile) |
pankso@51 | 157 # dbus |
al@303 | 158 [ -f /var/run/${name}/pid ] && pid=$(cat /var/run/${name}/pid) |
pankso@51 | 159 # apache |
al@303 | 160 [ "$name" = "apache" ] && pid=$(cat /var/run/$name/httpd.pid) |
paul@205 | 161 # Pidof works for many daemons |
al@303 | 162 [ "$pid" ] || pid=$(pidof $name) |
pascal@364 | 163 echo -n "<td>" |
pascal@364 | 164 if [ "$cfg" ]; then |
pascal@364 | 165 IFS="|" |
pascal@364 | 166 for i in $cfg ; do |
pascal@364 | 167 IFS=":" |
pascal@364 | 168 set -- $i |
pascal@364 | 169 case "$1" in |
pascal@364 | 170 edit) cat <<EOT |
pascal@364 | 171 <a href="index.cgi?file=${3:-/etc/$name.conf}&action=edit"> |
pascal@364 | 172 <img title="${2:-$name Configuration}" src="$IMAGES/edit.png" /></a> |
pascal@364 | 173 EOT |
pascal@364 | 174 ;; |
pascal@364 | 175 options) |
pascal@364 | 176 key=$(echo $name | tr [a-z] [A-Z])_OPTIONS |
pascal@364 | 177 cat <<EOT |
pascal@364 | 178 <a href="index.cgi?file=/etc/daemons.conf&action=setvar&var=$key&default=$3"> |
pascal@364 | 179 <img title="${2:-$key}" src="$IMAGES/tux.png" /></a> |
pascal@364 | 180 EOT |
pascal@364 | 181 ;; |
pascal@364 | 182 man) cat <<EOT |
pascal@364 | 183 <a href="index.cgi?exec=man ${3:-$name}"> |
pascal@364 | 184 <img title="${2:-$name Manual}" src="$IMAGES/text.png" /></a> |
pascal@364 | 185 EOT |
pascal@364 | 186 ;; |
pascal@364 | 187 help) cat <<EOT |
pascal@364 | 188 <a href="index.cgi?exec=$(which ${3:-$name}) --help"> |
pascal@364 | 189 <img title="${2:-$name Help}" src="$IMAGES/help.png" /></a> |
pascal@364 | 190 EOT |
pascal@364 | 191 ;; |
pascal@364 | 192 web) cat <<EOT |
pascal@364 | 193 <a href="${i#$1:$2:}"> |
pascal@366 | 194 <img title="${2:-$name website:} ${i#$1:$2:}" src="$IMAGES/browser.png" /></a> |
pascal@364 | 195 EOT |
pascal@364 | 196 ;; |
pascal@364 | 197 esac |
pascal@364 | 198 done |
pascal@364 | 199 fi |
pascal@364 | 200 echo "</td>" |
pankso@51 | 201 if [ "$pid" ]; then |
pascal@143 | 202 cat << EOT |
al@303 | 203 <td><img src="$IMAGES/started.png" alt="Started" title="$(gettext 'Started')" /></td> |
pascal@143 | 204 <td><a href="$SCRIPT_NAME?daemons=stop=$name"> |
al@303 | 205 <img src="$IMAGES/stop.png" alt="Stop" title="$(gettext 'Stop')" /></a></td> |
pascal@143 | 206 <td> |
pascal@143 | 207 EOT |
pascal@143 | 208 for i in $pid; do |
pascal@143 | 209 cat << EOT |
pascal@143 | 210 <a href="$SCRIPT_NAME?daemons=pid=$i">$i</a> |
pascal@143 | 211 EOT |
pascal@143 | 212 done |
pankso@51 | 213 else |
pascal@143 | 214 cat << EOT |
al@303 | 215 <td><img src="$IMAGES/stopped.png" alt="Stopped" title="$(gettext 'Stopped')" /></td> |
pascal@143 | 216 <td><a href="$SCRIPT_NAME?daemons=start=$name"> |
al@303 | 217 <img src="$IMAGES/start.png" alt="Start" title="$(gettext 'Start')" /></a></td> |
pascal@143 | 218 <td>----- |
pascal@143 | 219 EOT |
pankso@51 | 220 fi |
pascal@143 | 221 echo '</td></tr>' |
pankso@51 | 222 done |
pankso@51 | 223 table_end ;; |
al@303 | 224 |
pankso@151 | 225 *\ grub\ *) |
al@303 | 226 GRUBMENU="/boot/grub/menu.lst" |
pankso@151 | 227 if [ "$(GET splash)" ]; then |
pankso@151 | 228 default=$(GET default) |
pankso@151 | 229 timeout=$(GET timeout) |
pankso@151 | 230 splash=$(GET splash) |
pankso@151 | 231 sed -i \ |
al@303 | 232 -e s"|default .*|default $default # new|" \ |
al@303 | 233 -e s"|timeout .*|timeout $timeout|" \ |
al@303 | 234 -e s"|splashimage=.*|splashimage=$splash|" \ |
al@303 | 235 $GRUBMENU |
pankso@151 | 236 fi |
al@303 | 237 default=$(cat $GRUBMENU | grep ^default | cut -d " " -f 2) |
al@303 | 238 timeout=$(cat $GRUBMENU | grep ^timeout | cut -d " " -f 2) |
al@303 | 239 splash=$(cat $GRUBMENU | grep ^splashimage | cut -d "=" -f 2) |
pankso@151 | 240 xhtml_header |
pankso@151 | 241 cat << EOT |
pankso@151 | 242 <div id="wrapper"> |
al@303 | 243 <h2>$(gettext 'GRUB Boot loader')</h2> |
al@303 | 244 |
al@303 | 245 <p>$(gettext 'The first application started when the computer powers on')</p> |
pankso@151 | 246 </div> |
pankso@151 | 247 |
pankso@151 | 248 <form method="get" action="$SCRIPT_NAME"> |
pankso@151 | 249 <input type="hidden" name="grub" /> |
al@303 | 250 <table> |
al@303 | 251 <tr><td>$(gettext 'Default entry:')</td> |
al@303 | 252 <td><input type="text" name="default" value="$default" /></td></tr> |
al@303 | 253 <tr><td>$(gettext 'Timeout:')</td> |
al@303 | 254 <td><input type="text" name="timeout" value="$timeout" /></td></tr> |
al@303 | 255 <tr><td>$(gettext 'Splash image:')</td> |
al@303 | 256 <td><input type="text" name="splash" value="$splash" size="40" /></td></tr> |
al@303 | 257 </table> |
al@303 | 258 <input type="submit" value="$(gettext 'Change')" /> |
al@303 | 259 <a class="button" href="index.cgi?file=$GRUBMENU"> |
al@303 | 260 <img src="$IMAGES/text.png" />$(gettext 'View or edit menu.lst')</a> |
pankso@151 | 261 </form> |
pankso@151 | 262 |
al@303 | 263 <h3>$(gettext 'Boot entries')</h3> |
pankso@151 | 264 EOT |
al@303 | 265 |
al@303 | 266 |
al@303 | 267 menu=$(tail -q -n +$(grep -n ^title $GRUBMENU | head -n1 | cut -d: -f1) $GRUBMENU \ |
al@303 | 268 | sed -e "s|^$||g" \ |
al@303 | 269 | sed -e "s|^title|</pre></li>\n<p><strong>$(gettext 'Entry') #</strong></p>\n<pre>\0|g" \ |
al@303 | 270 | sed '/^[ \t]*$/d' \ |
al@303 | 271 | tail -q -n +2)"</pre>" |
al@303 | 272 |
pankso@151 | 273 entry='-1' |
al@303 | 274 echo "$menu" | while read line |
pankso@151 | 275 do |
al@303 | 276 if [ -n "$(echo $line | grep '#</strong>')" ]; then |
al@303 | 277 entry=$(($entry + 1)) |
al@303 | 278 fi |
al@303 | 279 echo $line | sed "s|#</strong>|$entry</strong>|" |
pankso@151 | 280 done |
al@303 | 281 |
pankso@151 | 282 # Here we could check if an entry for gpxe is present if not |
pankso@151 | 283 # display a form to add it. |
pankso@151 | 284 [ -f "/boot/gpxe" ] && echo "<h3>gPXE</h3>" && \ |
al@303 | 285 gettext 'Web boot is available with gPXE' |
pankso@151 | 286 ;; |
pankso@50 | 287 *) |
pankso@50 | 288 # |
pankso@51 | 289 # Default content with summary |
pankso@50 | 290 # |
pankso@50 | 291 . /etc/rcS.conf |
pankso@50 | 292 xhtml_header |
pankso@50 | 293 cat << EOT |
pankso@50 | 294 <div id="wrapper"> |
al@303 | 295 <h2>$(gettext 'Boot & Start services')</h2> |
al@303 | 296 <p>$(gettext 'Everything that happens before user login')</p> |
pankso@50 | 297 </div> |
pankso@51 | 298 <div> |
pascal@130 | 299 <a class="button" href="$SCRIPT_NAME?log"> |
al@303 | 300 <img src="$IMAGES/text.png" />$(gettext 'Boot logs')</a> |
pascal@124 | 301 <a class="button" href="$SCRIPT_NAME?daemons"> |
al@303 | 302 <img src="$IMAGES/recharge.png" />$(gettext 'Manage daemons')</a> |
al@303 | 303 <a class="button" href="$SCRIPT_NAME?grub">$(gettext 'Boot loader')</a> |
pankso@51 | 304 </div> |
pankso@51 | 305 |
al@303 | 306 <h3>$(gettext 'Configuration files')</h3> |
pankso@57 | 307 <ul> |
al@303 | 308 <li>$(gettext 'Main configuration file:') |
pankso@57 | 309 <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li> |
al@303 | 310 <li>$(gettext 'Login manager settings:') |
pankso@57 | 311 <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li> |
pankso@73 | 312 </ul> |
pankso@57 | 313 |
al@303 | 314 <h3>$(gettext 'Kernel cmdline')</h3> |
al@303 | 315 |
al@303 | 316 <pre>$(cat /proc/cmdline)</pre> |
al@303 | 317 |
al@303 | 318 <h3>$(gettext 'Local startup commands')</h3> |
al@303 | 319 |
al@303 | 320 <pre>$(cat /etc/init.d/local.sh | syntax_highlighter sh)</pre> |
al@303 | 321 |
pankso@105 | 322 <a class="button" href="index.cgi?file=/etc/init.d/local.sh&action=edit"> |
al@303 | 323 <img src="$IMAGES/edit.png" />$(gettext 'Edit script')</a> |
pankso@50 | 324 EOT |
pankso@50 | 325 ;; |
pankso@50 | 326 esac |
pankso@50 | 327 |
pankso@50 | 328 xhtml_footer |
pankso@50 | 329 exit 0 |