tazpanel rev 108
network.cgi: randow fixes (start-stop wifi) and improvment
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Fri Apr 15 08:51:30 2011 +0200 (2011-04-15) |
parents | 306b0bf62bb8 |
children | b898c9887a62 |
files | network.cgi |
line diff
1.1 --- a/network.cgi Fri Apr 15 07:45:43 2011 +0200 1.2 +++ b/network.cgi Fri Apr 15 08:51:30 2011 +0200 1.3 @@ -5,7 +5,6 @@ 1.4 1.5 # Common functions from libtazpanel 1.6 . lib/libtazpanel 1.7 -. /etc/network.conf 1.8 get_config 1.9 header 1.10 1.11 @@ -53,15 +52,15 @@ 1.12 fi 1.13 # Connected or not connected... 1.14 if ifconfig | grep -A 1 $WIFI_INTERFACE | \ 1.15 - grep -q inet && iwconfig $WIFI_INTERFACE | \ 1.16 - grep ESSID | grep -q -w "$ESSID"; then 1.17 - STATUS=$(gettext "Connected") 1.18 + fgrep -q inet && iwconfig $WIFI_INTERFACE | \ 1.19 + grep ESSID | fgrep -q -w "$ESSID"; then 1.20 + status=$(gettext "Connected") 1.21 else 1.22 - STATUS="-" 1.23 + status="---" 1.24 fi 1.25 echo '<tr>' 1.26 echo "<td><img src='$IMAGES/wireless.png' />$ESSID</td>" 1.27 - echo "<td>$QUALITY</td><td>$ENCRYPTION</td><td>$STATUS</td>" 1.28 + echo "<td>$QUALITY</td><td>$ENCRYPTION</td><td>$status $ip</td>" 1.29 echo '</tr>' 1.30 done 1.31 fi 1.32 @@ -77,10 +76,20 @@ 1.33 sleep 2 ;; 1.34 *\ stop\ *) 1.35 /etc/init.d/network.sh stop | log ;; 1.36 - *) 1.37 - continue ;; 1.38 + *\ start-wifi\ *) 1.39 + sed -i \ 1.40 + -e s'/^DHCP=.*/DHCP="yes"/' \ 1.41 + -e s'/^WIFI=.*/WIFI="yes"/' \ 1.42 + -e s'/^STATIC=.*/STATIC="no"/'/etc/network.conf 1.43 + /etc/init.d/network.sh start | log 1.44 + sleep 2 ;; 1.45 + *\ hostname\ *) 1.46 + echo $(gettext "Changed hostname:") $(GET hostname) | log 1.47 + echo "$(GET hostname)" > /etc/hostname ;; 1.48 esac 1.49 1.50 +. /etc/network.conf 1.51 + 1.52 # 1.53 # Main Commands for pages 1.54 # 1.55 @@ -163,6 +172,10 @@ 1.56 cat << EOT 1.57 <h2>`gettext "Wireless connection`</h2> 1.58 <div id="actions"> 1.59 + <a class="button" href="$SCRIPT_NAME?wifi&start-wifi=start-wifi"> 1.60 + <img src="$IMAGES/start.png" />$(gettext "Start")</a> 1.61 + <a class="button" href="$SCRIPT_NAME?wifi&stop=stop"> 1.62 + <img src="$IMAGES/stop.png" />$(gettext "Stop")</a> 1.63 <a class="button" href="$SCRIPT_NAME?wifi=scan"> 1.64 <img src="$IMAGES/recharge.png" />$(gettext "Scan")</a> 1.65 </div> 1.66 @@ -189,6 +202,7 @@ 1.67 *) 1.68 # Main Network page starting with a summary 1.69 xhtml_header 1.70 + hostname=$(cat /etc/hostname) 1.71 cat << EOT 1.72 <h2>`gettext "Networking`</h2> 1.73 <p> 1.74 @@ -197,17 +211,35 @@ 1.75 <div id="actions"> 1.76 <div class="float-left"> 1.77 `gettext "Connection:"` 1.78 - <a class="button" href="$SCRIPT_NAME?start">`gettext "Start"`</a> 1.79 - <a class="button" href="$SCRIPT_NAME?stop">`gettext "Stop"`</a> 1.80 + <a class="button" href="$SCRIPT_NAME?start"> 1.81 + <img src="$IMAGES/start.png" />$(gettext "Start")</a> 1.82 + <a class="button" href="$SCRIPT_NAME?stop"> 1.83 + <img src="$IMAGES/stop.png" />$(gettext "Stop")</a> 1.84 </div> 1.85 <div class="float-right"> 1.86 - `gettext "Configuration file:"` 1.87 + `gettext "Configuration:"` 1.88 <a class="button" href="index.cgi?file=/etc/network.conf">network.conf</a> 1.89 + <a class="button" href="$SCRIPT_NAME?eth">Ethernet</a> 1.90 + <a class="button" href="$SCRIPT_NAME?wifi">Wireless</a> 1.91 </div> 1.92 </div> 1.93 1.94 $(list_network_interfaces) 1.95 1.96 +<h3>$(gettext "Hosts")</h3> 1.97 +<pre> 1.98 +$(cat /etc/hosts) 1.99 +</pre> 1.100 +<a class="button" href="index.cgi?file=/etc/hosts&action=edit"> 1.101 + <img src="$IMAGES/edit.png" />$(gettext "Edit hosts")</a> 1.102 + 1.103 +<h3>$(gettext "Hostname")</h3> 1.104 +<form method="get" name="$SCRIPT_NAME" 1.105 + <input type="text" name="hostname" value="$hostname" /> 1.106 + <input type="submit" value="$(gettext "Change hostname")" 1.107 +</form> 1.108 + 1.109 + 1.110 <h3>$(gettext "Output of ") ifconfig</h3> 1.111 <pre> 1.112 $(ifconfig)