tazpanel view boot.cgi @ rev 110

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