tazpanel view boot.cgi @ rev 165
libtazpanel: align status
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Apr 22 11:34:07 2011 +0200 (2011-04-22) |
parents | e4381f2e73f6 |
children | e0d1571d49ba |
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
23 cat << EOT
24 <div id="wrapper">
25 <h2>`gettext "Boot log files"`</h2>
26 </div>
27 <div>
28 <a class="button" href="#kernel">
29 <img src="$IMAGES/tux.png" />$(gettext "Kernel messages")</a>
30 <a class="button" href="#boot">$(gettext "Boot scripts")</a>
31 <a class="button" href="#slim">$(gettext "X server")</a>
32 </div>
33 <a name="kernel"></a>
34 <h3>$(gettext "Kernel messages")</h3>
35 <pre>
36 $(cat /var/log/dmesg.log)
37 </pre>
38 <a name="boot"></a>
39 <h3>$(gettext "Boot scripts")</h3>
40 <pre>
41 $(cat /var/log/boot.log | filter_taztools_msgs)
42 </pre>
43 <a name="slim"></a>
44 <h3>$(gettext "X server")</h3>
45 <pre>
46 $(tail -n 40 /var/log/slim.log)
47 </pre>
48 EOT
49 ;;
50 *\ daemons\ *)
51 #
52 # Everything until user login
53 #
54 # Start and stop a daemon. I think we dont need restart since 2
55 # clicks and you are done
56 . /etc/rcS.conf
57 xhtml_header
59 cat << EOT
60 <div id="wrapper">
61 <h2>`gettext "Manage daemons"`</h2>
62 <p>
63 `gettext "Check, start and stop daemons on SliTaz"`
64 </p>
65 </div>
66 EOT
67 daemon=$(GET daemons)
68 case "$daemon" in
69 start=*)
70 sleep 1
71 /etc/init.d/${daemon#start=} start | log ;;
72 stop=*)
73 /etc/init.d/${daemon#stop=} stop | log ;;
74 pid=*)
75 echo "<pre>"
76 ps ww | sed "1p;/^ *${daemon#pid=} /!d"
77 echo "</pre>" ;;
78 esac
79 # Demon list
80 table_start
81 cat << EOT
82 <thead>
83 <tr>
84 <td>`gettext "Name"`</td>
85 <td>`gettext "Description"`</td>
86 <td>`gettext "Status"`</td>
87 <td>`gettext "Action"`</td>
88 <td>`gettext "PID"`</td>
89 </tr>
90 </thead>
91 EOT
92 cd /etc/init.d
93 list="`ls | sed -e /.sh/d -e /rc./d -e /RE/d -e /daemon/d \
94 -e /firewall/d`"
95 for name in $list
96 do
97 pkg=""
98 pid=""
99 status=""
100 SHORT_DESC=""
101 echo '<tr>'
102 # Name
103 echo "<td>$name</td>"
104 # First check if daemon is started at bootime
105 [ echo "RUN_DAEMONS" | fgrep $name ] && boot="on boot"
106 # Standard SliTaz busybox daemons and firewall
107 case "$name" in
108 firewall)
109 gettext "<td>SliTaz Firewall with iptable rules</td>" ;;
110 httpd)
111 gettext "<td>Small and fast web server with CGI support</td>" ;;
112 ntpd)
113 gettext "<td>Network time protocol daemon</td>" ;;
114 ftpd)
115 gettext "<td>Anonymous FTP server</td>" ;;
116 udhcpd)
117 gettext "<td>Busybox DHCP server</td>" ;;
118 syslogd|klogd)
119 gettext "<td>Linux Kernel log daemon</td>" ;;
120 crond)
121 gettext "<td>Execute scheduled commands</td>" ;;
122 dnsd)
123 gettext "<td>Small static DNS server daemon</td>" ;;
124 tftpd)
125 gettext "<td>Transfer a file on tftp request</td>" ;;
126 inetd)
127 gettext "<td>Listen for network connections and launch programs</td>" ;;
128 zcip)
129 gettext "<td>Manage a ZeroConf IPv4 link-local address</td>" ;;
130 *)
131 # Descrition from receipt
132 [ -d "$LOCALSTATE/installed/$name" ] && pkg=$name
133 [ -d "$LOCALSTATE/installed/${name%d}" ] && pkg=${name%d}
134 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam
135 if [ "$pkg" ]; then
136 . $LOCALSTATE/installed/$pkg/receipt
137 echo "<td>$SHORT_DESC</td>"
138 else
139 echo "<td>----</td>"
140 fi ;;
141 esac
142 # Attemp to get daemon status
143 pidfile=`find /var/run -name *$name*.pid`
144 [ "$pidfile" ] && pid=`cat $pidfile`
145 # dbus
146 [ -f /var/run/${name}/pid ] && pid=`cat /var/run/${name}/pid`
147 # apache
148 [ "$name" = "apache" ] && pid=`cat /var/run/$name/httpd.pid`
149 # Pidof works for many daemon
150 [ "$pid" ] || pid=`pidof $name`
151 if [ "$pid" ]; then
152 cat << EOT
153 <td><img src="$IMAGES/started.png" /></td>
154 <td><a href="$SCRIPT_NAME?daemons=stop=$name">
155 <img src="$IMAGES/stop.png" /></a></td>
156 <td>
157 EOT
158 for i in $pid; do
159 cat << EOT
160 <a href="$SCRIPT_NAME?daemons=pid=$i">$i</a>
161 EOT
162 done
163 else
164 cat << EOT
165 <td>-</td>
166 <td><a href="$SCRIPT_NAME?daemons=start=$name">
167 <img src="$IMAGES/start.png" /></a></td>
168 <td>-----
169 EOT
170 fi
171 echo '</td></tr>'
172 done
173 table_end ;;
174 *\ grub\ *)
175 if [ "$(GET splash)" ]; then
176 default=$(GET default)
177 timeout=$(GET timeout)
178 splash=$(GET splash)
179 sed -i \
180 -e s"/default .*/default $default/" \
181 -e s"/timeout .*/timeout $timeout/" \
182 -e s"#splashimage=.*#splashimage=$splash#" \
183 /boot/grub/menu.lst
184 fi
185 default=$(cat /boot/grub/menu.lst | grep ^default | cut -d " " -f 2)
186 timeout=$(cat /boot/grub/menu.lst | grep ^timeout | cut -d " " -f 2)
187 splash=$(cat /boot/grub/menu.lst | grep ^splashimage | cut -d "=" -f 2)
188 xhtml_header
189 cat << EOT
190 <div id="wrapper">
191 <h2>$(gettext "GRUB Boot loader")</h2>
192 <p>
193 $(gettext "The first application started when the computer powers on")
194 </p>
195 </div>
197 <form method="get" action="$SCRIPT_NAME">
198 <input type="hidden" name="grub" />
199 <pre>
200 Default entry : <input type="text" name="default" value="$default" />
202 Timeout : <input type="text" name="timeout" value="$timeout" />
204 Splash image : <input type="text" name="splash" value="$splash" size="40" />
205 </pre>
206 <input type="submit" value="$(gettext "Change")" />
207 <a class="button" href="index.cgi?file=/boot/grub/menu.lst">
208 <img src="$IMAGES/text.png" />View or edit menu.lst</a>
209 </form>
211 <h3>$(gettext "Boot entries")</h3>
212 EOT
213 entry='-1'
214 grep ^title /boot/grub/menu.lst | while read title
215 do
216 entry=$(($entry + 1))
217 echo "<strong>$(gettext "Entry") $entry</strong>"
218 echo '<pre>'
219 grep -A 2 "$title" /boot/grub/menu.lst
220 echo '</pre>'
221 done
222 # Here we could check if an entry for gpxe is present if not
223 # display a form to add it.
224 [ -f "/boot/gpxe" ] && echo "<h3>gPXE</h3>" && \
225 gettext "Web boot is avalaible with gPXE"
226 ;;
227 *)
228 #
229 # Default content with summary
230 #
231 . /etc/rcS.conf
232 xhtml_header
233 cat << EOT
234 <div id="wrapper">
235 <h2>$(gettext "Boot & Start services")</h2>
236 <p>
237 $(gettext "Everything that happens before user login")
238 </p>
239 </div>
240 <div>
241 <a class="button" href="$SCRIPT_NAME?log">
242 <img src="$IMAGES/text.png" />$(gettext "Boot logs")</a>
243 <a class="button" href="$SCRIPT_NAME?daemons">
244 <img src="$IMAGES/recharge.png" />$(gettext "Manage daemons")</a>
245 <a class="button" href="$SCRIPT_NAME?grub">$(gettext "Boot loader")</a>
246 </div>
248 <h3>`gettext "Configuration files"`</h3>
249 <ul>
250 <li>`gettext "Main configuration file:"`
251 <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li>
252 <li>`gettext "Login manager settings:"`
253 <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li>
254 </ul>
256 <h3>`gettext "Kernel cmdline"`</h3>
257 <pre>
258 `cat /proc/cmdline`
259 </pre>
260 <h3>`gettext "Local startup commands"`</h3>
261 <pre>
262 $(cat /etc/init.d/local.sh | syntax_highlighter sh)
263 </pre>
264 <a class="button" href="index.cgi?file=/etc/init.d/local.sh&action=edit">
265 <img src="$IMAGES/edit.png" />$(gettext "Edit script")</a>
266 EOT
267 ;;
268 esac
270 xhtml_footer
271 exit 0