tazpanel view boot.cgi @ rev 76

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