slitaz-tools view tinyutils/netbox @ rev 151

netbox: tftpd started by inetd
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Apr 19 19:38:33 2008 +0000 (2008-04-19)
parents e07f37112a41
children c08ea2bfd42d
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 inetd 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='|Etherwake">
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/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}INETD" && 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/inetd -a -x /usr/sbin/udhcpd ] \
251 && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
252 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
253 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
254 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
255 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
256 . /etc/daemons.conf
257 set -- $DROPBEAR_OPTIONS
258 while [ -n "$2" ]; do
259 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
260 shift
261 done
262 NET_BOX="${NET_BOX}\">"
263 tmp='<frame Dropbear>
264 <hbox>
265 <text use-markup="true">
266 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
267 </text>
268 <entry editable="false">'
269 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
270 tmp2='
271 <variable>DROPBEAR_OPTS</variable>
272 </entry>
273 <button>
274 <input file icon="help"></input>
275 <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>
276 </button>
277 <button>
278 <input file icon="accessories-text-editor"></input>
279 <action type="lauch">leafpad /etc/daemons.conf</action>
280 </button>
281 </hbox>
282 <hbox>
283 <text use-markup="true">
284 <label>"<b>Banner :</b>"</label>
285 </text>
286 <entry editable="false">'
287 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
288 tmp2='
289 <variable>DROPBEAR_BANNER</variable>
290 </entry>
291 <button>
292 <input file icon="accessories-text-editor"></input>
293 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
294 </button>
295 </hbox>
296 <hbox>
297 <button>
298 <label>Start</label>
299 <input file icon="forward"></input>
300 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
301 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
302 <action>/etc/init.d/dropbear start</action>
303 </button>
304 <button>
305 <label>Stop</label>
306 <input file icon="stop"></input>
307 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
308 <action>/etc/init.d/dropbear stop</action>
309 </button>
310 </hbox>
311 </frame>
312 '
313 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
314 tmp='<frame Inetd>
315 <hbox>
316 <text use-markup="true">
317 <label>"<b>INETD_OPTIONS</b>"</label>
318 </text>
319 <entry editable="false">'
320 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
321 tmp2='
322 <variable>INETD_OPTS</variable>
323 </entry>
324 <button>
325 <input file icon="help"></input>
326 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 60x14 -title "inetd help" -e "inetd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
327 </button>
328 <button>
329 <input file icon="accessories-text-editor"></input>
330 <action type="lauch">leafpad /etc/daemons.conf</action>
331 </button>
332 </hbox>
333 <hbox>
334 <text use-markup="true">
335 <label>"<b>Configuration :</b>"</label>
336 </text>
337 <entry editable="false">
338 <default>/etc/inetd.conf</default>
339 <variable>INETD_CONF</variable>
340 </entry>
341 <button>
342 <input file icon="accessories-text-editor"></input>
343 <action type="lauch">leafpad $INETD_CONF</action>
344 </button>
345 </hbox>
346 <hbox>
347 '
348 tmp="$tmp$tmp2"
349 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
350 i=$(basename $i)
351 tmp2="
352 <button>
353 <input file icon=\"help\"></input>
354 <label>$i</label>
355 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 60x19 -title \"$i help\" -e \"$i --help ; echo -e \\\"----\nENTER to continue...\\\" && read close\"</action>
356 </button>
357 "
358 tmp="$tmp$tmp2"
359 done
360 tmp2='
361 <button>
362 <label>Start</label>
363 <input file icon="forward"></input>
364 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
365 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
366 <action>/etc/init.d/inetd start</action>
367 </button>
368 <button>
369 <label>Stop</label>
370 <input file icon="stop"></input>
371 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
372 <action>/etc/init.d/inetd stop</action>
373 </button>
374 </hbox>
375 </frame>
376 '
377 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
378 tmp='<frame Dhcpd>
379 <hbox>
380 <text use-markup="true">
381 <label>"<b>Configuration :</b>"</label>
382 </text>
383 <entry editable="false">
384 <default>/etc/udhcpd.conf</default>
385 <variable>UDHCPD_CONF</variable>
386 </entry>
387 <button>
388 <input file icon="accessories-text-editor"></input>
389 <action type="lauch">leafpad $UDHCPD_CONF</action>
390 </button>
391 </hbox>
392 <hbox>
393 <button>
394 <label>Start</label>
395 <input file icon="forward"></input>
396 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
397 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
398 <action>/etc/init.d/udhcpd start</action>
399 </button>
400 <button>
401 <label>Stop</label>
402 <input file icon="stop"></input>
403 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
404 <action>/etc/init.d/udhcpd stop</action>
405 </button>
406 </hbox>
407 </frame>
408 '
409 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}"
410 tmp='<frame Pxelinux>
411 <hbox>
412 <text wrap="true">
413 <label>
414 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
415 </label>
416 </text>
417 </hbox>
418 <hbox>
419 <text use-markup="true">
420 <label>"<b>Configuration :</b>"</label>
421 </text>
422 <entry editable="false">
423 <default>pxelinux.cfg/default</default>
424 <variable>PXE_CONF</variable>
425 </entry>
426 <button>
427 <input file icon="accessories-text-editor"></input>
428 <action>dir=$(dirname /boot/$PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
429 <action>lzma d /usr/share/boot/pxelinux.0.lzma /boot/pxelinux.0</action>
430 <action>grep "^option bootfile=pxelinux.0" $UDHCPD_CONF || echo "option bootfile=pxelinux.0" >> $UDHCPD_CONF</action>
431 <action>[ -f /boot/$PXE_CONF ] || echo -e "label slitaz\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > /boot/$PXE_CONF</action>
432 <action type="lauch">leafpad /boot/$PXE_CONF</action>
433 </button>
434 </hbox>
435 </frame>
436 '
437 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
438 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}"
439 tmp='<frame Dnsd>
440 <hbox>
441 <text use-markup="true">
442 <label>"<b>DNSD_OPTIONS</b>"</label>
443 </text>
444 <entry editable="false">'
445 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
446 tmp2='
447 <variable>DNSD_OPTS</variable>
448 </entry>
449 <button>
450 <input file icon="help"></input>
451 <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>
452 </button>
453 <button>
454 <input file icon="accessories-text-editor"></input>
455 <action type="lauch">leafpad /etc/daemons.conf</action>
456 </button>
457 </hbox>
458 <hbox>
459 <text use-markup="true">
460 <label>"<b>Configuration :</b>"</label>
461 </text>
462 <entry editable="false">
463 <default>/etc/dnsd.conf</default>
464 <variable>DNSD_CONF</variable>
465 </entry>
466 <button>
467 <input file icon="accessories-text-editor"></input>
468 <action type="lauch">leafpad $DNSD_CONF</action>
469 </button>
470 </hbox>
471 <hbox>
472 <button>
473 <label>Start</label>
474 <input file icon="forward"></input>
475 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
476 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
477 <action>/etc/init.d/dnsd start</action>
478 </button>
479 <button>
480 <label>Stop</label>
481 <input file icon="stop"></input>
482 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
483 <action>/etc/init.d/dnsd stop</action>
484 </button>
485 </hbox>
486 </frame>
487 '
488 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
489 tmp='<frame Rsync>
490 <hbox>
491 <text use-markup="true">
492 <label>"<b>RSYNCD_OPTIONS</b>"</label>
493 </text>
494 <entry editable="false">'
495 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
496 tmp2='
497 <variable>RSYNC_OPTS</variable>
498 </entry>
499 <button>
500 <input file icon="help"></input>
501 <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>
502 </button>
503 <button>
504 <input file icon="accessories-text-editor"></input>
505 <action type="lauch">leafpad /etc/daemons.conf</action>
506 </button>
507 </hbox>
508 <hbox>
509 <text use-markup="true">
510 <label>"<b>Configuration :</b>"</label>
511 </text>
512 <entry editable="false">
513 <default>/etc/rsyncd.conf</default>
514 <variable>RSYNCD_CONF</variable>
515 </entry>
516 <button>
517 <input file icon="accessories-text-editor"></input>
518 <action type="lauch">leafpad $RSYNCD_CONF</action>
519 </button>
520 </hbox>
521 <hbox>
522 <text use-markup="true">
523 <label>"<b>Secrets file :</b>"</label>
524 </text>
525 <entry editable="true">
526 <default>/etc/rsyncd.secrets</default>
527 <variable>RSYNCD_SECRETS</variable>
528 </entry>
529 <button>
530 <input file icon="accessories-text-editor"></input>
531 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
532 </button>
533 </hbox>
534 <hbox>
535 <button>
536 <label>Start</label>
537 <input file icon="forward"></input>
538 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
539 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
540 <action>/etc/init.d/rsyncd start</action>
541 </button>
542 <button>
543 <label>Stop</label>
544 <input file icon="stop"></input>
545 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
546 <action>/etc/init.d/rsyncd stop</action>
547 </button>
548 </hbox>
549 </frame>
550 '
551 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
552 tmp='<frame Lighttpd>
553 <hbox>
554 <text use-markup="true">
555 <label>"<b>Configuration :</b>"</label>
556 </text>
557 <entry editable="false">
558 <default>/etc/lighttpd/lighttpd.conf</default>
559 <variable>LIGHTTPD_CONF</variable>
560 </entry>
561 <button>
562 <input file icon="accessories-text-editor"></input>
563 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
564 </button>
565 </hbox>
566 <hbox>
567 <button>
568 <label>Start</label>
569 <input file icon="forward"></input>
570 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
571 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
572 <action>/etc/init.d/lighttpd start</action>
573 </button>
574 <button>
575 <label>Stop</label>
576 <input file icon="stop"></input>
577 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
578 <action>/etc/init.d/lighttpd stop</action>
579 </button>
580 </hbox>
581 </frame>
582 '
583 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}"
584 tmp='<frame Samba: smbd & nmbd>
585 <hbox>
586 <text use-markup="true">
587 <label>"<b>Configuration :</b>"</label>
588 </text>
589 <entry editable="false">
590 <default>/etc/samba/smb.conf</default>
591 <variable>SMBD_CONF</variable>
592 </entry>
593 <button>
594 <input file icon="accessories-text-editor"></input>
595 <action type="lauch">leafpad $SMBD_CONF</action>
596 </button>
597 </hbox>
598 <hbox>
599 <button>
600 <label>Reload</label>
601 <input file icon="reload"></input>
602 <action>/etc/init.d/samba reload</action>
603 </button>
604 <button>
605 <label>Start</label>
606 <input file icon="forward"></input>
607 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
608 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
609 <action>/etc/init.d/lighttpd start</action>
610 </button>
611 <button>
612 <label>Stop</label>
613 <input file icon="stop"></input>
614 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
615 <action>/etc/init.d/lighttpd stop</action>
616 </button>
617 </hbox>
618 </frame>
619 '
620 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
621 NET_BOX="${NET_BOX}
622 </notebook>
623 "
624 tmp='<frame Iptables>
625 <hbox>
626 <text use-markup="true">
627 <label>"<b>Configuration :</b>"</label>
628 </text>
629 <entry editable="false">
630 <default>/etc/iptables.conf</default>
631 <variable>IPTABLES_CONF</variable>
632 </entry>
633 <button>
634 <input file icon="accessories-text-editor"></input>
635 <action type="lauch">leafpad $IPTABLES_CONF</action>
636 </button>
637 </hbox>
638 <hbox>
639 <button>
640 <label>Load</label>
641 <input file icon="reload"></input>
642 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
643 </button>
644 <button>
645 <label>Save</label>
646 <input file icon="go-jump"></input>
647 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
648 </button>
649 </hbox>
650 </frame>
651 '
652 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
653 tmp='
654 <frame Ether-wake>
655 <hbox>
656 <text use-markup="true">
657 <label>"<b>Machines :</b>"</label>
658 </text>
659 <entry editable="false">
660 <default>/etc/ethers</default>
661 <variable>ETHERS</variable>
662 </entry>
663 <button>
664 <input file icon="accessories-text-editor"></input>
665 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
666 <action type="lauch">leafpad $ETHERS</action>
667 </button>
668 </hbox>
669 <hbox>
670 <text use-markup="true">
671 <label>"<b>Options : </b>"</label>
672 </text>
673 <entry editable="false">
674 <variable>ETHERWAKE_OPTS</variable>
675 </entry>
676 <button>
677 <input file icon="help"></input>
678 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x15 -title "dnsd help" -e "ether-wake --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
679 </button>
680 <button>
681 <label>Start</label>
682 <input file icon="forward"></input>
683 <action>ether-wake $ETHERWAKE_OPTS</action>
684 </button>
685 </hbox>
686 </frame>
687 </notebook>
689 <hbox>
690 <button>
691 <label>Status</label>
692 <input file icon="network-wired"></input>
693 <action type="launch">IFCONFIG</action>
694 </button>
695 <button>
696 <input file icon="exit"></input>
697 <action type="exit">Exit</action>
698 </button>
699 </hbox>
701 </vbox>
702 </window>
703 '
704 NET_BOX="${NET_BOX}${tmp}"
706 export NET_BOX
708 # TODO: Servers/VNC(X11vnc)
709 # Modules(Network kernel modules) VPN(OpenVPN)
711 # Only root can configure network.
712 check_root
713 gtkdialog --center --program=NET_BOX
715 exit 0