tazpanel view boot.cgi @ rev 57

boot.cgi add more link to config file og grub and slim
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 10 20:28:21 2011 +0200 (2011-04-10)
parents 769f91a0718d
children 8f60cbb66259
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
47 debug_info
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|dnsd|tftpd|inetd|zcip)
98 gettext "<td>Daemon powered by BusyBox</td>" ;;
99 *)
100 # Descrition from receipt
101 [ -d "$LOCALSTATE/installed/$name" ] && pkg=$name
102 [ -d "$LOCALSTATE/installed/${name%d}" ] && pkg=${name%d}
103 [ -d "$LOCALSTATE/installed/${name}-pam" ] && pkg=${name}-pam
104 if [ "$pkg" ]; then
105 . $LOCALSTATE/installed/$pkg/receipt
106 echo "<td>$SHORT_DESC</td>"
107 else
108 echo "<td>----</td>"
109 fi ;;
110 esac
111 # Attemp to get daemon status
112 pidfile=`find /var/run -name *$name*.pid`
113 [ "$pidfile" ] && pid=`cat $pidfile`
114 # dbus
115 [ -f /var/run/${name}/pid ] && pid=`cat /var/run/${name}/pid`
116 # apache
117 [ "$name" = "apache" ] && pid=`cat /var/run/$name/httpd.pid`
118 # Pidof works for many daemon
119 [ "$pid" ] || pid=`pidof $name`
120 if [ "$pid" ]; then
121 echo "<td><img src='$IMAGES/started.png' /></td>"
122 echo "<td><a href='$SCRIPT_NAME?daemons=stop=$name'>
123 <img src='$IMAGES/stop.png' /></a></td>"
124 echo "<td>$pid</td>"
125 else
126 echo "<td>-</td>"
127 echo "<td><a href='$SCRIPT_NAME?daemons=start=$name'>
128 <img src='$IMAGES/start.png' /></a></td>"
129 echo "<td>-----</td>"
130 fi
131 echo '</tr>'
132 done
133 table_end ;;
134 *)
135 #
136 # Default content with summary
137 #
138 . /etc/rcS.conf
139 TITLE="- Boot"
140 xhtml_header
141 debug_info
142 cat << EOT
143 <div id="wrapper">
144 <h2>`gettext "Boot &amp; Start services"`</h2>
145 <p>
146 `gettext "Everything that appends before user login."`
147 </p>
148 </div>
150 <div>
151 <a class="button" href="$SCRIPT_NAME?daemons">Manage daemons</a>
154 </div>
156 <h3>`gettext "Configuration files"`</h3>
157 <ul>
158 <li>`gettext "Main configuration file:"`
159 <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a></li>
160 <li>`gettext "Grub menu:"`
161 <a href="index.cgi?file=/boot/grub/menu.lst">menu.lst</a></li>
162 <li>`gettext "Login manager settings:"`
163 <a href="index.cgi?file=/etc/slim.conf">slim.conf</a></li>
164 <ul>
166 <h3>`gettext "Kernel cmdline"`</h3>
167 <pre>
168 `cat /proc/cmdline`
169 </pre>
170 <h3>`gettext "Local startup commands"`</h3>
171 <pre>
172 `cat /etc/init.d/local.sh`
173 </pre>
174 EOT
175 ;;
176 esac
178 xhtml_footer
179 exit 0