tazpanel view boot.cgi @ rev 82

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