slitaz-tools view tinyutils/netbox @ rev 161

netbox: fix default pxe config
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Apr 23 21:57:53 2008 +0000 (2008-04-23)
parents 570116a5cf7a
children 135677d78c7b
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>UDHCPD_OPTIONS</b>"</label>
382 </text>
383 <entry editable="false">'
384 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
385 tmp2='
386 <variable>UDHCPD_OPTS</variable>
387 </entry>
388 <button>
389 <input file icon="help"></input>
390 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 60x14 -title "udhcpd help" -e "udhcpd --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
391 </button>
392 <button>
393 <input file icon="accessories-text-editor"></input>
394 <action type="lauch">leafpad /etc/daemons.conf</action>
395 </button>
396 </hbox>
397 <hbox>
398 <text use-markup="true">
399 <label>"<b>Configuration :</b>"</label>
400 </text>
401 <entry editable="false">
402 <default>/etc/udhcpd.conf</default>
403 <variable>UDHCPD_CONF</variable>
404 </entry>
405 <button>
406 <input file icon="accessories-text-editor"></input>
407 <action type="lauch">leafpad $UDHCPD_CONF</action>
408 </button>
409 </hbox>
410 <hbox>
411 <button>
412 <label>Start</label>
413 <input file icon="forward"></input>
414 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
415 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
416 <action>/etc/init.d/udhcpd start</action>
417 </button>
418 <button>
419 <label>Stop</label>
420 <input file icon="stop"></input>
421 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
422 <action>/etc/init.d/udhcpd stop</action>
423 </button>
424 </hbox>
425 </frame>
426 '
427 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
428 tmp='<frame Pxelinux>
429 <hbox>
430 <text wrap="true">
431 <label>
432 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
433 </label>
434 </text>
435 </hbox>
436 <hbox>
437 <text use-markup="true">
438 <label>"<b>Configuration :</b>"</label>
439 </text>
440 <entry editable="false">
441 <default>'
442 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
443 tmp2='/pxelinux.cfg/default</default>
444 <variable>PXE_CONF</variable>
445 </entry>
446 <button>
447 <input file icon="accessories-text-editor"></input>
448 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
449 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
450 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
451 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
452 <action>[ -f $PXE_CONF ] || echo -e "label linux\n\tkernel bzImage\n\tappend initrd=rootfs.gz rw root=/dev/null vga=normal" > $PXE_CONF</action>
453 <action type="lauch">leafpad $PXE_CONF</action>
454 </button>
455 </hbox>
456 </frame>
457 '
458 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
459 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
460 tmp='<frame Dnsd>
461 <hbox>
462 <text use-markup="true">
463 <label>"<b>DNSD_OPTIONS</b>"</label>
464 </text>
465 <entry editable="false">'
466 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
467 tmp2='
468 <variable>DNSD_OPTS</variable>
469 </entry>
470 <button>
471 <input file icon="help"></input>
472 <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>
473 </button>
474 <button>
475 <input file icon="accessories-text-editor"></input>
476 <action type="lauch">leafpad /etc/daemons.conf</action>
477 </button>
478 </hbox>
479 <hbox>
480 <text use-markup="true">
481 <label>"<b>Configuration :</b>"</label>
482 </text>
483 <entry editable="false">
484 <default>/etc/dnsd.conf</default>
485 <variable>DNSD_CONF</variable>
486 </entry>
487 <button>
488 <input file icon="accessories-text-editor"></input>
489 <action type="lauch">leafpad $DNSD_CONF</action>
490 </button>
491 </hbox>
492 <hbox>
493 <button>
494 <label>Start</label>
495 <input file icon="forward"></input>
496 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
497 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
498 <action>/etc/init.d/dnsd start</action>
499 </button>
500 <button>
501 <label>Stop</label>
502 <input file icon="stop"></input>
503 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
504 <action>/etc/init.d/dnsd stop</action>
505 </button>
506 </hbox>
507 </frame>
508 '
509 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
510 tmp='<frame Rsync>
511 <hbox>
512 <text use-markup="true">
513 <label>"<b>RSYNCD_OPTIONS</b>"</label>
514 </text>
515 <entry editable="false">'
516 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
517 tmp2='
518 <variable>RSYNC_OPTS</variable>
519 </entry>
520 <button>
521 <input file icon="help"></input>
522 <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>
523 </button>
524 <button>
525 <input file icon="accessories-text-editor"></input>
526 <action type="lauch">leafpad /etc/daemons.conf</action>
527 </button>
528 </hbox>
529 <hbox>
530 <text use-markup="true">
531 <label>"<b>Configuration :</b>"</label>
532 </text>
533 <entry editable="false">
534 <default>/etc/rsyncd.conf</default>
535 <variable>RSYNCD_CONF</variable>
536 </entry>
537 <button>
538 <input file icon="accessories-text-editor"></input>
539 <action type="lauch">leafpad $RSYNCD_CONF</action>
540 </button>
541 </hbox>
542 <hbox>
543 <text use-markup="true">
544 <label>"<b>Secrets file :</b>"</label>
545 </text>
546 <entry editable="true">
547 <default>/etc/rsyncd.secrets</default>
548 <variable>RSYNCD_SECRETS</variable>
549 </entry>
550 <button>
551 <input file icon="accessories-text-editor"></input>
552 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
553 </button>
554 </hbox>
555 <hbox>
556 <button>
557 <label>Start</label>
558 <input file icon="forward"></input>
559 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
560 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
561 <action>/etc/init.d/rsyncd start</action>
562 </button>
563 <button>
564 <label>Stop</label>
565 <input file icon="stop"></input>
566 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
567 <action>/etc/init.d/rsyncd stop</action>
568 </button>
569 </hbox>
570 </frame>
571 '
572 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
573 tmp='<frame Lighttpd>
574 <hbox>
575 <text use-markup="true">
576 <label>"<b>Configuration :</b>"</label>
577 </text>
578 <entry editable="false">
579 <default>/etc/lighttpd/lighttpd.conf</default>
580 <variable>LIGHTTPD_CONF</variable>
581 </entry>
582 <button>
583 <input file icon="accessories-text-editor"></input>
584 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
585 </button>
586 </hbox>
587 <hbox>
588 <button>
589 <label>Start</label>
590 <input file icon="forward"></input>
591 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
592 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
593 <action>/etc/init.d/lighttpd start</action>
594 </button>
595 <button>
596 <label>Stop</label>
597 <input file icon="stop"></input>
598 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
599 <action>/etc/init.d/lighttpd stop</action>
600 </button>
601 </hbox>
602 </frame>
603 '
604 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}"
605 tmp='<frame Samba: smbd & nmbd>
606 <hbox>
607 <text use-markup="true">
608 <label>"<b>Configuration :</b>"</label>
609 </text>
610 <entry editable="false">
611 <default>/etc/samba/smb.conf</default>
612 <variable>SMBD_CONF</variable>
613 </entry>
614 <button>
615 <input file icon="accessories-text-editor"></input>
616 <action type="lauch">leafpad $SMBD_CONF</action>
617 </button>
618 </hbox>
619 <hbox>
620 <button>
621 <label>Reload</label>
622 <input file icon="reload"></input>
623 <action>/etc/init.d/samba reload</action>
624 </button>
625 <button>
626 <label>Start</label>
627 <input file icon="forward"></input>
628 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
629 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
630 <action>/etc/init.d/lighttpd start</action>
631 </button>
632 <button>
633 <label>Stop</label>
634 <input file icon="stop"></input>
635 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
636 <action>/etc/init.d/lighttpd stop</action>
637 </button>
638 </hbox>
639 </frame>
640 '
641 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
642 NET_BOX="${NET_BOX}
643 </notebook>
644 "
645 tmp='<frame Iptables>
646 <hbox>
647 <text use-markup="true">
648 <label>"<b>Configuration :</b>"</label>
649 </text>
650 <entry editable="false">
651 <default>/etc/iptables.conf</default>
652 <variable>IPTABLES_CONF</variable>
653 </entry>
654 <button>
655 <input file icon="accessories-text-editor"></input>
656 <action type="lauch">leafpad $IPTABLES_CONF</action>
657 </button>
658 </hbox>
659 <hbox>
660 <button>
661 <label>Load</label>
662 <input file icon="reload"></input>
663 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
664 </button>
665 <button>
666 <label>Save</label>
667 <input file icon="go-jump"></input>
668 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
669 </button>
670 </hbox>
671 </frame>
672 '
673 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
674 tmp='
675 <frame Ether-wake>
676 <hbox>
677 <text use-markup="true">
678 <label>"<b>Machines :</b>"</label>
679 </text>
680 <entry editable="false">
681 <default>/etc/ethers</default>
682 <variable>ETHERS</variable>
683 </entry>
684 <button>
685 <input file icon="accessories-text-editor"></input>
686 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
687 <action type="lauch">leafpad $ETHERS</action>
688 </button>
689 </hbox>
690 <hbox>
691 <text use-markup="true">
692 <label>"<b>Options : </b>"</label>
693 </text>
694 <entry editable="false">
695 <variable>ETHERWAKE_OPTS</variable>
696 </entry>
697 <button>
698 <input file icon="help"></input>
699 <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>
700 </button>
701 <button>
702 <label>Start</label>
703 <input file icon="forward"></input>
704 <action>ether-wake $ETHERWAKE_OPTS</action>
705 </button>
706 </hbox>
707 </frame>
708 </notebook>
710 <hbox>
711 <button>
712 <label>Status</label>
713 <input file icon="network-wired"></input>
714 <action type="launch">IFCONFIG</action>
715 </button>
716 <button>
717 <input file icon="exit"></input>
718 <action type="exit">Exit</action>
719 </button>
720 </hbox>
722 </vbox>
723 </window>
724 '
725 NET_BOX="${NET_BOX}${tmp}"
727 export NET_BOX
729 # TODO: Servers/VNC(X11vnc)
730 # Modules(Network kernel modules) VPN(OpenVPN)
732 # Only root can configure network.
733 check_root
734 gtkdialog --center --program=NET_BOX
736 exit 0