tazpanel view boot.cgi @ rev 141

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