tazpanel diff 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 diff
     1.1 --- a/lib/libtazpanel	Tue Apr 05 05:51:38 2011 +0200
     1.2 +++ b/lib/libtazpanel	Wed Apr 06 06:17:23 2011 +0200
     1.3 @@ -3,6 +3,13 @@
     1.4  # Common functions for TazPanel CGI and cmdline interface
     1.5  #
     1.6  
     1.7 +# Include gettext helper script.
     1.8 +. /usr/bin/gettext.sh
     1.9 +
    1.10 +# Export package name for gettext.
    1.11 +TEXTDOMAIN='tazpanel'
    1.12 +export TEXTDOMAIN
    1.13 +
    1.14  # We need a config file first
    1.15  get_config() {
    1.16  	CONFIG="/etc/slitaz/tazpanel.conf"
    1.17 @@ -13,6 +20,47 @@
    1.18  		exit 1
    1.19  }
    1.20  
    1.21 +# Network interface status
    1.22 +interface_status() {
    1.23 +	if 	ifconfig | grep -A 1 $i | grep -q inet; then
    1.24 +		ip=`ifconfig | grep -A 1 $i | grep inet | \
    1.25 +			awk '{ print $2 }' | cut -d ":" -f 2`
    1.26 +		echo "<td>connected</td><td>$ip</td>"
    1.27 +	else
    1.28 +		echo "<td>----</td><td>----</td>"
    1.29 +	fi
    1.30 +}
    1.31 +
    1.32 +# Catch network interface (used in summary and network main page)
    1.33 +list_network_interfaces() {
    1.34 +	table_start
    1.35 +	cat << EOT
    1.36 +<tr id="thead">
    1.37 +	<td>`gettext "Interface"`</td>
    1.38 +	<td>`gettext "Name"`</td>
    1.39 +	<td>`gettext "Status"`</td>
    1.40 +	<td>`gettext "IP Address"`</td>
    1.41 +</tr>
    1.42 +EOT
    1.43 +	for i in `ls /sys/class/net`
    1.44 +	do
    1.45 +		case $i in
    1.46 +			eth*)
    1.47 +				echo "<tr><td><img src='$IMAGES/ethernet.png' />$i</td>
    1.48 +					<td>Ethernet</td> `interface_status`</tr>" ;;
    1.49 +			wlan*|ath*|ra*)
    1.50 +				echo "<tr><td><img src='$IMAGES/wireless.png' />$i</td>
    1.51 +					<td>Wireless</td> `interface_status`</tr>" ;;
    1.52 +			lo)
    1.53 +				echo "<tr><td><img src='$IMAGES/loopback.png' />$i</td>
    1.54 +				<td>Loopback</td> `interface_status`</tr>" ;;
    1.55 +			*)
    1.56 +				continue ;;
    1.57 +		esac
    1.58 +	done
    1.59 +	table_end
    1.60 +}
    1.61 +
    1.62  #
    1.63  # xHTML 5 (header and footer skel are from the style)
    1.64  #