slitaz-tools rev 33
Add : 'netbox' a GTK+ interface for network wired configuration
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jan 13 18:06:32 2008 +0100 (2008-01-13) |
parents | d9ce64aa6d2e |
children | 6766819798c7 |
files | tinyutils/netbox |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tinyutils/netbox Sun Jan 13 18:06:32 2008 +0100 1.3 @@ -0,0 +1,251 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# Gtkdialog box to manage network connexion. 1.7 +# - SliTaz GNU/Linux 2008. 1.8 +# 1.9 +VERSION=20080113 1.10 + 1.11 +# Check if user is root. 1.12 +check_root() 1.13 +{ 1.14 + if test $(id -u) != 0 ; then 1.15 + echo -e " 1.16 +You must be root to run `basename $0`. Please type 'su' and 1.17 +root password to become super-user.\n" 1.18 + exit 0 1.19 + fi 1.20 +} 1.21 + 1.22 +# Interafce status with ifconfig without arguments to show all 1.23 +# active connections. 1.24 +# 1.25 +export IFCONFIG=' 1.26 + <vbox> 1.27 + <text use-markup="true"> 1.28 + <label>" 1.29 +<b>Active network interfaces</b>" 1.30 + </label> 1.31 + </text> 1.32 + <text wrap="false"> 1.33 + <input>date</input> 1.34 + </text> 1.35 + <frame Ifconfig> 1.36 + <text wrap="false" width-chars="58"> 1.37 + <input>ifconfig</input> 1.38 + </text> 1.39 + </frame> 1.40 + <hbox> 1.41 + <button> 1.42 + <input file icon="exit"></input> 1.43 + <action type="closewindow">IFCONFIG</action> 1.44 + </button> 1.45 + </hbox> 1.46 + </vbox> 1.47 +' 1.48 + 1.49 +# The main dialog with notebook and all options. 1.50 +# 1.51 +export NET_BOX=' 1.52 + <vbox> 1.53 + <text use-markup="true"> 1.54 + <label>" 1.55 +<b>SliTaz - Netbox</b>" 1.56 + </label> 1.57 + </text> 1.58 + <text wrap="true" width-chars="44"> 1.59 + <label> 1.60 +" 1.61 +Manage network connections getting dynamic IP by 1.62 +DHCP or static IP. Netbox can start or stop networking, 1.63 +configure network interfaces or directly edit files. 1.64 +" 1.65 + </label> 1.66 + </text> 1.67 + 1.68 + <frame General> 1.69 + <hbox> 1.70 + <text use-markup="true"> 1.71 + <label>"<b>Interface : </b>"</label> 1.72 + </text> 1.73 + <entry> 1.74 + <input>. /etc/network.conf; echo $INTERFACE</input> 1.75 + <variable>INTERFACE</variable> 1.76 + </entry> 1.77 + </hbox> 1.78 + </frame> 1.79 + 1.80 + <notebook labels="DHCP|Static IP|System wide"> 1.81 + 1.82 + <frame Udhcpc> 1.83 + <hbox> 1.84 + <text wrap="true"> 1.85 + <label> 1.86 +"The -b options make DHCP client run in background 1.87 +if lease cannot be immediatly negociated." 1.88 + </label> 1.89 + </text> 1.90 + </hbox> 1.91 + <hbox> 1.92 + <text use-markup="true"> 1.93 + <label>"<b>Options : </b>"</label> 1.94 + </text> 1.95 + <entry> 1.96 + <default>-b</default> 1.97 + <variable>UDHCPC_OPTS</variable> 1.98 + </entry> 1.99 + </hbox> 1.100 + <hbox> 1.101 + <button> 1.102 + <label>Start</label> 1.103 + <input file icon="forward"></input> 1.104 + <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action> 1.105 + <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action> 1.106 + <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action> 1.107 + <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action> 1.108 + </button> 1.109 + <button> 1.110 + <label>Stop</label> 1.111 + <input file icon="stop"></input> 1.112 + <action>echo -n "Stopping interface : $INTERFACE... "</action> 1.113 + <action>ifconfig $INTERFACE down</action> 1.114 + <action>killall -q udhcpc; echo "done"</action> 1.115 + </button> 1.116 + </hbox> 1.117 + </frame> 1.118 + 1.119 + <frame Configuration> 1.120 + <hbox> 1.121 + <text use-markup="true"> 1.122 + <label>"<b>IP : </b>"</label> 1.123 + </text> 1.124 + <entry> 1.125 + <input>. /etc/network.conf; echo "$IP"</input> 1.126 + <variable>IP</variable> 1.127 + </entry> 1.128 + </hbox> 1.129 + <hbox> 1.130 + <text use-markup="true"> 1.131 + <label>"<b>Netmask : </b>"</label> 1.132 + </text> 1.133 + <entry> 1.134 + <input>. /etc/network.conf; echo "$NETMASK"</input> 1.135 + <variable>NETMASK</variable> 1.136 + </entry> 1.137 + </hbox> 1.138 + <hbox> 1.139 + <text use-markup="true"> 1.140 + <label>"<b>Gateway : </b>"</label> 1.141 + </text> 1.142 + <entry> 1.143 + <input>. /etc/network.conf; echo "$GATEWAY"</input> 1.144 + <variable>GATEWAY</variable> 1.145 + </entry> 1.146 + </hbox> 1.147 + <hbox> 1.148 + <text use-markup="true"> 1.149 + <label>"<b>DNS server : </b>"</label> 1.150 + </text> 1.151 + <entry> 1.152 + <input>. /etc/network.conf; echo "$DNS_SERVER"</input> 1.153 + <variable>DNS_SERVER</variable> 1.154 + </entry> 1.155 + </hbox> 1.156 + <hbox> 1.157 + <button> 1.158 + <label>Start</label> 1.159 + <input file icon="forward"></input> 1.160 + <action>ifconfig lo down</action> 1.161 + <action>ifconfig $INTERFACE down</action> 1.162 + <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action> 1.163 + <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action> 1.164 + <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action> 1.165 + <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action> 1.166 + <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action> 1.167 + <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action> 1.168 + <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action> 1.169 + <action>/etc/init.d/network.sh</action> 1.170 + </button> 1.171 + <button> 1.172 + <label>Stop</label> 1.173 + <input file icon="stop"></input> 1.174 + <action>echo -n "Stopping interface : $INTERFACE... "</action> 1.175 + <action>ifconfig $INTERFACE down; echo "done"</action> 1.176 + </button> 1.177 + </hbox> 1.178 + </frame> 1.179 + 1.180 + <frame Configuration files> 1.181 + <hbox> 1.182 + <text use-markup="true"> 1.183 + <label>"<b>Hosts : </b>"</label> 1.184 + </text> 1.185 + <entry editable="false"> 1.186 + <default>/etc/hosts</default> 1.187 + <variable>HOSTS</variable> 1.188 + </entry> 1.189 + <button> 1.190 + <input file icon="accessories-text-editor"></input> 1.191 + <action type="lauch">leafpad $HOSTS</action> 1.192 + </button> 1.193 + </hbox> 1.194 + <hbox> 1.195 + <text use-markup="true"> 1.196 + <label>"<b>Host name : </b>"</label> 1.197 + </text> 1.198 + <entry editable="false"> 1.199 + <default>/etc/hostname</default> 1.200 + <variable>HOSTNAME</variable> 1.201 + </entry> 1.202 + <button> 1.203 + <input file icon="accessories-text-editor"></input> 1.204 + <action type="lauch">leafpad $HOSTNAME</action> 1.205 + </button> 1.206 + </hbox> 1.207 + <hbox> 1.208 + <text use-markup="true"> 1.209 + <label>"<b>Network : </b>"</label> 1.210 + </text> 1.211 + <entry editable="false"> 1.212 + <default>/etc/network.conf</default> 1.213 + <variable>CONFIG_FILE</variable> 1.214 + </entry> 1.215 + <button> 1.216 + <input file icon="accessories-text-editor"></input> 1.217 + <action type="lauch">leafpad $CONFIG_FILE</action> 1.218 + </button> 1.219 + </hbox> 1.220 + <hbox> 1.221 + <button> 1.222 + <label>Restart</label> 1.223 + <input file icon="reload"></input> 1.224 + <action>echo -n "Stopping interface : $INTERFACE... "</action> 1.225 + <action>ifconfig lo down</action> 1.226 + <action>ifconfig $INTERFACE down</action> 1.227 + <action>killall -q udhcpc; echo "done"</action> 1.228 + <action>/etc/init.d/network.sh</action> 1.229 + </button> 1.230 + </hbox> 1.231 + </frame> 1.232 + 1.233 + </notebook> 1.234 + 1.235 + <hbox> 1.236 + <button> 1.237 + <label>Status</label> 1.238 + <input file icon="network-wired"></input> 1.239 + <action type="launch">IFCONFIG</action> 1.240 + </button> 1.241 + <button> 1.242 + <input file icon="exit"></input> 1.243 + <action type="exit">Exit</action> 1.244 + </button> 1.245 + </hbox> 1.246 + 1.247 + </vbox> 1.248 +' 1.249 + 1.250 +# Only root can configure network. 1.251 +check_root 1.252 +gtkdialog --program=NET_BOX 1.253 + 1.254 +exit 0