tazpanel view boot.cgi @ rev 130

boot.cgi: show boot logs
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 16 13:22:34 2011 +0200 (2011-04-16)
parents 20b80d61e7c7
children 67fa759f1357
line source
1 #!/bin/sh
2 #
3 # Boot CGI script - All what happens before login (grub, rcS, slim)
4 #
5 # Copyright (C) 2011 SliTaz GNU/Linux - BSD License
6 #
8 # Common functions from libtazpanel and source main boot config file.
9 . lib/libtazpanel
10 . /etc/rcS.conf
11 header
12 get_config
14 TITLE="- Boot"
16 #
17 # Commands
18 #
20 case " $(GET) " in
21 *\ log\ *)
22 xhtml_header
24 cat << EOT
25 <div id="wrapper">
26 <h2>`gettext "Boot log files"`</h2>
27 </div>
28 <h3>`gettext "kernel messages"`</h3>
29 <pre>
30 $(cat /var/log/dmesg.log)
31 </pre>
32 <h3>`gettext "boot scripts"`</h3>
33 <pre>
34 $(sed 's/\[^Gm]*.//g' < /var/log/boot.log)
35 </pre>
36 EOT
37 ;;
38 *\ daemons\ *)
39 #
40 # Everything until user login
41 #
42 # Start and stop a daemon. I think we dont need restart since 2
43 # clicks and you are done
44 daemon=$(GET daemons)
45 case "$daemon" in
46 start=*)
47 sleep 1
48 /etc/init.d/${daemon#start=} start | log ;;
49 stop=*)
50 /etc/init.d/${daemon#stop=} stop | log ;;
51 esac
52 . /etc/rcS.conf
53 xhtml_header
55 cat << EOT
56 <div id="wrapper">
57 <h2>`gettext "Manage daemons"`</h2>
58 <p>
59 `gettext "Check, start and stop daemons on SliTaz"`
60 </p>
61 </div>
62 EOT
63 # Demon list
64 table_start
65 cat << EOT
66 <thead>
67 <tr>
68 <td>`gettext "Name"`</td>
69 <td>`gettext "Description"`</td>
70 <td>`gettext "Status"`</td>
71 <td>`gettext "Action"`</td>
72 <td>`gettext "PID"`</td>
73 </tr>
74 </thead>
75 EOT
76 cd /etc/init.d
77 list="`ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d \
78 -e /firewall/d`"
79 for name in $list
80 do
81 pkg=""
82 pid=""
83 status=""
84 SHORT_DESC=""
85 echo '<tr>'
86 # Name
87 echo "<td>$name</td>"
88 # First check if daemon is started at bootime
89 [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot"
90 # Standard SliTaz busybox daemons and firewall
91 case "$name" in
92 firewall)
93 gettext "<td>SliTaz Firewall with iptable rules</td>" ;;
94 httpd)
95 gettext "<td>Small and fast web server with CGI support</td>" ;;
96 ntpd)
97 gettext "<td>Network time protocol daemon</td>" ;;
98 ftpd)
99 gettext "<td>Anonymous FTP server</td>" ;;
100 udhcpd)
101 gettext "<td>Busybox DHCP server</td>" ;;
102 syslogd|klogd)
103 gettext "<td>Linux Kernel log daemon</td>" ;;
104 crond)
105 gettext "<td>Execute scheduled commands</td>" ;;
106 dnsd)
107 gettext "<td>Small static DNS server daemon</td>" ;;
108 tftpd)
109 gettext "<td>Transfer a file on tftp request</td>" ;;
110 inetd)
111 gettext "<td>Listen for network connections and launch programs</td>" ;;
112 zcip)
113 gettext "<td>Manage a ZeroConf IPv4 link-local address</td>" ;;
114 *)
115 # Descrition from receipt
116 [ -d "$LOCALSTATE/installed/$name" ] && pkg=$name
117 [ -d "$LOCALSTATE/installed/${name%d}" ] && pkg=${name%d}
118 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam
119 if [ "$pkg" ]; then
120 . $LOCALSTATE/installed/$pkg/receipt
121 echo "<td>$SHORT_DESC</td>"
122 else
123 echo "<td>----</td>"
124 fi ;;
125 esac
126 # Attemp to get daemon status
127 pidfile=`find /var/run -name *$name*.pid`
128 [ "$pidfile" ] && pid=`cat $pidfile`
129 # dbus
130 [ -f /var/run/${name}/pid ] && pid=`cat /var/run/${name}/pid`
131 # apache
132 [ "$name" = "apache" ] && pid=`cat /var/run/$name/httpd.pid`
133 # Pidof works for many daemon
134 [ "$pid" ] || pid=`pidof $name`
135 if [ "$pid" ]; then
136 echo "<td><img src='$IMAGES/started.png' /></td>"
137 echo "<td><a href='$SCRIPT_NAME?daemons=stop=$name'>
138 <img src='$IMAGES/stop.png' /></a></td>"
139 echo "<td>$pid</td>"
140 else
141 echo "<td>-</td>"
142 echo "<td><a href='$SCRIPT_NAME?daemons=start=$name'>
143 <img src='$IMAGES/start.png' /></a></td>"
144 echo "<td>-----</td>"
145 fi
146 echo '</tr>'
147 done
148 table_end ;;
149 *)
150 #
151 # Default content with summary
152 #
153 . /etc/rcS.conf
154 xhtml_header
156 cat << EOT
157 <div id="wrapper">
158 <h2>`gettext "Boot &amp; Start services"`</h2>
159 <p>
160 `gettext "Everything that happens before user login"`
161 </p>
162 </div>
163 <div>
164 <a class="button" href="$SCRIPT_NAME?log">
165 <img src="$IMAGES/edit.png" />`gettext "Boot logs"`</a>
166 <a class="button" href="$SCRIPT_NAME?daemons">
167 <img src="$IMAGES/recharge.png" />`gettext "Manage daemons"`</a>
168 </div>
170 <h3>`gettext "Configuration files"`</h3>
171 <ul>
172 <li>`gettext "Main configuration file:"`
173 <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li>
174 <li>`gettext "Grub menu:"`
175 <a href="index.cgi?file=/boot/grub/menu.lst">menu.lst</a></li>
176 <li>`gettext "Login manager settings:"`
177 <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li>
178 </ul>
180 <h3>`gettext "Kernel cmdline"`</h3>
181 <pre>
182 `cat /proc/cmdline`
183 </pre>
184 <h3>`gettext "Local startup commands"`</h3>
185 <pre>
186 $(cat /etc/init.d/local.sh | syntax_highlighter sh)
187 </pre>
188 <a class="button" href="index.cgi?file=/etc/init.d/local.sh&amp;action=edit">
189 <img src="$IMAGES/edit.png" />$(gettext "Edit script")</a>
190 EOT
191 ;;
192 esac
194 xhtml_footer
195 exit 0