slitaz-tools view tinyutils/netbox @ rev 194

netbox: use the nice new icon... and have a Help dialog
author Christophe Lincoln <pankso@slitaz.org>
date Fri May 16 00:55:24 2008 +0200 (2008-05-16)
parents 6821317846d5
children d95c13d35c0a
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 set_ipup()
20 {
21 [ -f /etc/ppp/ip-up ] && return
22 cat > /etc/ppp/ip-up <<EOT
23 #!/bin/sh
24 exec $0 call ipup \$@
25 EOT
26 chmod +x /etc/ppp/ip-up
27 }
29 if [ "$1" = "call" ]; then
30 ppp="pppd local lock notty"
31 pppup=""
32 sub=$2
33 shift 2
34 case "$sub" in
35 sendsshkey)
36 check_root
37 dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key | \
38 grep ^ssh | ssh $1 "mkdir .ssh 2> /dev/null ; while read key; do for i in authorized_keys authorized_keys2; do grep -q \$key .ssh/\$i || echo \$key >> .ssh/\$i; done; done; chmod 700 .ssh ; chmod 600 .ssh/authorized_keys*"
39 exit 0;;
40 vpnssh) check_root
41 set_ipup
42 ps ww | grep -q "$ppp $2:$3" && exit 1
43 pipe="/tmp/ssh$$"
44 mkfifo $pipe
45 [ -n "$4" ] && pppup="ipparam 'addroutes,$(echo $4 | sed 's/ /,/g')'"
46 cat $pipe | dbclient -i /etc/dropbear/dropbear_rsa_host_key \
47 $1 "$ppp" | $ppp $2:$3 $pppup > $pipe
48 rm -f $pipe
49 exit 0;;
50 killvpnssh)
51 check_root
52 kill $(ps x | grep dbclient | grep "$ppp" | awk '{ print $1 }')
53 exit 0;;
54 ipup)
55 # Arg Name Example
56 # $1 Interface name ppp0
57 # $2 The tty ttyS1
58 # $3 The link speed 38400
59 # $4 Local IP number 12.34.56.78
60 # $5 Peer IP number 12.34.56.99
61 # $6 Optional ``ipparam'' value foo
62 iface=$1
63 # skip tty if present
64 case "$2" in [0-9]*);; *) shift; esac
65 peer=$4
66 IFS=","; set -- $(eval echo $5); unset IFS
67 set -- $1
68 if [ "$1" = "addroutes" ]; then
69 while [ -n "$2" ]; do
70 eval $(ipcalc -n $2)
71 eval $(ipcalc -m $2)
72 route add -net $NETWORK netmask $NETMASK \
73 gw $peer $iface
74 shift
75 done
76 fi
77 exit 0;;
78 esac
79 echo "call $sub unsupported."
80 exit 1
81 fi
83 # English/French help dialod.
84 export HELP='
85 <window title="Network status" icon-name="network-wire">
86 <vbox>
87 <text use-markup="true">
88 <label>"
89 <b>SliTaz - Netbox</b>"
90 </label>
91 </text>
92 <frame English>
93 <text wrap="true" width-chars="58">
94 <label>
95 "Netbox let you manage network connections getting dynamic IP by DHCP
96 or static IP, and setup servers. Netbox can start or stop networking,
97 configure network interfaces or directly edit files. Wifi users may
98 configure System wide / Network."
99 </label>
100 </text>
101 </frame>
102 </vbox>
103 </window>
104 '
106 # Interafce status with ifconfig without arguments to show all
107 # active connections.
108 #
109 export IFCONFIG='
110 <window title="Network status" icon-name="network-wire">
111 <vbox>
112 <text wrap="false">
113 <input>date</input>
114 </text>
115 <notebook labels="Network interfaces'
116 [ -x /usr/sbin/iwlist ] && IFCONFIG="$IFCONFIG|Wireless interfaces|Wireless networks"
117 tmp='|Routing|Servers">
118 <frame Ifconfig>
119 <text wrap="false" width-chars="58">
120 <input>ifconfig</input>
121 </text>
122 </frame>'
123 IFCONFIG="$IFCONFIG$tmp"
124 tmp='<frame Iwconfig>
125 <text wrap="false" width-chars="58">
126 <input>iwconfig</input>
127 </text>
128 </frame>
129 <frame Wireless networks>
130 <text wrap="false" width-chars="58">
131 <input>iwlist scan</input>
132 </text>
133 </frame>'
134 [ -x /usr/sbin/iwlist ] && IFCONFIG="$IFCONFIG$tmp"
135 tmp='<frame Routing>
136 <frame Nameservers>
137 <text wrap="false" width-chars="58">
138 <input>cat /etc/resolv.conf</input>
139 </text>
140 </frame>
141 <frame Routing table>
142 <text wrap="false" width-chars="58">
143 <input>route</input>
144 </text>
145 </frame>
146 <frame Arp table>
147 <text wrap="false" width-chars="58">
148 <input>arp</input>
149 </text>
150 </frame>
151 </frame>
152 <frame Servers>
153 <text wrap="false" width-chars="58">
154 <input>for i in dropbear inetd udhcpd dnsd rsync lighttpd smbd nmbd x11vnc pppd; do ps ww | grep $i | grep -v grep | fold -s; done</input>
155 </text>
156 </frame>
157 </notebook>
158 <hbox>
159 <button>
160 <input file icon="gtk-close"></input>
161 <action type="closewindow">IFCONFIG</action>
162 </button>
163 </hbox>
164 </vbox>
165 </window>
166 '
167 IFCONFIG="$IFCONFIG$tmp"
169 # The main dialog with notebook, start/stop buttons and all options.
170 # Note than /etc/network.conf is seded wehwn an interafce is activate
171 #
172 NET_BOX='
173 <window title="SliTaz Netbox Manager" icon-name="network-wired">
174 <vbox>
176 <hbox>
177 <text use-markup="true">
178 <label>"<b>Network/Server Manager</b>"</label>
179 </text>
180 <pixmap>
181 <input file>/usr/share/pixmaps/netbox.png</input>
182 </pixmap>
183 </hbox>
185 <frame General>
186 <hbox>
187 <text use-markup="true">
188 <label>"<b>Interface :</b>"</label>
189 </text>
190 <entry>
191 <input>. /etc/network.conf; echo $INTERFACE</input>
192 <variable>INTERFACE</variable>
193 </entry>
194 </hbox>
195 </frame>
197 <notebook labels="DHCP|PPPoE|Static IP|System wide|VPN|Servers'
198 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX|Firewall"
199 tmp='|Etherwake">
201 <frame Udhcpc>
202 <hbox>
203 <text use-markup="true">
204 <label>"<b>Options :</b>"</label>
205 </text>
206 <entry>
207 <default>-b</default>
208 <variable>UDHCPC_OPTS</variable>
209 </entry>
210 <button>
211 <input file icon="help"></input>
212 <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>
213 </button>
214 </hbox>
215 <hbox>
216 <button>
217 <label>Start</label>
218 <input file icon="forward"></input>
219 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
220 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
221 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
222 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
223 </button>
224 <button>
225 <label>Stop</label>
226 <input file icon="stop"></input>
227 <action>echo -n "Stopping interface : $INTERFACE... "</action>
228 <action>ifconfig $INTERFACE down</action>
229 <action>killall -q udhcpc; echo "done"</action>
230 </button>
231 </hbox>
232 </frame>
234 <frame PPPoE>
235 <hbox>
236 <text use-markup="true">
237 <label>"<b>Name :</b>"</label>
238 </text>
239 <entry>
240 <input>NAME=$(grep -s ^name /etc/ppp/options); echo "${NAME#* }"</input>
241 <variable>NAME</variable>
242 </entry>
243 </hbox>
244 <hbox>
245 <text use-markup="true">
246 <label>"<b>Username :</b>"</label>
247 </text>
248 <entry>
249 <variable>USER</variable>
250 </entry>
251 </hbox>
252 <hbox>
253 <text use-markup="true">
254 <label>"<b>Password :</b>"</label>
255 </text>
256 <entry>
257 <variable>USER</variable>
258 </entry>
259 </hbox>
260 <hbox>
261 <button>
262 <input file icon="accessories-text-editor"></input>
263 <label>Tune</label>
264 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
265 <action type="lauch">leafpad /etc/ppp/options</action>
266 </button>
267 <button>
268 <label>Start</label>
269 <input file icon="forward"></input>
270 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
271 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
272 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
273 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
274 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
275 <action>killall udhcpc</action>
276 <action>sed -i "s/DHCP=\"yes\"/DHCP=\"no\"/" /etc/network.conf</action>
277 <action>sed -i "s/PPPOE=\"no\"/PPPOE=\"yes\"/" /etc/network.conf</action>
278 <action>pppd $INTERFACE &</action>
279 </button>
280 <button>
281 <label>Stop</label>
282 <input file icon="stop"></input>
283 <action>sed -i "s/PPPOE=\"yes\"/PPPOE=\"no\"/" /etc/network.conf</action>
284 <action>killall pppd</action>
285 </button>
286 </hbox>
287 </frame>
289 <frame Configuration>
290 <hbox>
291 <text use-markup="true">
292 <label>"<b>IP :</b>"</label>
293 </text>
294 <entry>
295 <input>. /etc/network.conf; echo "$IP"</input>
296 <variable>IP</variable>
297 </entry>
298 </hbox>
299 <hbox>
300 <text use-markup="true">
301 <label>"<b>Netmask :</b>"</label>
302 </text>
303 <entry>
304 <input>. /etc/network.conf; echo "$NETMASK"</input>
305 <variable>NETMASK</variable>
306 </entry>
307 </hbox>
308 <hbox>
309 <text use-markup="true">
310 <label>"<b>Gateway :</b>"</label>
311 </text>
312 <entry>
313 <input>. /etc/network.conf; echo "$GATEWAY"</input>
314 <variable>GATEWAY</variable>
315 </entry>
316 </hbox>
317 <hbox>
318 <text use-markup="true">
319 <label>"<b>DNS server :</b>"</label>
320 </text>
321 <entry>
322 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
323 <variable>DNS_SERVER</variable>
324 </entry>
325 </hbox>
326 <hbox>
327 <button>
328 <label>Start</label>
329 <input file icon="forward"></input>
330 <action>ifconfig lo down</action>
331 <action>ifconfig $INTERFACE down</action>
332 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
333 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
334 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
335 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
336 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
337 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
338 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
339 <action>/etc/init.d/network.sh</action>
340 </button>
341 <button>
342 <label>Stop</label>
343 <input file icon="stop"></input>
344 <action>echo -n "Stopping interface : $INTERFACE... "</action>
345 <action>ifconfig $INTERFACE down; echo "done"</action>
346 </button>
347 </hbox>
348 </frame>
350 <frame Configuration files>
351 <hbox>
352 <text use-markup="true">
353 <label>"<b>Hosts :</b>"</label>
354 </text>
355 <entry editable="false">
356 <default>/etc/hosts</default>
357 <variable>HOSTS</variable>
358 </entry>
359 <button>
360 <input file icon="accessories-text-editor"></input>
361 <action type="lauch">leafpad $HOSTS</action>
362 </button>
363 </hbox>
364 <hbox>
365 <text use-markup="true">
366 <label>"<b>Host name :</b>"</label>
367 </text>
368 <entry editable="false">
369 <default>/etc/hostname</default>
370 <variable>HOSTNAME</variable>
371 </entry>
372 <button>
373 <input file icon="accessories-text-editor"></input>
374 <action type="lauch">leafpad $HOSTNAME</action>
375 </button>
376 </hbox>
377 <hbox>
378 <text use-markup="true">
379 <label>"<b>Network :</b>"</label>
380 </text>
381 <entry editable="false">
382 <default>/etc/network.conf</default>
383 <variable>CONFIG_FILE</variable>
384 </entry>
385 <button>
386 <input file icon="accessories-text-editor"></input>
387 <action type="lauch">leafpad $CONFIG_FILE</action>
388 </button>
389 </hbox>
390 <hbox>
391 <button>
392 <label>Restart</label>
393 <input file icon="reload"></input>
394 <action>echo -n "Stopping interface : $INTERFACE... "</action>
395 <action>ifconfig lo down</action>
396 <action>ifconfig $INTERFACE down</action>
397 <action>killall -q udhcpc; echo "done"</action>
398 <action>/etc/init.d/network.sh</action>
399 </button>
400 </hbox>
401 </frame>
403 <frame Virtual Private Network with PPP/SSH>
404 <hbox>
405 <text use-markup="true">
406 <label>"<b>Peer :</b>"</label>
407 </text>
408 <entry>
409 <variable>DROPBEAR_PEERVPN</variable>
410 <default>user@elsewhere</default>
411 </entry>
412 </hbox>
413 <hbox>
414 <text use-markup="true">
415 <label>"<b>Local IP :</b>"</label>
416 </text>
417 <entry>
418 <variable>DROPBEAR_LOCAL</variable>
419 <default>192.168.254.1</default>
420 </entry>
421 </hbox>
422 <hbox>
423 <text use-markup="true">
424 <label>"<b>Remote IP :</b>"</label>
425 </text>
426 <entry>
427 <variable>DROPBEAR_REMOTE</variable>
428 <default>192.168.254.2</default>
429 </entry>
430 </hbox>
431 <hbox>
432 <text use-markup="true">
433 <label>"<b>Route(s) :</b>"</label>
434 </text>
435 <entry>
436 <variable>DROPBEAR_ROUTE</variable>
437 <default>192.168.10.0/24 192.168.20.0/28</default>
438 </entry>
439 </hbox>
440 <hbox>
441 <button>
442 <input file icon="forward"></input>
443 <label>Connect</label>
444 <action>netbox call vpnssh $DROPBEAR_PEERVPN $DROPBEAR_LOCAL $DROPBEAR_REMOTE "$DROPBEAR_ROUTE" &</action>
445 </button>
446 <button>
447 <input file icon="stop"></input>
448 <label>Disconnect</label>
449 <action>netbox call killvpnssh</action>
450 </button>
451 <button>
452 <input file icon="go-up"></input>
453 <label>Send key</label>
454 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x10 -title "dropbear help" -e "netbox call sendsshkey $DROPBEAR_PEERVPN; echo -e \"----\nENTER to continue...\" && read close"</action>
455 </button>
456 </hbox>
457 </frame>
458 <notebook labels="'
459 NET_BOX="$NET_BOX$tmp"
460 tmp=''
461 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH" && tmp='|'
462 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}INETD" && tmp='|'
463 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}DHCP" && tmp='|'
464 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
465 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] \
466 && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
467 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
468 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
469 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
470 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
471 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}VNC" && tmp='|'
472 . /etc/daemons.conf
473 set -- $DROPBEAR_OPTIONS
474 while [ -n "$2" ]; do
475 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
476 shift
477 done
478 NET_BOX="${NET_BOX}\">"
479 tmp='<frame Dropbear>
480 <hbox>
481 <text use-markup="true">
482 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
483 </text>
484 <entry editable="false">'
485 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
486 tmp2='
487 <variable>DROPBEAR_OPTS</variable>
488 </entry>
489 <button>
490 <input file icon="help"></input>
491 <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>
492 </button>
493 <button>
494 <input file icon="accessories-text-editor"></input>
495 <action type="lauch">leafpad /etc/daemons.conf</action>
496 </button>
497 </hbox>
498 <hbox>
499 <text use-markup="true">
500 <label>"<b>Banner :</b>"</label>
501 </text>
502 <entry editable="false">'
503 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
504 tmp2='
505 <variable>DROPBEAR_BANNER</variable>
506 </entry>
507 <button>
508 <input file icon="accessories-text-editor"></input>
509 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
510 </button>
511 </hbox>
512 <hbox>
513 <text use-markup="true">
514 <label>"<b>Remote :</b>"</label>
515 </text>
516 <entry>
517 <variable>DROPBEAR_PEER</variable>
518 <default>user@elsewhere</default>
519 </entry>
520 <button>
521 <input file icon="utilities-terminal"></input>
522 <label>Connect</label>
523 <action>xterm -fa MiscFixed -fs 11 -bg black -fg white -geometry 80x25 -title "$DROPBEAR_PEER" -e "dbclient -i /etc/dropbear/dropbear_rsa_host_key $DROPBEAR_PEER ; echo -e \"----\nENTER to continue...\" && read close" &</action>
524 </button>
525 <button>
526 <input file icon="go-up"></input>
527 <label>Send key</label>
528 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x10 -title "dropbear help" -e "netbox call sendsshkey $DROPBEAR_PEER; echo -e \"----\nENTER to continue...\" && read close"</action>
529 </button>
530 </hbox>
531 <hbox>
532 <button>
533 <label>Start</label>
534 <input file icon="forward"></input>
535 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
536 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
537 <action>/etc/init.d/dropbear start</action>
538 </button>
539 <button>
540 <label>Stop</label>
541 <input file icon="stop"></input>
542 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
543 <action>/etc/init.d/dropbear stop</action>
544 </button>
545 </hbox>
546 </frame>
547 '
548 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
549 tmp='<frame Inetd>
550 <hbox>
551 <text use-markup="true">
552 <label>"<b>INETD_OPTIONS</b>"</label>
553 </text>
554 <entry editable="false">'
555 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
556 tmp2='
557 <variable>INETD_OPTS</variable>
558 </entry>
559 <button>
560 <input file icon="help"></input>
561 <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>
562 </button>
563 <button>
564 <input file icon="accessories-text-editor"></input>
565 <action type="lauch">leafpad /etc/daemons.conf</action>
566 </button>
567 </hbox>
568 <hbox>
569 <text use-markup="true">
570 <label>"<b>Configuration :</b>"</label>
571 </text>
572 <entry editable="false">
573 <default>/etc/inetd.conf</default>
574 <variable>INETD_CONF</variable>
575 </entry>
576 <button>
577 <input file icon="accessories-text-editor"></input>
578 <action type="lauch">leafpad $INETD_CONF</action>
579 </button>
580 </hbox>
581 <hbox>
582 '
583 tmp="$tmp$tmp2"
584 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
585 i=$(basename $i)
586 tmp2="
587 <button>
588 <input file icon=\"help\"></input>
589 <label>$i</label>
590 <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>
591 </button>
592 "
593 tmp="$tmp$tmp2"
594 done
595 tmp2='
596 <button>
597 <label>Start</label>
598 <input file icon="forward"></input>
599 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
600 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
601 <action>/etc/init.d/inetd start</action>
602 </button>
603 <button>
604 <label>Stop</label>
605 <input file icon="stop"></input>
606 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
607 <action>/etc/init.d/inetd stop</action>
608 </button>
609 </hbox>
610 </frame>
611 '
612 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
613 tmp='<frame Dhcpd>
614 <hbox>
615 <text use-markup="true">
616 <label>"<b>UDHCPD_OPTIONS</b>"</label>
617 </text>
618 <entry editable="false">'
619 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
620 tmp2='
621 <variable>UDHCPD_OPTS</variable>
622 </entry>
623 <button>
624 <input file icon="help"></input>
625 <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>
626 </button>
627 <button>
628 <input file icon="accessories-text-editor"></input>
629 <action type="lauch">leafpad /etc/daemons.conf</action>
630 </button>
631 </hbox>
632 <hbox>
633 <text use-markup="true">
634 <label>"<b>Configuration :</b>"</label>
635 </text>
636 <entry editable="false">
637 <default>/etc/udhcpd.conf</default>
638 <variable>UDHCPD_CONF</variable>
639 </entry>
640 <button>
641 <input file icon="accessories-text-editor"></input>
642 <action type="lauch">leafpad $UDHCPD_CONF</action>
643 </button>
644 </hbox>
645 <hbox>
646 <button>
647 <label>Start</label>
648 <input file icon="forward"></input>
649 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
650 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
651 <action>/etc/init.d/udhcpd start</action>
652 </button>
653 <button>
654 <label>Stop</label>
655 <input file icon="stop"></input>
656 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
657 <action>/etc/init.d/udhcpd stop</action>
658 </button>
659 </hbox>
660 </frame>
661 '
662 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
663 tmp='<frame Pxelinux>
664 <hbox>
665 <text wrap="true">
666 <label>
667 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
668 </label>
669 </text>
670 </hbox>
671 <hbox>
672 <text use-markup="true">
673 <label>"<b>Configuration :</b>"</label>
674 </text>
675 <entry editable="false">
676 <default>'
677 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
678 tmp2='/pxelinux.cfg/default</default>
679 <variable>PXE_CONF</variable>
680 </entry>
681 <button>
682 <input file icon="accessories-text-editor"></input>
683 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
684 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
685 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
686 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
687 <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>
688 <action type="lauch">leafpad $PXE_CONF</action>
689 </button>
690 </hbox>
691 <hbox>
692 <button>
693 <input file icon="system-file-manager"></input>
694 <label>Network boot files</label>
695 <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>
696 </button>
697 </hbox>
698 </frame>
699 '
700 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
701 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
702 tmp='<frame Dnsd>
703 <hbox>
704 <text use-markup="true">
705 <label>"<b>DNSD_OPTIONS</b>"</label>
706 </text>
707 <entry editable="false">'
708 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
709 tmp2='
710 <variable>DNSD_OPTS</variable>
711 </entry>
712 <button>
713 <input file icon="help"></input>
714 <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>
715 </button>
716 <button>
717 <input file icon="accessories-text-editor"></input>
718 <action type="lauch">leafpad /etc/daemons.conf</action>
719 </button>
720 </hbox>
721 <hbox>
722 <text use-markup="true">
723 <label>"<b>Configuration :</b>"</label>
724 </text>
725 <entry editable="false">
726 <default>/etc/dnsd.conf</default>
727 <variable>DNSD_CONF</variable>
728 </entry>
729 <button>
730 <input file icon="accessories-text-editor"></input>
731 <action type="lauch">leafpad $DNSD_CONF</action>
732 </button>
733 </hbox>
734 <hbox>
735 <button>
736 <label>Start</label>
737 <input file icon="forward"></input>
738 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
739 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
740 <action>/etc/init.d/dnsd start</action>
741 </button>
742 <button>
743 <label>Stop</label>
744 <input file icon="stop"></input>
745 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
746 <action>/etc/init.d/dnsd stop</action>
747 </button>
748 </hbox>
749 </frame>
750 '
751 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
752 tmp='<frame Rsync>
753 <hbox>
754 <text use-markup="true">
755 <label>"<b>RSYNCD_OPTIONS</b>"</label>
756 </text>
757 <entry editable="false">'
758 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
759 tmp2='
760 <variable>RSYNC_OPTS</variable>
761 </entry>
762 <button>
763 <input file icon="help"></input>
764 <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>
765 </button>
766 <button>
767 <input file icon="accessories-text-editor"></input>
768 <action type="lauch">leafpad /etc/daemons.conf</action>
769 </button>
770 </hbox>
771 <hbox>
772 <text use-markup="true">
773 <label>"<b>Configuration :</b>"</label>
774 </text>
775 <entry editable="false">
776 <default>/etc/rsyncd.conf</default>
777 <variable>RSYNCD_CONF</variable>
778 </entry>
779 <button>
780 <input file icon="accessories-text-editor"></input>
781 <action type="lauch">leafpad $RSYNCD_CONF</action>
782 </button>
783 </hbox>
784 <hbox>
785 <text use-markup="true">
786 <label>"<b>Secrets file :</b>"</label>
787 </text>
788 <entry editable="true">
789 <default>/etc/rsyncd.secrets</default>
790 <variable>RSYNCD_SECRETS</variable>
791 </entry>
792 <button>
793 <input file icon="accessories-text-editor"></input>
794 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
795 </button>
796 </hbox>
797 <hbox>
798 <button>
799 <label>Start</label>
800 <input file icon="forward"></input>
801 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
802 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
803 <action>/etc/init.d/rsyncd start</action>
804 </button>
805 <button>
806 <label>Stop</label>
807 <input file icon="stop"></input>
808 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
809 <action>/etc/init.d/rsyncd stop</action>
810 </button>
811 </hbox>
812 </frame>
813 '
814 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
815 tmp='<frame Lighttpd>'
816 tmp2='<frame PHP>
817 <hbox>
818 <text use-markup="true">
819 <label>"<b>Configuration :</b>"</label>
820 </text>
821 <entry editable="false">
822 <default>/etc/php.ini</default>
823 <variable>PHP_CONF</variable>
824 </entry>
825 <button>
826 <input file icon="accessories-text-editor"></input>
827 <action type="lauch">leafpad $PHP_CONF</action>
828 </button>
829 </hbox>
830 </frame>
831 '
832 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
833 tmp2='<hbox>
834 <text use-markup="true">
835 <label>"<b>Configuration :</b>"</label>
836 </text>
837 <entry editable="false">
838 <default>/etc/lighttpd/lighttpd.conf</default>
839 <variable>LIGHTTPD_CONF</variable>
840 </entry>
841 <button>
842 <input file icon="accessories-text-editor"></input>
843 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
844 </button>
845 </hbox>
846 <hbox>
847 <button>
848 <label>Start</label>
849 <input file icon="forward"></input>
850 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
851 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
852 <action>/etc/init.d/lighttpd start</action>
853 </button>
854 <button>
855 <label>Stop</label>
856 <input file icon="stop"></input>
857 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
858 <action>/etc/init.d/lighttpd stop</action>
859 </button>
860 </hbox>
861 </frame>
862 '
863 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
864 tmp='<frame Samba: smbd & nmbd>
865 <hbox>
866 <text use-markup="true">
867 <label>"<b>Configuration :</b>"</label>
868 </text>
869 <entry editable="false">
870 <default>/etc/samba/smb.conf</default>
871 <variable>SMBD_CONF</variable>
872 </entry>
873 <button>
874 <input file icon="accessories-text-editor"></input>
875 <action type="lauch">leafpad $SMBD_CONF</action>
876 </button>
877 </hbox>
878 <hbox>
879 <button>
880 <label>Reload</label>
881 <input file icon="reload"></input>
882 <action>/etc/init.d/samba reload</action>
883 </button>
884 <button>
885 <label>Start</label>
886 <input file icon="forward"></input>
887 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
888 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
889 <action>/etc/init.d/samba start</action>
890 </button>
891 <button>
892 <label>Stop</label>
893 <input file icon="stop"></input>
894 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
895 <action>/etc/init.d/samba stop</action>
896 </button>
897 </hbox>
898 </frame>
899 '
900 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
901 tmp='<frame x11vnc>
902 <hbox>
903 <text use-markup="true">
904 <label>"<b>X11VNC_OPTIONS</b>"</label>
905 </text>
906 <entry editable="false">'
907 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
908 tmp2='
909 <variable>X11VNC_OPTS</variable>
910 </entry>
911 <button>
912 <input file icon="help"></input>
913 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
914 </button>
915 <button>
916 <input file icon="accessories-text-editor"></input>
917 <action type="lauch">leafpad /etc/daemons.conf</action>
918 </button>
919 </hbox>
920 <hbox>
921 <text use-markup="true">
922 <label>"<b>New password</b>"</label>
923 </text>
924 <entry>
925 <variable>X11VNC_PASSWD</variable>
926 </entry>
927 <button>
928 <input file icon="reload"></input>
929 <label>Update</label>
930 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
931 </button>
932 </hbox>
933 <hbox>
934 <button>
935 <label>Start</label>
936 <input file icon="forward"></input>
937 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
938 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
939 <action>/etc/init.d/x11vnc start</action>
940 </button>
941 <button>
942 <label>Stop</label>
943 <input file icon="stop"></input>
944 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
945 <action>/etc/init.d/x11vnc stop</action>
946 </button>
947 </hbox>
948 </frame>
949 '
950 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
951 NET_BOX="${NET_BOX}
952 </notebook>
953 "
954 tmp='<frame Iptables>
955 <hbox>
956 <text use-markup="true">
957 <label>"<b>Configuration :</b>"</label>
958 </text>
959 <entry editable="false">
960 <default>/etc/iptables.conf</default>
961 <variable>IPTABLES_CONF</variable>
962 </entry>
963 <button>
964 <input file icon="accessories-text-editor"></input>
965 <action type="lauch">leafpad $IPTABLES_CONF</action>
966 </button>
967 </hbox>
968 <hbox>
969 <button>
970 <label>Load</label>
971 <input file icon="reload"></input>
972 <action>cat $IPTABLES_CONF | /sbin/iptables-restore</action>
973 </button>
974 <button>
975 <label>Save</label>
976 <input file icon="go-jump"></input>
977 <action>/sbin/iptables-save > $IPTABLES_CONF</action>
978 </button>
979 </hbox>
980 </frame>
981 '
982 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
983 tmp='
984 <frame Ether-wake>
985 <hbox>
986 <text use-markup="true">
987 <label>"<b>Machines :</b>"</label>
988 </text>
989 <entry editable="false">
990 <default>/etc/ethers</default>
991 <variable>ETHERS</variable>
992 </entry>
993 <button>
994 <input file icon="accessories-text-editor"></input>
995 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
996 <action type="lauch">leafpad $ETHERS</action>
997 </button>
998 </hbox>
999 <hbox>
1000 <text use-markup="true">
1001 <label>"<b>Options : </b>"</label>
1002 </text>
1003 <entry editable="false">
1004 <variable>ETHERWAKE_OPTS</variable>
1005 </entry>
1006 <button>
1007 <input file icon="help"></input>
1008 <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>
1009 </button>
1010 <button>
1011 <label>Start</label>
1012 <input file icon="forward"></input>
1013 <action>ether-wake $ETHERWAKE_OPTS</action>
1014 </button>
1015 </hbox>
1016 </frame>
1017 </notebook>
1019 <hbox>
1020 <button>
1021 <label>Status</label>
1022 <input file icon="dialog-information"></input>
1023 <action type="launch">IFCONFIG</action>
1024 </button>
1025 <button help>
1026 <label>Help</label>
1027 <action type="launch">HELP</action>
1028 </button>
1029 <button>
1030 <label>Quit</label>
1031 <input file icon="exit"></input>
1032 <action type="exit">Exit</action>
1033 </button>
1034 </hbox>
1036 </vbox>
1037 </window>
1039 NET_BOX="${NET_BOX}${tmp}"
1041 export NET_BOX
1043 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
1045 # Only root can configure network.
1046 check_root
1047 # Configure and connect if button Connect was pressed.
1048 if ! grep -qs ^name /etc/ppp/options ; then
1049 # Generate /etc/ppp/options
1050 cat > /etc/ppp/options << _EOT_
1051 plugin rp-pppoe.so
1052 name provider-ID
1053 noipdefault
1054 defaultroute
1055 mtu 1492
1056 mru 1492
1057 lock
1058 _EOT_
1059 # Generate /etc/ppp/pap-secrets
1060 cat > /etc/ppp/pap-secrets << _EOT_
1061 # Secrets for authentication using PAP
1062 # client server secret IP addresses
1063 _EOT_
1064 # Generate /etc/ppp/chap-secrets
1065 cat > /etc/ppp/chap-secrets << _EOT_
1066 # Secrets for authentication using CHAP
1067 # client server secret IP addresses
1068 _EOT_
1069 fi
1070 gtkdialog --center --program=NET_BOX
1072 exit 0