slitaz-tools view tinyutils/netbox @ rev 137

netbox: add samba and iptables
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 12 22:34:10 2008 +0000 (2008-04-12)
parents 0d7aff1e5225
children 1b7c89459369
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="Network status" 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 <text use-markup="true">
39 <label>"
40 <b>Active network servers</b>"
41 </label>
42 </text>
43 <frame Servers>
44 <text wrap="false" width-chars="58">
45 <input>for i in dropbear tftpd udhcpd dnsd rsync lighttpd ; do ps w | grep $i | grep -v grep; done</input>
46 </text>
47 </frame>
48 <hbox>
49 <button>
50 <input file icon="exit"></input>
51 <action type="closewindow">IFCONFIG</action>
52 </button>
53 </hbox>
54 </vbox>
55 </window>
56 '
58 # The main dialog with notebook, start/stop buttons and all options.
59 # Note than /etc/network.conf is seded wehwn an interafce is activate
60 #
61 NET_BOX='
62 <window title="Netbox" icon-name="network-wired">
63 <vbox>
64 <text use-markup="true">
65 <label>
66 "
67 <b>SliTaz - Netbox</b>"
68 </label>
69 </text>
70 <text wrap="true" width-chars="44">
71 <label>
72 "
73 Manage network connections getting dynamic IP
74 by DHCP or static IP, and setup servers.
75 Netbox can start or stop networking, configure
76 network interfaces or directly edit files.
77 "
78 </label>
79 </text>
81 <frame General>
82 <hbox>
83 <text use-markup="true">
84 <label>"<b>Interface :</b>"</label>
85 </text>
86 <entry>
87 <input>. /etc/network.conf; echo $INTERFACE</input>
88 <variable>INTERFACE</variable>
89 </entry>
90 </hbox>
91 </frame>
93 <notebook labels="DHCP|Static IP|System wide|Servers'
94 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX|Firewall"
95 tmp='">
97 <frame Udhcpc>
98 <hbox>
99 <text use-markup="true">
100 <label>"<b>Options :</b>"</label>
101 </text>
102 <entry>
103 <default>-b</default>
104 <variable>UDHCPC_OPTS</variable>
105 </entry>
106 <button>
107 <input file icon="help"></input>
108 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x27 -title "udhcpc help" -e "udhcpc --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
109 </button>
110 </hbox>
111 <hbox>
112 <button>
113 <label>Start</label>
114 <input file icon="forward"></input>
115 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
116 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
117 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
118 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
119 </button>
120 <button>
121 <label>Stop</label>
122 <input file icon="stop"></input>
123 <action>echo -n "Stopping interface : $INTERFACE... "</action>
124 <action>ifconfig $INTERFACE down</action>
125 <action>killall -q udhcpc; echo "done"</action>
126 </button>
127 </hbox>
128 </frame>
130 <frame Configuration>
131 <hbox>
132 <text use-markup="true">
133 <label>"<b>IP :</b>"</label>
134 </text>
135 <entry>
136 <input>. /etc/network.conf; echo "$IP"</input>
137 <variable>IP</variable>
138 </entry>
139 </hbox>
140 <hbox>
141 <text use-markup="true">
142 <label>"<b>Netmask :</b>"</label>
143 </text>
144 <entry>
145 <input>. /etc/network.conf; echo "$NETMASK"</input>
146 <variable>NETMASK</variable>
147 </entry>
148 </hbox>
149 <hbox>
150 <text use-markup="true">
151 <label>"<b>Gateway :</b>"</label>
152 </text>
153 <entry>
154 <input>. /etc/network.conf; echo "$GATEWAY"</input>
155 <variable>GATEWAY</variable>
156 </entry>
157 </hbox>
158 <hbox>
159 <text use-markup="true">
160 <label>"<b>DNS server :</b>"</label>
161 </text>
162 <entry>
163 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
164 <variable>DNS_SERVER</variable>
165 </entry>
166 </hbox>
167 <hbox>
168 <button>
169 <label>Start</label>
170 <input file icon="forward"></input>
171 <action>ifconfig lo down</action>
172 <action>ifconfig $INTERFACE down</action>
173 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
174 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
175 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
176 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
177 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
178 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
179 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
180 <action>/etc/init.d/network.sh</action>
181 </button>
182 <button>
183 <label>Stop</label>
184 <input file icon="stop"></input>
185 <action>echo -n "Stopping interface : $INTERFACE... "</action>
186 <action>ifconfig $INTERFACE down; echo "done"</action>
187 </button>
188 </hbox>
189 </frame>
191 <frame Configuration files>
192 <hbox>
193 <text use-markup="true">
194 <label>"<b>Hosts :</b>"</label>
195 </text>
196 <entry editable="false">
197 <default>/etc/hosts</default>
198 <variable>HOSTS</variable>
199 </entry>
200 <button>
201 <input file icon="accessories-text-editor"></input>
202 <action type="lauch">leafpad $HOSTS</action>
203 </button>
204 </hbox>
205 <hbox>
206 <text use-markup="true">
207 <label>"<b>Host name :</b>"</label>
208 </text>
209 <entry editable="false">
210 <default>/etc/hostname</default>
211 <variable>HOSTNAME</variable>
212 </entry>
213 <button>
214 <input file icon="accessories-text-editor"></input>
215 <action type="lauch">leafpad $HOSTNAME</action>
216 </button>
217 </hbox>
218 <hbox>
219 <text use-markup="true">
220 <label>"<b>Network :</b>"</label>
221 </text>
222 <entry editable="false">
223 <default>/etc/network.conf</default>
224 <variable>CONFIG_FILE</variable>
225 </entry>
226 <button>
227 <input file icon="accessories-text-editor"></input>
228 <action type="lauch">leafpad $CONFIG_FILE</action>
229 </button>
230 </hbox>
231 <hbox>
232 <button>
233 <label>Restart</label>
234 <input file icon="reload"></input>
235 <action>echo -n "Stopping interface : $INTERFACE... "</action>
236 <action>ifconfig lo down</action>
237 <action>ifconfig $INTERFACE down</action>
238 <action>killall -q udhcpc; echo "done"</action>
239 <action>/etc/init.d/network.sh</action>
240 </button>
241 </hbox>
242 </frame>
243 <notebook labels="'
244 NET_BOX="$NET_BOX$tmp"
245 tmp=''
246 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH" && tmp='|'
247 [ -x /usr/bin/tftpd ] && NET_BOX="${NET_BOX}${tmp}TFTP" && tmp='|'
248 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}DHCP" && tmp='|'
249 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
250 -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
251 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
252 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
253 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
254 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
255 . /etc/daemons.conf
256 set -- $DROPBEAR_OPTIONS
257 while [ -n "$2" ]; do
258 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
259 shift
260 done
261 NET_BOX="${NET_BOX}\">"
262 tmp='<frame Dropbear>
263 <hbox>
264 <text use-markup="true">
265 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
266 </text>
267 <entry editable="false">'
268 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
269 tmp2='
270 <variable>DROPBEAR_OPTS</variable>
271 </entry>
272 <button>
273 <input file icon="help"></input>
274 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "dropbear help" -e "dropbear --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
275 </button>
276 <button>
277 <input file icon="accessories-text-editor"></input>
278 <action type="lauch">leafpad /etc/daemons.conf</action>
279 </button>
280 </hbox>
281 <hbox>
282 <text use-markup="true">
283 <label>"<b>Banner :</b>"</label>
284 </text>
285 <entry editable="false">'
286 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
287 tmp2='
288 <variable>DROPBEAR_BANNER</variable>
289 </entry>
290 <button>
291 <input file icon="accessories-text-editor"></input>
292 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
293 </button>
294 </hbox>
295 <hbox>
296 <button>
297 <label>Start</label>
298 <input file icon="forward"></input>
299 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
300 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
301 <action>/etc/init.d/dropbear start</action>
302 </button>
303 <button>
304 <label>Stop</label>
305 <input file icon="stop"></input>
306 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
307 <action>/etc/init.d/dropbear stop</action>
308 </button>
309 </hbox>
310 </frame>
311 '
312 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
313 set -- $TFTPD_OPTIONS
314 TFTPD_OPTS=""
315 while [ -n "$2" ]; do
316 TFTPD_OPTS="$TFTPD_OPTS $1"
317 shift
318 done
319 TFTPD_ROOT="$1"
320 tmp='<frame Tftpd>
321 <hbox>
322 <text use-markup="true">
323 <label>"<b>TFTPD_OPTIONS</b>"</label>
324 </text>
325 <entry editable="false">'
326 [ -n "$TFTPD_OPTS" ] && tmp="$tmp<default>$TFTPD_OPTS</default>"
327 tmp2='
328 <variable>TFTPD_OPTS</variable>
329 </entry>
330 <button>
331 <input file icon="help"></input>
332 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x13 -title "tftpd help" -e "tftpd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
333 </button>
334 <button>
335 <input file icon="accessories-text-editor"></input>
336 <action type="lauch">leafpad /etc/daemons.conf</action>
337 </button>
338 </hbox>
339 <hbox>
340 <text use-markup="true">
341 <label>"<b>Root path :</b>"</label>
342 </text>
343 <entry editable="false">'
344 tmp="$tmp$tmp2"
345 [ -n "$TFTPD_ROOT" ] && tmp="$tmp<default>$TFTPD_ROOT</default>"
346 tmp2='
347 <variable>TFTPD_ROOT</variable>
348 </entry>
349 </hbox>
350 <hbox>
351 <button>
352 <label>Start</label>
353 <input file icon="forward"></input>
354 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)tftpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
355 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"tftpd \1\"/" /etc/rcS.conf</action>
356 <action>/etc/init.d/tftpd start</action>
357 </button>
358 <button>
359 <label>Stop</label>
360 <input file icon="stop"></input>
361 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)tftpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
362 <action>/etc/init.d/tftpd start</action>
363 </button>
364 </hbox>
365 </frame>
366 '
367 [ -x /usr/bin/tftpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
368 tmp='<frame Dhcpd>
369 <hbox>
370 <text use-markup="true">
371 <label>"<b>Configuration :</b>"</label>
372 </text>
373 <entry editable="false">
374 <default>/etc/udhcpd.conf</default>
375 <variable>UDHCPD_CONF</variable>
376 </entry>
377 <button>
378 <input file icon="accessories-text-editor"></input>
379 <action type="lauch">leafpad $UDHCPD_CONF</action>
380 </button>
381 </hbox>
382 <hbox>
383 <button>
384 <label>Start</label>
385 <input file icon="forward"></input>
386 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
387 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
388 <action>/etc/init.d/udhcpd start</action>
389 </button>
390 <button>
391 <label>Stop</label>
392 <input file icon="stop"></input>
393 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
394 <action>/etc/init.d/udhcpd stop</action>
395 </button>
396 </hbox>
397 </frame>
398 '
399 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}"
400 tmp='<frame Pxelinux>
401 <hbox>
402 <text wrap="true">
403 <label>
404 "Tftpd and Dhcpd must be lauched to start the PXE service."
405 </label>
406 </text>
407 </hbox>
408 <hbox>
409 <text use-markup="true">
410 <label>"<b>Configuration :</b>"</label>
411 </text>
412 <entry editable="false">
413 <default>pxelinux.cfg/default</default>
414 <variable>PXE_CONF</variable>
415 </entry>
416 <button>
417 <input file icon="accessories-text-editor"></input>
418 <action>dir=$(dirname $TFTPD_ROOT/$PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
419 <action>lzma d /usr/share/boot/pxelinux.0.lzma $TFTPD_ROOT/pxelinux.0</action>
420 <action>grep "^option bootfile=pxelinux.0" $UDHCPD_CONF || echo "option bootfile=pxelinux.0" >> $UDHCPD_CONF</action>
421 <action>[ -f $TFTPD_ROOT/$PXE_CONF ] || echo -e "label slitaz\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > $TFTPD_ROOT/$PXE_CONF</action>
422 <action type="lauch">leafpad $TFTPD_ROOT/$PXE_CONF</action>
423 </button>
424 </hbox>
425 </frame>
426 '
427 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
428 -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}"
429 tmp='<frame Dnsd>
430 <hbox>
431 <text use-markup="true">
432 <label>"<b>DNSD_OPTIONS</b>"</label>
433 </text>
434 <entry editable="false">'
435 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
436 tmp2='
437 <variable>DNSD_OPTS</variable>
438 </entry>
439 <button>
440 <input file icon="help"></input>
441 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x15 -title "dnsd help" -e "dnsd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
442 </button>
443 <button>
444 <input file icon="accessories-text-editor"></input>
445 <action type="lauch">leafpad /etc/daemons.conf</action>
446 </button>
447 </hbox>
448 <hbox>
449 <text use-markup="true">
450 <label>"<b>Configuration :</b>"</label>
451 </text>
452 <entry editable="false">
453 <default>/etc/dnsd.conf</default>
454 <variable>DNSD_CONF</variable>
455 </entry>
456 <button>
457 <input file icon="accessories-text-editor"></input>
458 <action type="lauch">leafpad $DNSD_CONF</action>
459 </button>
460 </hbox>
461 <hbox>
462 <button>
463 <label>Start</label>
464 <input file icon="forward"></input>
465 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
466 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
467 <action>/etc/init.d/dnsd start</action>
468 </button>
469 <button>
470 <label>Stop</label>
471 <input file icon="stop"></input>
472 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
473 <action>/etc/init.d/dnsd stop</action>
474 </button>
475 </hbox>
476 </frame>
477 '
478 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
479 tmp='<frame Rsync>
480 <hbox>
481 <text use-markup="true">
482 <label>"<b>RSYNCD_OPTIONS</b>"</label>
483 </text>
484 <entry editable="false">'
485 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
486 tmp2='
487 <variable>RSYNC_OPTS</variable>
488 </entry>
489 <button>
490 <input file icon="help"></input>
491 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x31 -title "rsync daemon help" -e "rsync --daemon --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
492 </button>
493 <button>
494 <input file icon="accessories-text-editor"></input>
495 <action type="lauch">leafpad /etc/daemons.conf</action>
496 </button>
497 </hbox>
498 <hbox>
499 <text use-markup="true">
500 <label>"<b>Configuration :</b>"</label>
501 </text>
502 <entry editable="false">
503 <default>/etc/rsyncd.conf</default>
504 <variable>RSYNCD_CONF</variable>
505 </entry>
506 <button>
507 <input file icon="accessories-text-editor"></input>
508 <action type="lauch">leafpad $RSYNCD_CONF</action>
509 </button>
510 </hbox>
511 <hbox>
512 <text use-markup="true">
513 <label>"<b>Secrets file :</b>"</label>
514 </text>
515 <entry editable="true">
516 <default>/etc/rsyncd.secrets</default>
517 <variable>RSYNCD_SECRETS</variable>
518 </entry>
519 <button>
520 <input file icon="accessories-text-editor"></input>
521 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
522 </button>
523 </hbox>
524 <hbox>
525 <button>
526 <label>Start</label>
527 <input file icon="forward"></input>
528 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
529 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
530 <action>/etc/init.d/rsyncd start</action>
531 </button>
532 <button>
533 <label>Stop</label>
534 <input file icon="stop"></input>
535 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
536 <action>/etc/init.d/rsyncd stop</action>
537 </button>
538 </hbox>
539 </frame>
540 '
541 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
542 tmp='<frame Lighttpd>
543 <hbox>
544 <text use-markup="true">
545 <label>"<b>Configuration :</b>"</label>
546 </text>
547 <entry editable="false">
548 <default>/etc/lighttpd/lighttpd.conf</default>
549 <variable>LIGHTTPD_CONF</variable>
550 </entry>
551 <button>
552 <input file icon="accessories-text-editor"></input>
553 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
554 </button>
555 </hbox>
556 <hbox>
557 <button>
558 <label>Start</label>
559 <input file icon="forward"></input>
560 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
561 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
562 <action>/etc/init.d/lighttpd start</action>
563 </button>
564 <button>
565 <label>Stop</label>
566 <input file icon="stop"></input>
567 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
568 <action>/etc/init.d/lighttpd stop</action>
569 </button>
570 </hbox>
571 </frame>
572 '
573 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}"
574 tmp='<frame Samba: smbd & nmbd>
575 <hbox>
576 <text use-markup="true">
577 <label>"<b>Configuration :</b>"</label>
578 </text>
579 <entry editable="false">
580 <default>/etc/samba/smb.conf</default>
581 <variable>SMBD_CONF</variable>
582 </entry>
583 <button>
584 <input file icon="accessories-text-editor"></input>
585 <action type="lauch">leafpad $SMBD_CONF</action>
586 </button>
587 </hbox>
588 <hbox>
589 <button>
590 <label>Reload</label>
591 <input file icon="reload"></input>
592 <action>/etc/init.d/samba reload</action>
593 </button>
594 <button>
595 <label>Start</label>
596 <input file icon="forward"></input>
597 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
598 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
599 <action>/etc/init.d/lighttpd start</action>
600 </button>
601 <button>
602 <label>Stop</label>
603 <input file icon="stop"></input>
604 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
605 <action>/etc/init.d/lighttpd stop</action>
606 </button>
607 </hbox>
608 </frame>
609 '
610 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
611 NET_BOX="${NET_BOX}
612 </notebook>
613 "
614 tmp='<frame Iptables>
615 <hbox>
616 <text use-markup="true">
617 <label>"<b>Configuration :</b>"</label>
618 </text>
619 <entry editable="false">
620 <default>/etc/iptables.conf</default>
621 <variable>IPTABLES_CONF</variable>
622 </entry>
623 <button>
624 <input file icon="accessories-text-editor"></input>
625 <action type="lauch">leafpad $IPTABLES_CONF</action>
626 </button>
627 </hbox>
628 <hbox>
629 <button>
630 <label>Load</label>
631 <input file icon="reload"></input>
632 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
633 </button>
634 <button>
635 <label>Save</label>
636 <input file icon="go-jump"></input>
637 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
638 </button>
639 </hbox>
640 </frame>
641 '
642 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
643 tmp='
644 </notebook>
646 <hbox>
647 <button>
648 <label>Status</label>
649 <input file icon="network-wired"></input>
650 <action type="launch">IFCONFIG</action>
651 </button>
652 <button>
653 <input file icon="exit"></input>
654 <action type="exit">Exit</action>
655 </button>
656 </hbox>
658 </vbox>
659 </window>
660 '
661 NET_BOX="${NET_BOX}${tmp}"
663 export NET_BOX
665 # TODO: Servers/VNC(X11vnc)
666 # Modules(Network kernel modules) VPN(OpenVPN)
668 # Only root can configure network.
669 check_root
670 gtkdialog --center --program=NET_BOX
672 exit 0