slitaz-tools view tinyutils/netbox @ rev 97

soundconf give less msg and remoce sleep 1 + box goes in the center
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 10 20:42:46 2008 +0100 (2008-03-10)
parents adb072794713
children c6a8b708b12d
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box to manage network connexion.
4 # - SliTaz GNU/Linux 2008.
5 #
6 VERSION=20080113
8 # Check if user is root.
9 check_root()
10 {
11 if test $(id -u) != 0 ; then
12 echo -e "
13 You must be root to run `basename $0`. Please type 'su' and
14 root password to become super-user.\n"
15 exit 0
16 fi
17 }
19 # Interafce status with ifconfig without arguments to show all
20 # active connections.
21 #
22 export IFCONFIG='
23 <window title="Ifconfig" icon-name="network-wired">
24 <vbox>
25 <text use-markup="true">
26 <label>"
27 <b>Active network interfaces</b>"
28 </label>
29 </text>
30 <text wrap="false">
31 <input>date</input>
32 </text>
33 <frame Ifconfig>
34 <text wrap="false" width-chars="58">
35 <input>ifconfig</input>
36 </text>
37 </frame>
38 <hbox>
39 <button>
40 <input file icon="exit"></input>
41 <action type="closewindow">IFCONFIG</action>
42 </button>
43 </hbox>
44 </vbox>
45 </window>
46 '
48 # The main dialog with notebook, start/stop buttons and all options.
49 # Note than /etc/network.conf is seded wehwn an interafce is activate
50 #
51 export NET_BOX='
52 <window title="Netbox" icon-name="network-wired">
53 <vbox>
54 <text use-markup="true">
55 <label>
56 "
57 <b>SliTaz - Netbox</b>"
58 </label>
59 </text>
60 <text wrap="true" width-chars="44">
61 <label>
62 "
63 Manage network connections getting dynamic IP by
64 DHCP or static IP. Netbox can start or stop networking,
65 configure network interfaces or directly edit files.
66 "
67 </label>
68 </text>
70 <frame General>
71 <hbox>
72 <text use-markup="true">
73 <label>"<b>Interface :</b>"</label>
74 </text>
75 <entry>
76 <input>. /etc/network.conf; echo $INTERFACE</input>
77 <variable>INTERFACE</variable>
78 </entry>
79 </hbox>
80 </frame>
82 <notebook labels="DHCP|Static IP|System wide">
84 <frame Udhcpc>
85 <hbox>
86 <text wrap="true">
87 <label>
88 "The -b options make DHCP client run in background
89 if lease cannot be immediatly negociated."
90 </label>
91 </text>
92 </hbox>
93 <hbox>
94 <text use-markup="true">
95 <label>"<b>Options :</b>"</label>
96 </text>
97 <entry>
98 <default>-b</default>
99 <variable>UDHCPC_OPTS</variable>
100 </entry>
101 </hbox>
102 <hbox>
103 <button>
104 <label>Start</label>
105 <input file icon="forward"></input>
106 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
107 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
108 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
109 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
110 </button>
111 <button>
112 <label>Stop</label>
113 <input file icon="stop"></input>
114 <action>echo -n "Stopping interface : $INTERFACE... "</action>
115 <action>ifconfig $INTERFACE down</action>
116 <action>killall -q udhcpc; echo "done"</action>
117 </button>
118 </hbox>
119 </frame>
121 <frame Configuration>
122 <hbox>
123 <text use-markup="true">
124 <label>"<b>IP :</b>"</label>
125 </text>
126 <entry>
127 <input>. /etc/network.conf; echo "$IP"</input>
128 <variable>IP</variable>
129 </entry>
130 </hbox>
131 <hbox>
132 <text use-markup="true">
133 <label>"<b>Netmask :</b>"</label>
134 </text>
135 <entry>
136 <input>. /etc/network.conf; echo "$NETMASK"</input>
137 <variable>NETMASK</variable>
138 </entry>
139 </hbox>
140 <hbox>
141 <text use-markup="true">
142 <label>"<b>Gateway :</b>"</label>
143 </text>
144 <entry>
145 <input>. /etc/network.conf; echo "$GATEWAY"</input>
146 <variable>GATEWAY</variable>
147 </entry>
148 </hbox>
149 <hbox>
150 <text use-markup="true">
151 <label>"<b>DNS server :</b>"</label>
152 </text>
153 <entry>
154 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
155 <variable>DNS_SERVER</variable>
156 </entry>
157 </hbox>
158 <hbox>
159 <button>
160 <label>Start</label>
161 <input file icon="forward"></input>
162 <action>ifconfig lo down</action>
163 <action>ifconfig $INTERFACE down</action>
164 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
165 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
166 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
167 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
168 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
169 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
170 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
171 <action>/etc/init.d/network.sh</action>
172 </button>
173 <button>
174 <label>Stop</label>
175 <input file icon="stop"></input>
176 <action>echo -n "Stopping interface : $INTERFACE... "</action>
177 <action>ifconfig $INTERFACE down; echo "done"</action>
178 </button>
179 </hbox>
180 </frame>
182 <frame Configuration files>
183 <hbox>
184 <text use-markup="true">
185 <label>"<b>Hosts :</b>"</label>
186 </text>
187 <entry editable="false">
188 <default>/etc/hosts</default>
189 <variable>HOSTS</variable>
190 </entry>
191 <button>
192 <input file icon="accessories-text-editor"></input>
193 <action type="lauch">leafpad $HOSTS</action>
194 </button>
195 </hbox>
196 <hbox>
197 <text use-markup="true">
198 <label>"<b>Host name :</b>"</label>
199 </text>
200 <entry editable="false">
201 <default>/etc/hostname</default>
202 <variable>HOSTNAME</variable>
203 </entry>
204 <button>
205 <input file icon="accessories-text-editor"></input>
206 <action type="lauch">leafpad $HOSTNAME</action>
207 </button>
208 </hbox>
209 <hbox>
210 <text use-markup="true">
211 <label>"<b>Network :</b>"</label>
212 </text>
213 <entry editable="false">
214 <default>/etc/network.conf</default>
215 <variable>CONFIG_FILE</variable>
216 </entry>
217 <button>
218 <input file icon="accessories-text-editor"></input>
219 <action type="lauch">leafpad $CONFIG_FILE</action>
220 </button>
221 </hbox>
222 <hbox>
223 <button>
224 <label>Restart</label>
225 <input file icon="reload"></input>
226 <action>echo -n "Stopping interface : $INTERFACE... "</action>
227 <action>ifconfig lo down</action>
228 <action>ifconfig $INTERFACE down</action>
229 <action>killall -q udhcpc; echo "done"</action>
230 <action>/etc/init.d/network.sh</action>
231 </button>
232 </hbox>
233 </frame>
235 </notebook>
237 <hbox>
238 <button>
239 <label>Status</label>
240 <input file icon="network-wired"></input>
241 <action type="launch">IFCONFIG</action>
242 </button>
243 <button>
244 <input file icon="exit"></input>
245 <action type="exit">Exit</action>
246 </button>
247 </hbox>
249 </vbox>
250 </window>
251 '
253 # Only root can configure network.
254 check_root
255 gtkdialog --center --program=NET_BOX
257 exit 0