tazpanel view boot.cgi @ rev 56

Add a file view CASE so we can displa any file on the system (ex at boot.cgi with rcS.conf)
author Christophe Lincoln <pankso@slitaz.org>
date Sun Apr 10 20:20:19 2011 +0200 (2011-04-10)
parents 730f8bcacabc
children b542e1db674c
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>
152 Main configuration file: <a href="index.cgi?file=/etc/rcS.conf">rcS.conf</a>
153 </div>
155 <h3>`gettext "Kernel cmdline"`</h3>
156 <pre>
157 `cat /proc/cmdline`
158 </pre>
159 <h3>`gettext "Local startup commands"`</h3>
160 <pre>
161 `cat /etc/init.d/local.sh`
162 </pre>
163 EOT
164 ;;
165 esac
167 xhtml_footer
168 exit 0