tazpanel view lib/libtazpanel @ rev 40

Move network shared function (used by summary) to libtazpanel and include libtazpanel in POT file
author Christophe Lincoln <pankso@slitaz.org>
date Wed Apr 06 06:17:23 2011 +0200 (2011-04-06)
parents b4e001e85045
children 167a97495e1c
line source
1 #!/bin/sh
2 #
3 # Common functions for TazPanel CGI and cmdline interface
4 #
6 # Include gettext helper script.
7 . /usr/bin/gettext.sh
9 # Export package name for gettext.
10 TEXTDOMAIN='tazpanel'
11 export TEXTDOMAIN
13 # We need a config file first
14 get_config() {
15 CONFIG="/etc/slitaz/tazpanel.conf"
16 [ -f $CONFIG ] && . $CONFIG
17 [ -f tazpanel.conf ] && . tazpanel.conf
18 [ ! -f $PANEL/lib/libtazpanel ] && \
19 echo "No config file or libtazpanel found: $CONFIG" && \
20 exit 1
21 }
23 # Network interface status
24 interface_status() {
25 if ifconfig | grep -A 1 $i | grep -q inet; then
26 ip=`ifconfig | grep -A 1 $i | grep inet | \
27 awk '{ print $2 }' | cut -d ":" -f 2`
28 echo "<td>connected</td><td>$ip</td>"
29 else
30 echo "<td>----</td><td>----</td>"
31 fi
32 }
34 # Catch network interface (used in summary and network main page)
35 list_network_interfaces() {
36 table_start
37 cat << EOT
38 <tr id="thead">
39 <td>`gettext "Interface"`</td>
40 <td>`gettext "Name"`</td>
41 <td>`gettext "Status"`</td>
42 <td>`gettext "IP Address"`</td>
43 </tr>
44 EOT
45 for i in `ls /sys/class/net`
46 do
47 case $i in
48 eth*)
49 echo "<tr><td><img src='$IMAGES/ethernet.png' />$i</td>
50 <td>Ethernet</td> `interface_status`</tr>" ;;
51 wlan*|ath*|ra*)
52 echo "<tr><td><img src='$IMAGES/wireless.png' />$i</td>
53 <td>Wireless</td> `interface_status`</tr>" ;;
54 lo)
55 echo "<tr><td><img src='$IMAGES/loopback.png' />$i</td>
56 <td>Loopback</td> `interface_status`</tr>" ;;
57 *)
58 continue ;;
59 esac
60 done
61 table_end
62 }
64 #
65 # xHTML 5 (header and footer skel are from the style)
66 #
68 xhtml_header() {
69 cat ${PANEL}$HEADER | sed s/'- %TITLE%'/"$TITLE"/
70 }
72 xhtml_footer() {
73 cat ${PANEL}$FOOTER
74 }
76 table_start() {
77 cat << EOT
78 <table>
79 <tbody>
80 EOT
81 }
83 table_end () {
84 cat << EOT
85 </tbody>
86 </table>
87 EOT
88 }