slitaz-tools view tinyutils/netbox @ rev 169

netbox/PXE: list boot files
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 04 12:08:40 2008 +0000 (2008-05-04)
parents c3f3b2feb87c
children fc51bbbcac62
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 smbd nmbd x11vnc; 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 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}VNC" && tmp='|'
257 . /etc/daemons.conf
258 set -- $DROPBEAR_OPTIONS
259 while [ -n "$2" ]; do
260 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
261 shift
262 done
263 NET_BOX="${NET_BOX}\">"
264 tmp='<frame Dropbear>
265 <hbox>
266 <text use-markup="true">
267 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
268 </text>
269 <entry editable="false">'
270 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
271 tmp2='
272 <variable>DROPBEAR_OPTS</variable>
273 </entry>
274 <button>
275 <input file icon="help"></input>
276 <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>
277 </button>
278 <button>
279 <input file icon="accessories-text-editor"></input>
280 <action type="lauch">leafpad /etc/daemons.conf</action>
281 </button>
282 </hbox>
283 <hbox>
284 <text use-markup="true">
285 <label>"<b>Banner :</b>"</label>
286 </text>
287 <entry editable="false">'
288 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
289 tmp2='
290 <variable>DROPBEAR_BANNER</variable>
291 </entry>
292 <button>
293 <input file icon="accessories-text-editor"></input>
294 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
295 </button>
296 </hbox>
297 <hbox>
298 <button>
299 <label>Start</label>
300 <input file icon="forward"></input>
301 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
302 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
303 <action>/etc/init.d/dropbear start</action>
304 </button>
305 <button>
306 <label>Stop</label>
307 <input file icon="stop"></input>
308 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
309 <action>/etc/init.d/dropbear stop</action>
310 </button>
311 </hbox>
312 </frame>
313 '
314 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
315 tmp='<frame Inetd>
316 <hbox>
317 <text use-markup="true">
318 <label>"<b>INETD_OPTIONS</b>"</label>
319 </text>
320 <entry editable="false">'
321 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
322 tmp2='
323 <variable>INETD_OPTS</variable>
324 </entry>
325 <button>
326 <input file icon="help"></input>
327 <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>
328 </button>
329 <button>
330 <input file icon="accessories-text-editor"></input>
331 <action type="lauch">leafpad /etc/daemons.conf</action>
332 </button>
333 </hbox>
334 <hbox>
335 <text use-markup="true">
336 <label>"<b>Configuration :</b>"</label>
337 </text>
338 <entry editable="false">
339 <default>/etc/inetd.conf</default>
340 <variable>INETD_CONF</variable>
341 </entry>
342 <button>
343 <input file icon="accessories-text-editor"></input>
344 <action type="lauch">leafpad $INETD_CONF</action>
345 </button>
346 </hbox>
347 <hbox>
348 '
349 tmp="$tmp$tmp2"
350 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
351 i=$(basename $i)
352 tmp2="
353 <button>
354 <input file icon=\"help\"></input>
355 <label>$i</label>
356 <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>
357 </button>
358 "
359 tmp="$tmp$tmp2"
360 done
361 tmp2='
362 <button>
363 <label>Start</label>
364 <input file icon="forward"></input>
365 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
366 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
367 <action>/etc/init.d/inetd start</action>
368 </button>
369 <button>
370 <label>Stop</label>
371 <input file icon="stop"></input>
372 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
373 <action>/etc/init.d/inetd stop</action>
374 </button>
375 </hbox>
376 </frame>
377 '
378 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
379 tmp='<frame Dhcpd>
380 <hbox>
381 <text use-markup="true">
382 <label>"<b>UDHCPD_OPTIONS</b>"</label>
383 </text>
384 <entry editable="false">'
385 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
386 tmp2='
387 <variable>UDHCPD_OPTS</variable>
388 </entry>
389 <button>
390 <input file icon="help"></input>
391 <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>
392 </button>
393 <button>
394 <input file icon="accessories-text-editor"></input>
395 <action type="lauch">leafpad /etc/daemons.conf</action>
396 </button>
397 </hbox>
398 <hbox>
399 <text use-markup="true">
400 <label>"<b>Configuration :</b>"</label>
401 </text>
402 <entry editable="false">
403 <default>/etc/udhcpd.conf</default>
404 <variable>UDHCPD_CONF</variable>
405 </entry>
406 <button>
407 <input file icon="accessories-text-editor"></input>
408 <action type="lauch">leafpad $UDHCPD_CONF</action>
409 </button>
410 </hbox>
411 <hbox>
412 <button>
413 <label>Start</label>
414 <input file icon="forward"></input>
415 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
416 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
417 <action>/etc/init.d/udhcpd start</action>
418 </button>
419 <button>
420 <label>Stop</label>
421 <input file icon="stop"></input>
422 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
423 <action>/etc/init.d/udhcpd stop</action>
424 </button>
425 </hbox>
426 </frame>
427 '
428 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
429 tmp='<frame Pxelinux>
430 <hbox>
431 <text wrap="true">
432 <label>
433 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
434 </label>
435 </text>
436 </hbox>
437 <hbox>
438 <text use-markup="true">
439 <label>"<b>Configuration :</b>"</label>
440 </text>
441 <entry editable="false">
442 <default>'
443 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
444 tmp2='/pxelinux.cfg/default</default>
445 <variable>PXE_CONF</variable>
446 </entry>
447 <button>
448 <input file icon="accessories-text-editor"></input>
449 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
450 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
451 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
452 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
453 <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>
454 <action type="lauch">leafpad $PXE_CONF</action>
455 </button>
456 </hbox>
457 <hbox>
458 <button>
459 <input file icon="system-file-manager"></input>
460 <label>Network boot files</label>
461 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 100x25 -title "Network boot files (q to quit)" -e "find $(dirname $(dirname $PXE_CONF)) -exec ls -ld {} \; | less"</action>
462 </button>
463 </hbox>
464 </frame>
465 '
466 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
467 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
468 tmp='<frame Dnsd>
469 <hbox>
470 <text use-markup="true">
471 <label>"<b>DNSD_OPTIONS</b>"</label>
472 </text>
473 <entry editable="false">'
474 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
475 tmp2='
476 <variable>DNSD_OPTS</variable>
477 </entry>
478 <button>
479 <input file icon="help"></input>
480 <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>
481 </button>
482 <button>
483 <input file icon="accessories-text-editor"></input>
484 <action type="lauch">leafpad /etc/daemons.conf</action>
485 </button>
486 </hbox>
487 <hbox>
488 <text use-markup="true">
489 <label>"<b>Configuration :</b>"</label>
490 </text>
491 <entry editable="false">
492 <default>/etc/dnsd.conf</default>
493 <variable>DNSD_CONF</variable>
494 </entry>
495 <button>
496 <input file icon="accessories-text-editor"></input>
497 <action type="lauch">leafpad $DNSD_CONF</action>
498 </button>
499 </hbox>
500 <hbox>
501 <button>
502 <label>Start</label>
503 <input file icon="forward"></input>
504 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
505 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
506 <action>/etc/init.d/dnsd start</action>
507 </button>
508 <button>
509 <label>Stop</label>
510 <input file icon="stop"></input>
511 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
512 <action>/etc/init.d/dnsd stop</action>
513 </button>
514 </hbox>
515 </frame>
516 '
517 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
518 tmp='<frame Rsync>
519 <hbox>
520 <text use-markup="true">
521 <label>"<b>RSYNCD_OPTIONS</b>"</label>
522 </text>
523 <entry editable="false">'
524 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
525 tmp2='
526 <variable>RSYNC_OPTS</variable>
527 </entry>
528 <button>
529 <input file icon="help"></input>
530 <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>
531 </button>
532 <button>
533 <input file icon="accessories-text-editor"></input>
534 <action type="lauch">leafpad /etc/daemons.conf</action>
535 </button>
536 </hbox>
537 <hbox>
538 <text use-markup="true">
539 <label>"<b>Configuration :</b>"</label>
540 </text>
541 <entry editable="false">
542 <default>/etc/rsyncd.conf</default>
543 <variable>RSYNCD_CONF</variable>
544 </entry>
545 <button>
546 <input file icon="accessories-text-editor"></input>
547 <action type="lauch">leafpad $RSYNCD_CONF</action>
548 </button>
549 </hbox>
550 <hbox>
551 <text use-markup="true">
552 <label>"<b>Secrets file :</b>"</label>
553 </text>
554 <entry editable="true">
555 <default>/etc/rsyncd.secrets</default>
556 <variable>RSYNCD_SECRETS</variable>
557 </entry>
558 <button>
559 <input file icon="accessories-text-editor"></input>
560 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
561 </button>
562 </hbox>
563 <hbox>
564 <button>
565 <label>Start</label>
566 <input file icon="forward"></input>
567 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
568 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
569 <action>/etc/init.d/rsyncd start</action>
570 </button>
571 <button>
572 <label>Stop</label>
573 <input file icon="stop"></input>
574 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
575 <action>/etc/init.d/rsyncd stop</action>
576 </button>
577 </hbox>
578 </frame>
579 '
580 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
581 tmp='<frame Lighttpd>'
582 tmp2='<frame PHP>
583 <hbox>
584 <text use-markup="true">
585 <label>"<b>Configuration :</b>"</label>
586 </text>
587 <entry editable="false">
588 <default>/etc/php.ini</default>
589 <variable>PHP_CONF</variable>
590 </entry>
591 <button>
592 <input file icon="accessories-text-editor"></input>
593 <action type="lauch">leafpad $PHP_CONF</action>
594 </button>
595 </hbox>
596 </frame>
597 '
598 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
599 tmp2='<hbox>
600 <text use-markup="true">
601 <label>"<b>Configuration :</b>"</label>
602 </text>
603 <entry editable="false">
604 <default>/etc/lighttpd/lighttpd.conf</default>
605 <variable>LIGHTTPD_CONF</variable>
606 </entry>
607 <button>
608 <input file icon="accessories-text-editor"></input>
609 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
610 </button>
611 </hbox>
612 <hbox>
613 <button>
614 <label>Start</label>
615 <input file icon="forward"></input>
616 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
617 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
618 <action>/etc/init.d/lighttpd start</action>
619 </button>
620 <button>
621 <label>Stop</label>
622 <input file icon="stop"></input>
623 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
624 <action>/etc/init.d/lighttpd stop</action>
625 </button>
626 </hbox>
627 </frame>
628 '
629 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
630 tmp='<frame Samba: smbd & nmbd>
631 <hbox>
632 <text use-markup="true">
633 <label>"<b>Configuration :</b>"</label>
634 </text>
635 <entry editable="false">
636 <default>/etc/samba/smb.conf</default>
637 <variable>SMBD_CONF</variable>
638 </entry>
639 <button>
640 <input file icon="accessories-text-editor"></input>
641 <action type="lauch">leafpad $SMBD_CONF</action>
642 </button>
643 </hbox>
644 <hbox>
645 <button>
646 <label>Reload</label>
647 <input file icon="reload"></input>
648 <action>/etc/init.d/samba reload</action>
649 </button>
650 <button>
651 <label>Start</label>
652 <input file icon="forward"></input>
653 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
654 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
655 <action>/etc/init.d/samba start</action>
656 </button>
657 <button>
658 <label>Stop</label>
659 <input file icon="stop"></input>
660 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
661 <action>/etc/init.d/samba stop</action>
662 </button>
663 </hbox>
664 </frame>
665 '
666 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
667 tmp='<frame x11vnc>
668 <hbox>
669 <text use-markup="true">
670 <label>"<b>X11VNC_OPTIONS</b>"</label>
671 </text>
672 <entry editable="false">'
673 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
674 tmp2='
675 <variable>X11VNC_OPTS</variable>
676 </entry>
677 <button>
678 <input file icon="help"></input>
679 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
680 </button>
681 <button>
682 <input file icon="accessories-text-editor"></input>
683 <action type="lauch">leafpad /etc/daemons.conf</action>
684 </button>
685 </hbox>
686 <hbox>
687 <text use-markup="true">
688 <label>"<b>New password</b>"</label>
689 </text>
690 <entry>
691 <variable>X11VNC_PASSWD</variable>
692 </entry>
693 <button>
694 <input file icon="reload"></input>
695 <label>Update</label>
696 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
697 </button>
698 </hbox>
699 <hbox>
700 <button>
701 <label>Start</label>
702 <input file icon="forward"></input>
703 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
704 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
705 <action>/etc/init.d/x11vnc start</action>
706 </button>
707 <button>
708 <label>Stop</label>
709 <input file icon="stop"></input>
710 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
711 <action>/etc/init.d/x11vnc stop</action>
712 </button>
713 </hbox>
714 </frame>
715 '
716 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
717 NET_BOX="${NET_BOX}
718 </notebook>
719 "
720 tmp='<frame Iptables>
721 <hbox>
722 <text use-markup="true">
723 <label>"<b>Configuration :</b>"</label>
724 </text>
725 <entry editable="false">
726 <default>/etc/iptables.conf</default>
727 <variable>IPTABLES_CONF</variable>
728 </entry>
729 <button>
730 <input file icon="accessories-text-editor"></input>
731 <action type="lauch">leafpad $IPTABLES_CONF</action>
732 </button>
733 </hbox>
734 <hbox>
735 <button>
736 <label>Load</label>
737 <input file icon="reload"></input>
738 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
739 </button>
740 <button>
741 <label>Save</label>
742 <input file icon="go-jump"></input>
743 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
744 </button>
745 </hbox>
746 </frame>
747 '
748 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
749 tmp='
750 <frame Ether-wake>
751 <hbox>
752 <text use-markup="true">
753 <label>"<b>Machines :</b>"</label>
754 </text>
755 <entry editable="false">
756 <default>/etc/ethers</default>
757 <variable>ETHERS</variable>
758 </entry>
759 <button>
760 <input file icon="accessories-text-editor"></input>
761 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
762 <action type="lauch">leafpad $ETHERS</action>
763 </button>
764 </hbox>
765 <hbox>
766 <text use-markup="true">
767 <label>"<b>Options : </b>"</label>
768 </text>
769 <entry editable="false">
770 <variable>ETHERWAKE_OPTS</variable>
771 </entry>
772 <button>
773 <input file icon="help"></input>
774 <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>
775 </button>
776 <button>
777 <label>Start</label>
778 <input file icon="forward"></input>
779 <action>ether-wake $ETHERWAKE_OPTS</action>
780 </button>
781 </hbox>
782 </frame>
783 </notebook>
785 <hbox>
786 <button>
787 <label>Status</label>
788 <input file icon="network-wired"></input>
789 <action type="launch">IFCONFIG</action>
790 </button>
791 <button>
792 <input file icon="exit"></input>
793 <action type="exit">Exit</action>
794 </button>
795 </hbox>
797 </vbox>
798 </window>
799 '
800 NET_BOX="${NET_BOX}${tmp}"
802 export NET_BOX
804 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
806 # Only root can configure network.
807 check_root
808 gtkdialog --center --program=NET_BOX
810 exit 0