slitaz-tools view tinyutils/netbox @ rev 168

Netbox: add PHP
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun May 04 09:20:52 2008 +0000 (2008-05-04)
parents 055ada1bb408
children af16b5d7db36
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 </frame>
458 '
459 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
460 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
461 tmp='<frame Dnsd>
462 <hbox>
463 <text use-markup="true">
464 <label>"<b>DNSD_OPTIONS</b>"</label>
465 </text>
466 <entry editable="false">'
467 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
468 tmp2='
469 <variable>DNSD_OPTS</variable>
470 </entry>
471 <button>
472 <input file icon="help"></input>
473 <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>
474 </button>
475 <button>
476 <input file icon="accessories-text-editor"></input>
477 <action type="lauch">leafpad /etc/daemons.conf</action>
478 </button>
479 </hbox>
480 <hbox>
481 <text use-markup="true">
482 <label>"<b>Configuration :</b>"</label>
483 </text>
484 <entry editable="false">
485 <default>/etc/dnsd.conf</default>
486 <variable>DNSD_CONF</variable>
487 </entry>
488 <button>
489 <input file icon="accessories-text-editor"></input>
490 <action type="lauch">leafpad $DNSD_CONF</action>
491 </button>
492 </hbox>
493 <hbox>
494 <button>
495 <label>Start</label>
496 <input file icon="forward"></input>
497 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
498 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
499 <action>/etc/init.d/dnsd start</action>
500 </button>
501 <button>
502 <label>Stop</label>
503 <input file icon="stop"></input>
504 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
505 <action>/etc/init.d/dnsd stop</action>
506 </button>
507 </hbox>
508 </frame>
509 '
510 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
511 tmp='<frame Rsync>
512 <hbox>
513 <text use-markup="true">
514 <label>"<b>RSYNCD_OPTIONS</b>"</label>
515 </text>
516 <entry editable="false">'
517 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
518 tmp2='
519 <variable>RSYNC_OPTS</variable>
520 </entry>
521 <button>
522 <input file icon="help"></input>
523 <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>
524 </button>
525 <button>
526 <input file icon="accessories-text-editor"></input>
527 <action type="lauch">leafpad /etc/daemons.conf</action>
528 </button>
529 </hbox>
530 <hbox>
531 <text use-markup="true">
532 <label>"<b>Configuration :</b>"</label>
533 </text>
534 <entry editable="false">
535 <default>/etc/rsyncd.conf</default>
536 <variable>RSYNCD_CONF</variable>
537 </entry>
538 <button>
539 <input file icon="accessories-text-editor"></input>
540 <action type="lauch">leafpad $RSYNCD_CONF</action>
541 </button>
542 </hbox>
543 <hbox>
544 <text use-markup="true">
545 <label>"<b>Secrets file :</b>"</label>
546 </text>
547 <entry editable="true">
548 <default>/etc/rsyncd.secrets</default>
549 <variable>RSYNCD_SECRETS</variable>
550 </entry>
551 <button>
552 <input file icon="accessories-text-editor"></input>
553 <action type="lauch">leafpad $RSYNCD_SECRETS</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=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
561 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
562 <action>/etc/init.d/rsyncd start</action>
563 </button>
564 <button>
565 <label>Stop</label>
566 <input file icon="stop"></input>
567 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
568 <action>/etc/init.d/rsyncd stop</action>
569 </button>
570 </hbox>
571 </frame>
572 '
573 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
574 tmp='<frame Lighttpd>'
575 tmp2='<frame PHP>
576 <hbox>
577 <text use-markup="true">
578 <label>"<b>Configuration :</b>"</label>
579 </text>
580 <entry editable="false">
581 <default>/etc/php.ini</default>
582 <variable>PHP_CONF</variable>
583 </entry>
584 <button>
585 <input file icon="accessories-text-editor"></input>
586 <action type="lauch">leafpad $PHP_CONF</action>
587 </button>
588 </hbox>
589 </frame>
590 '
591 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
592 tmp2='<hbox>
593 <text use-markup="true">
594 <label>"<b>Configuration :</b>"</label>
595 </text>
596 <entry editable="false">
597 <default>/etc/lighttpd/lighttpd.conf</default>
598 <variable>LIGHTTPD_CONF</variable>
599 </entry>
600 <button>
601 <input file icon="accessories-text-editor"></input>
602 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
603 </button>
604 </hbox>
605 <hbox>
606 <button>
607 <label>Start</label>
608 <input file icon="forward"></input>
609 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
610 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
611 <action>/etc/init.d/lighttpd start</action>
612 </button>
613 <button>
614 <label>Stop</label>
615 <input file icon="stop"></input>
616 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
617 <action>/etc/init.d/lighttpd stop</action>
618 </button>
619 </hbox>
620 </frame>
621 '
622 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
623 tmp='<frame Samba: smbd & nmbd>
624 <hbox>
625 <text use-markup="true">
626 <label>"<b>Configuration :</b>"</label>
627 </text>
628 <entry editable="false">
629 <default>/etc/samba/smb.conf</default>
630 <variable>SMBD_CONF</variable>
631 </entry>
632 <button>
633 <input file icon="accessories-text-editor"></input>
634 <action type="lauch">leafpad $SMBD_CONF</action>
635 </button>
636 </hbox>
637 <hbox>
638 <button>
639 <label>Reload</label>
640 <input file icon="reload"></input>
641 <action>/etc/init.d/samba reload</action>
642 </button>
643 <button>
644 <label>Start</label>
645 <input file icon="forward"></input>
646 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
647 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
648 <action>/etc/init.d/samba start</action>
649 </button>
650 <button>
651 <label>Stop</label>
652 <input file icon="stop"></input>
653 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
654 <action>/etc/init.d/samba stop</action>
655 </button>
656 </hbox>
657 </frame>
658 '
659 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
660 tmp='<frame x11vnc>
661 <hbox>
662 <text use-markup="true">
663 <label>"<b>X11VNC_OPTIONS</b>"</label>
664 </text>
665 <entry editable="false">'
666 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
667 tmp2='
668 <variable>X11VNC_OPTS</variable>
669 </entry>
670 <button>
671 <input file icon="help"></input>
672 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
673 </button>
674 <button>
675 <input file icon="accessories-text-editor"></input>
676 <action type="lauch">leafpad /etc/daemons.conf</action>
677 </button>
678 </hbox>
679 <hbox>
680 <text use-markup="true">
681 <label>"<b>New password</b>"</label>
682 </text>
683 <entry>
684 <variable>X11VNC_PASSWD</variable>
685 </entry>
686 <button>
687 <input file icon="reload"></input>
688 <label>Update</label>
689 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
690 </button>
691 </hbox>
692 <hbox>
693 <button>
694 <label>Start</label>
695 <input file icon="forward"></input>
696 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
697 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
698 <action>/etc/init.d/x11vnc start</action>
699 </button>
700 <button>
701 <label>Stop</label>
702 <input file icon="stop"></input>
703 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
704 <action>/etc/init.d/x11vnc stop</action>
705 </button>
706 </hbox>
707 </frame>
708 '
709 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
710 NET_BOX="${NET_BOX}
711 </notebook>
712 "
713 tmp='<frame Iptables>
714 <hbox>
715 <text use-markup="true">
716 <label>"<b>Configuration :</b>"</label>
717 </text>
718 <entry editable="false">
719 <default>/etc/iptables.conf</default>
720 <variable>IPTABLES_CONF</variable>
721 </entry>
722 <button>
723 <input file icon="accessories-text-editor"></input>
724 <action type="lauch">leafpad $IPTABLES_CONF</action>
725 </button>
726 </hbox>
727 <hbox>
728 <button>
729 <label>Load</label>
730 <input file icon="reload"></input>
731 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
732 </button>
733 <button>
734 <label>Save</label>
735 <input file icon="go-jump"></input>
736 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
737 </button>
738 </hbox>
739 </frame>
740 '
741 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
742 tmp='
743 <frame Ether-wake>
744 <hbox>
745 <text use-markup="true">
746 <label>"<b>Machines :</b>"</label>
747 </text>
748 <entry editable="false">
749 <default>/etc/ethers</default>
750 <variable>ETHERS</variable>
751 </entry>
752 <button>
753 <input file icon="accessories-text-editor"></input>
754 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
755 <action type="lauch">leafpad $ETHERS</action>
756 </button>
757 </hbox>
758 <hbox>
759 <text use-markup="true">
760 <label>"<b>Options : </b>"</label>
761 </text>
762 <entry editable="false">
763 <variable>ETHERWAKE_OPTS</variable>
764 </entry>
765 <button>
766 <input file icon="help"></input>
767 <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>
768 </button>
769 <button>
770 <label>Start</label>
771 <input file icon="forward"></input>
772 <action>ether-wake $ETHERWAKE_OPTS</action>
773 </button>
774 </hbox>
775 </frame>
776 </notebook>
778 <hbox>
779 <button>
780 <label>Status</label>
781 <input file icon="network-wired"></input>
782 <action type="launch">IFCONFIG</action>
783 </button>
784 <button>
785 <input file icon="exit"></input>
786 <action type="exit">Exit</action>
787 </button>
788 </hbox>
790 </vbox>
791 </window>
792 '
793 NET_BOX="${NET_BOX}${tmp}"
795 export NET_BOX
797 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
799 # Only root can configure network.
800 check_root
801 gtkdialog --center --program=NET_BOX
803 exit 0