slitaz-tools view tinyutils/netbox @ rev 373

netbox: add dnsmasq support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Aug 12 13:22:54 2009 +0200 (2009-08-12)
parents a4f46bd9f1f3
children f42ec52d7e54
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box to manage network connections and servers.
4 # Please use tab to indent.
5 #
6 # (c) - SliTaz GNU/Linux 2009.
7 #
8 VERSION=20090812
10 # Check if user is root.
11 check_root()
12 {
13 if test $(id -u) != 0 ; then
14 echo -e "
15 You must be root to run `basename $0`. Please type 'su' and
16 root password to become super-user.\n"
17 exit 0
18 fi
19 }
21 #
22 # Functions called by the connection tab to list interfaces.
23 #
24 ############################################################
26 interface_status()
27 {
28 if ifconfig | grep -A 1 $i | grep -q inet; then
29 ip=`ifconfig | grep -A 1 $i | grep inet | awk '{ print $2 }' | cut -d ":" -f 2`
30 echo "connected ($ip)"
31 else
32 echo "-"
33 fi
34 }
35 # First column is for icon name.
36 detect_interfaces()
37 {
38 for i in `ls /sys/class/net`
39 do
40 case $i in
41 eth*)
42 echo "network-wired | $i | Ethernet | `interface_status`" ;;
43 wlan*|ath*|ra*)
44 echo "network-wireless | $i | Wireless | `interface_status`" ;;
45 lo)
46 echo "gtk-network | $i | Loopback | `interface_status`" ;;
47 *)
48 continue ;;
49 esac
51 done
52 }
54 # When users double click on a connection.
55 interfaces_List_actions()
56 {
57 echo "$INTERFACE_LIST"
58 }
60 # Netbox can be called with args.
61 case "$1" in
62 detect_interfaces|interfaces_List_actions)
63 $1
64 exit 0 ;;
65 *)
66 continue ;;
67 esac
69 #
70 # GUI functions
71 #
72 ############################################################
74 xterm="xterm -fa MiscFixed -fs 11 -bg gray93 -fg black"
75 helpbutton()
76 {
77 local label;
78 label="<label>$3</label>"
79 [ -n "$3" ] || label=""
80 cat << EOT
81 <button>
82 <input file icon="help"></input>$label
83 <action>$xterm -geometry $2 -title "$1 help (q to quit)" -e "$(which $1) --help 2>&1 | less"</action>
84 </button>
85 EOT
86 }
88 editbutton()
89 {
90 cat << EOT
91 <button>
92 <input file icon="accessories-text-editor"></input>
93 <action type="lauch">leafpad $1</action>
94 </button>
95 EOT
96 }
98 manbutton()
99 {
100 cat << EOT
101 <button>
102 <input file icon="browser"></input>
103 <label>man</label>
104 <action>$xterm -geometry 80x24 -title "$2 man (q to quit)" -e ". /etc/profile; man $1 $2"</action>
105 </button>
106 EOT
107 }
109 helpdaemon()
110 {
111 cat << EOT
112 <hbox>
113 <text use-markup="true">
114 <label>"<b>$3</b>"</label>
115 </text>
116 <entry editable="false">
117 EOT
118 eval tmp=\$$3
119 [ -n "$tmp" ] && cat << EOT
120 <default>$tmp</default>
121 EOT
122 cat << EOT
123 <variable>$4</variable>
124 </entry>
125 EOT
126 [ -n "$6" ] || cat << EOT
127 $(helpbutton $1 $2)
128 EOT
129 [ -n "$5" ] && cat << EOT
130 $(manbutton $5 $1)
131 EOT
132 cat << EOT
133 $(editbutton /etc/daemons.conf)
134 </hbox>
135 EOT
136 }
138 datafile()
139 {
140 cat << EOT
141 <hbox>
142 <text use-markup="true">
143 <label>"<b>$3</b>"</label>
144 </text>
145 <entry editable="false">
146 EOT
147 [ -n "$1" ] && cat << EOT
148 <default>$1</default>
149 EOT
150 cat << EOT
151 <variable>$2</variable>
152 </entry>
153 EOT
154 [ -n "$4" ] && cat << EOT
155 $(manbutton $4)
156 EOT
157 cat << EOT
158 $(editbutton \$$2)
159 </hbox>
160 EOT
161 }
163 configfile()
164 {
165 datafile "$1" $2 'Configuration:' "$3"
166 }
168 BROWSER=''
169 for i in firefox opera dillo midori netsurf links ; do
170 which $i > /dev/null && BROWSER="$i" && break
171 done
172 case "$BROWSER" in
173 links) BROWSER="links -g ";;
174 esac
176 webbutton()
177 {
178 [ -f "/var/lib/tazpkg/installed/$1/receipt" ] &&
179 [ -n "$BROWSER" ] && cat << EOT
180 <button>
181 <input file icon="browser"></input>
182 <label>web</label>
183 <action>. /var/lib/tazpkg/installed/$1/receipt ; $BROWSER \$WEB_SITE &</action>
184 </button>
185 EOT
186 }
188 wikibutton()
189 {
190 [ -n "$BROWSER" ] && cat <<EOT
191 <button>
192 <input file icon="browser"></input>
193 <label>Wiki</label>
194 <action>$BROWSER $1 &</action>
195 </button>
196 EOT
197 }
199 startstopdaemon()
200 {
201 local pkg
202 pkg=$1
203 [ -n "$2" ] && pkg=$2
204 webbutton $pkg
205 cat << EOT
206 <button>
207 <label>Start</label>
208 <input file icon="forward"></input>
209 <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)$1 \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
210 <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)\\"/RUN_DAEMONS=\\"$1 \1\\"/" /etc/rcS.conf</action>
211 <action>/etc/init.d/$1 start</action>
212 </button>
213 <button>
214 <label>Stop</label>
215 <input file icon="stop"></input>
216 <action>sed -i "s/RUN_DAEMONS=\\"\\(.*\\)$1 \?\\(.*\\)\\"/RUN_DAEMONS=\\"\1\2\\"/" /etc/rcS.conf</action>
217 <action>/etc/init.d/$1 stop</action>
218 </button>
219 EOT
220 }
222 installbox()
223 {
224 cat << EOT
225 <hbox>
226 <text wrap="true" use-markup="true">
227 <label>"<i>The package <b>$1</b> is not yet installed</i>"</label>
228 </text>
229 <button>
230 <input file icon="go-jump"></input>
231 <label>Install</label>
232 <action>$xterm -geometry 80x17 -title "$1 install" -e "yes y | tazpkg get-install $1 ; echo -e \"----\n\nENTER to continue...\" && read close"</action>
233 <action type="exit">restart</action>
234 </button>
235 </hbox>
236 EOT
237 }
239 set_ipup()
240 {
241 [ -f /etc/ppp/ip-up ] && return
242 cat > /etc/ppp/ip-up <<EOT
243 #!/bin/sh
244 exec $0 call ipup \$@
245 EOT
246 chmod +x /etc/ppp/ip-up
247 }
249 while true; do
251 # Detect WIFI_INTERFACE and update /etc/network.conf
252 . /etc/network.conf
253 if [ ! -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
254 WIFI_INTERFACE=$(for i in /sys/class/net/*/wireless; do \
255 [ -d $i ] && echo $(basename $(dirname $i)) || echo wlan0; \
256 break; done)
257 [ -n "$WIFI_INTERFACE" ] && sed -i "s/^WIFI_INTERFACE=.*/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" /etc/network.conf
258 fi
260 #
261 # Netbox internal calls
262 #
263 #########################################################
265 if [ "$1" = "call" ]; then
266 ppp="pppd local lock notty"
267 pppup=""
268 sub=$2
269 shift 2
270 case "$sub" in
271 sendsshkey)
272 check_root
273 ( dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key ;
274 cat /etc/ssh/ssh_host_rsa_key.pub ) 2> /dev/null | \
275 grep ^ssh | ssh $1 "mkdir .ssh 2> /dev/null ; \
276 while read key; do for i in authorized_keys authorized_keys2; do \
277 grep -q \$key .ssh/\$i || echo \$key >> .ssh/\$i ; done ; done ; \
278 chmod 700 .ssh ; chmod 600 .ssh/authorized_keys*"
279 exit 0;;
280 # OpenSSH VPN:
281 # PermitTunnel=point-to-point (or yes, ethernet, no)
282 # Tunnel="4" => tun4
283 # Local Client:
284 # # ssh -f -w 0:1 $REMOTE true => local tun0 [, remote tun1]
285 # # ifconfig $TUN $IP1 $IP2 netmask 255.255.255.252
286 # # route add $REMOTE_NETWORK $IP2
287 # Remote Server:
288 # # ifconfig $TUN $IP2 $IP1 netmask 255.255.255.252
289 # # route add $LOCAL_NETWORK $IP1
290 vpnssh) check_root
291 set_ipup
292 ps ww | grep -q "$ppp $2:$3" && exit 1
293 pipe="/tmp/ssh$$"
294 mkfifo $pipe
295 [ -n "$4" ] && pppup="ipparam 'addroutes,$(echo $4 | sed 's/ /,/g')'"
296 cat $pipe | dbclient -i /etc/dropbear/dropbear_rsa_host_key \
297 $1 "$ppp" | $ppp $2:$3 $pppup > $pipe
298 rm -f $pipe
299 exit 0;;
300 killvpnssh)
301 check_root
302 kill $(ps x | grep dbclient | grep "$ppp" | awk '{ print $1 }')
303 exit 0;;
304 ipup)
305 # Arg Name Example
306 # $1 Interface name ppp0
307 # $2 The tty ttyS1
308 # $3 The link speed 38400
309 # $4 Local IP number 12.34.56.78
310 # $5 Peer IP number 12.34.56.99
311 # $6 Optional ``ipparam'' value foo
312 iface=$1
313 # skip tty if present
314 case "$2" in [0-9]*);; *) shift; esac
315 peer=$4
316 IFS=","; set -- $(eval echo $5); unset IFS
317 set -- $1
318 if [ "$1" = "addroutes" ]; then
319 while [ -n "$2" ]; do
320 eval $(ipcalc -n $2)
321 eval $(ipcalc -m $2)
322 route add -net $NETWORK netmask $NETMASK \
323 gw $peer $iface
324 shift
325 done
326 fi
327 exit 0;;
328 esac
329 echo "call $sub unsupported."
330 exit 1
331 fi
333 #
334 # Tab display engine
335 #
336 ######################################################
338 use_tab()
339 {
340 local tmp=''
341 case "$2" in
342 header|body)
343 $1 | while read exe name call; do
344 case "$exe" in
345 \#*) continue;;
346 esac
347 which $exe > /dev/null || continue
348 if [ "$2" == "header" ]; then
349 echo -n "$tmp$name"
350 tmp='|'
351 else
352 $call
353 fi
354 done
355 ;;
356 *)
357 tmp=$(use_tab $1 header)
358 echo "$tmp" | grep -q \| && cat <<EOT
359 <notebook labels="$tmp">
360 EOT
361 [ -n "$tmp" ] && cat <<EOT
362 $(use_tab $1 body)
363 EOT
364 echo "$tmp" | grep -q \| && cat <<EOT
365 </notebook>
366 EOT
367 ;;
368 esac
369 }
371 #
372 # Status wire interfaces
373 #
374 tab_status_iface()
375 {
376 cat <<EOT
377 <frame Ifconfig>
378 <text wrap="false" width-chars="58">
379 <input>ifconfig</input>
380 </text>
381 </frame>
382 EOT
383 }
385 #
386 # Status wifi interfaces
387 #
388 tab_status_wifi_iface()
389 {
390 cat <<EOT
391 <frame Iwconfig>
392 <text wrap="false" width-chars="58">
393 <input>iwconfig</input>
394 </text>
395 </frame>
396 EOT
397 }
399 #
400 # Status wifi network
401 #
402 tab_status_wifi_net()
403 {
404 cat <<EOT
405 <frame Wireless networks>
406 <text wrap="false" width-chars="58">
407 <input>iwlist scan</input>
408 </text>
409 </frame>
410 EOT
411 }
413 #
414 # Status routing
415 #
416 tab_status_route()
417 {
418 cat <<EOT
419 <frame Routing>
420 <frame Nameservers>
421 <text wrap="false" width-chars="58">
422 <input>cat /etc/resolv.conf</input>
423 </text>
424 </frame>
425 <frame Routing table>
426 <text wrap="false" width-chars="58">
427 <input>route</input>
428 </text>
429 </frame>
430 <frame Arp table>
431 <text wrap="false" width-chars="58">
432 <input>arp</input>
433 </text>
434 </frame>
435 </frame>
436 EOT
437 }
439 #
440 # Status servers
441 #
442 tab_status_servers()
443 {
444 local servers
445 servers="dropbear sshd inetd dhcpd dnsd named rsync httpd mbd vnc pppd knock"
446 cat <<EOT
447 <frame Servers>
448 <text wrap="false" width-chars="58">
449 <input>for i in $servers; do ps ww | grep \$i | grep -v grep | fold -s; done</input>
450 </text>
451 </frame>
452 EOT
453 }
455 data_status()
456 {
457 cat <<EOT
458 ifconfig Network\ interfaces tab_status_iface
459 iwconfig Wireless\ interfaces tab_status_wifi_iface
460 iwlist Wireless\ networks tab_status_wifi_net
461 route Routing tab_status_route
462 ps Servers tab_status_servers
463 EOT
464 }
466 #
467 # Status
468 #
469 tab_status()
470 {
471 use_tab data_status
472 }
474 #
475 # Interfaces list from detect_interfaces()
476 #
477 tab_connections()
478 {
479 cat <<EOT
480 <vbox>
481 <tree>
482 <width>520</width><height>120</height>
483 <variable>INTERFACE_LIST</variable>
484 <label>Interface|Type|Status</label>
485 <input icon_column="0">$0 detect_interfaces</input>
486 <action>refresh:INTERFACE_LIST</action>
487 </tree>
488 </vbox>
489 EOT
490 }
492 #
493 # DHCP
494 #
495 tab_udhcpc()
496 {
497 cat <<EOT
498 <frame Udhcpc (busybox)>
499 <text width-chars="58">
500 <label> "Ethernet (cable) default connection." </label>
501 </text>
502 <hbox>
503 <text use-markup="true">
504 <label>"<b>Interface:</b>"</label>
505 </text>
506 <entry>
507 <input>. /etc/network.conf; echo "\$INTERFACE"</input>
508 <variable>INTERFACE</variable>
509 </entry>
510 </hbox>
511 <hbox>
512 <text use-markup="true">
513 <label>"<b>Options: </b>"</label>
514 </text>
515 <entry>
516 <default>-b</default>
517 <variable>UDHCPC_OPTS</variable>
518 </entry>
519 $(helpbutton udhcpc 80x30)
520 </hbox>
521 <hbox>
522 <text use-markup="true">
523 <label>"<b>Script: </b>"</label>
524 </text>
525 <entry editable="false">
526 <default>/usr/share/udhcpc/default.script</default>
527 <variable>UDHCPC_SCRIPT</variable>
528 </entry>
529 <button>
530 <input file icon="accessories-text-editor"></input>
531 <action type="lauch">leafpad \$UDHCPC_SCRIPT</action>
532 </button>
533 </hbox>
534 <hbox>
535 <button>
536 <label>Start</label>
537 <input file icon="forward"></input>
538 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE="\$INTERFACE"/ /etc/network.conf</action>
539 <action>sed -i s/DHCP="no"/DHCP="yes"/ /etc/network.conf</action>
540 <action>sed -i s/STATIC="yes"/STATIC="no"/ /etc/network.conf</action>
541 <action>udhcpc \$UDHCPC_OPTS -i \$INTERFACE -p /var/run/udhcpc.\$INTERFACE.pid</action>
542 <action>refresh:INTERFACE_LIST</action>
543 </button>
544 <button>
545 <label>Stop</label>
546 <input file icon="stop"></input>
547 <action>echo -n "Stopping interface : \$INTERFACE... "</action>
548 <action>ifconfig \$INTERFACE down</action>
549 <action>killall -q udhcpc; echo "done"</action>
550 <action>refresh:INTERFACE_LIST</action>
551 </button>
552 </hbox>
553 </frame>
554 EOT
555 }
557 #
558 # Static/fixed IP settings.
559 #
560 tab_fixed_ip()
561 {
562 cat <<EOT
563 <frame Ethernet fixed IP>
564 <hbox>
565 <text use-markup="true">
566 <label>"<b>Interface: </b>"</label>
567 </text>
568 <entry>
569 <input>. /etc/network.conf; echo "\$INTERFACE"</input>
570 <variable>INTERFACE</variable>
571 </entry>
572 </hbox>
573 <hbox>
574 <text use-markup="true">
575 <label>"<b>IP: </b>"</label>
576 </text>
577 <entry>
578 <input>. /etc/network.conf; echo "\$IP"</input>
579 <variable>IP</variable>
580 </entry>
581 </hbox>
582 <hbox>
583 <text use-markup="true">
584 <label>"<b>Netmask: </b>"</label>
585 </text>
586 <entry>
587 <input>. /etc/network.conf; echo "\$NETMASK"</input>
588 <variable>NETMASK</variable>
589 </entry>
590 </hbox>
591 <hbox>
592 <text use-markup="true">
593 <label>"<b>Gateway: </b>"</label>
594 </text>
595 <entry>
596 <input>. /etc/network.conf; echo "\$GATEWAY"</input>
597 <variable>GATEWAY</variable>
598 </entry>
599 </hbox>
600 <hbox>
601 <text use-markup="true">
602 <label>"<b>DNS server: </b>"</label>
603 </text>
604 <entry>
605 <input>. /etc/network.conf; echo "\$DNS_SERVER"</input>
606 <variable>DNS_SERVER</variable>
607 </entry>
608 </hbox>
609 <hbox>
610 <button>
611 <label>Start</label>
612 <input file icon="forward"></input>
613 <action>ifconfig lo down</action>
614 <action>ifconfig \$INTERFACE down</action>
615 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE="\$INTERFACE"/ /etc/network.conf</action>
616 <action>sed -i s/DHCP="yes"/DHCP="no"/ /etc/network.conf</action>
617 <action>sed -i s/WIFI="yes"/WIFI="no"/ /etc/network.conf</action>
618 <action>sed -i s/STATIC="no"/STATIC="yes"/ /etc/network.conf</action>
619 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP="\$IP"/ /etc/network.conf</action>
620 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK="\$NETMASK"/ /etc/network.conf</action>
621 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY="\$GATEWAY"/ /etc/network.conf</action>
622 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER="\$DNS_SERVER"/ /etc/network.conf</action>
623 <action>/etc/init.d/network.sh</action>
624 <action>refresh:INTERFACE_LIST</action>
625 </button>
626 <button>
627 <label>Stop</label>
628 <input file icon="stop"></input>
629 <action>ifconfig \$INTERFACE down</action>
630 <action>refresh:INTERFACE_LIST</action>
631 </button>
632 </hbox>
633 </frame>
634 EOT
635 }
637 #
638 # PPPoe settings.
639 #
640 tab_pppoe()
641 {
642 cat <<EOT
643 <frame PPPoE>
644 <hbox>
645 <text use-markup="true">
646 <label>"<b>Name: </b>"</label>
647 </text>
648 <entry>
649 <input>NAME=\$(grep -s ^name /etc/ppp/options); echo "\${NAME#* }"</input>
650 <variable>NAME</variable>
651 </entry>
652 </hbox>
653 <hbox>
654 <text use-markup="true">
655 <label>"<b>Username:</b>"</label>
656 </text>
657 <entry>
658 <variable>USER</variable>
659 </entry>
660 </hbox>
661 <hbox>
662 <text use-markup="true">
663 <label>"<b>Password:</b>"</label>
664 </text>
665 <entry>
666 <variable>PASS</variable>
667 </entry>
668 </hbox>
669 <hbox>
670 $(helpbutton pppd 80x30)
671 $(manbutton 8 pppd)
672 <button>
673 <input file icon="accessories-text-editor"></input>
674 <label>Tune</label>
675 <action>[ -n "\$NAME" ] && sed -i "s/^name .*/name \$NAME/" /etc/ppp/options</action>
676 <action type="lauch">leafpad /etc/ppp/options</action>
677 </button>
678 <button>
679 <label>Start</label>
680 <input file icon="forward"></input>
681 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/pap-secrets
682 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/pap-secrets</action>
683 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/chap-secrets
684 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/chap-secrets</action>
685 <action>[ -n "\$NAME" ] && sed -i "s/^name .*/name \$NAME/" /etc/ppp/options</action>
686 <action>killall udhcpc</action>
687 <action>sed -i "s/DHCP=\"yes\"/DHCP=\"no\"/" /etc/network.conf</action>
688 <action>sed -i "s/PPPOE=\"no\"/PPPOE=\"yes\"/" /etc/network.conf</action>
689 <action>pppd \$INTERFACE &</action>
690 </button>
691 <button>
692 <label>Stop</label>
693 <input file icon="stop"></input>
694 <action>sed -i "s/PPPOE=\"yes\"/PPPOE=\"no\"/" /etc/network.conf</action>
695 <action>killall pppd</action>
696 </button>
697 </hbox>
698 </frame>
699 EOT
700 }
702 #
703 # PPP settings.
704 #
705 tab_ppp()
706 {
707 cat <<EOT
708 <frame PPP>
709 <hbox>
710 <text use-markup="true">
711 <label>"<b>Username: </b>"</label>
712 </text>
713 <entry>
714 <input>USER=\$(grep -s ^ACCOUNT= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${USER#*=}"</input>
715 <variable>USER</variable>
716 </entry>
717 </hbox>
718 <hbox>
719 <text use-markup="true">
720 <label>"<b>Password: </b>"</label>
721 </text>
722 <entry>
723 <input>PASS=\$(grep -s ^PASSWORD= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${PASS#*=}"</input>
724 <variable>PASS</variable>
725 </entry>
726 </hbox>
727 <hbox>
728 <text use-markup="true">
729 <label>"<b>Telephone:</b>"</label>
730 </text>
731 <entry>
732 <input>PHONE=\$(grep -s ^TELEPHONE= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${PHONE#*=}"</input>
733 <variable>PHONE</variable>
734 </entry>
735 </hbox>
736 <hbox>
737 $(helpbutton pppd 80x30)
738 $(manbutton 8 pppd)
739 <button>
740 <input file icon="accessories-text-editor"></input>
741 <label>Tune</label>
742 <action>[ -n "\$NAME" ] && sed -i "s/^ACCOUNT=.*/ACCOUNT=\$NAME/" /etc/ppp/scripts/ppp-on</action>
743 <action>[ -n "\$PASS" ] && sed -i "s/^PASSWORD=.*/PASSWORD=\$PASS/" /etc/ppp/scripts/ppp-on</action>
744 <action>[ -n "\$PHONE" ] && sed -i "s/^TELEPHONE=.*/TELEPHONE=\$PHONE/" /etc/ppp/scripts/ppp-on</action>
745 <action type="lauch">leafpad /etc/ppp/scripts/ppp-on</action>
746 </button>
747 <button>
748 <label>Start</label>
749 <input file icon="forward"></input>
750 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/pap-secrets
751 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/pap-secrets</action>
752 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/chap-secrets
753 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/chap-secrets</action>
754 <action>[ -n "\$NAME" ] && sed -i "s/^name .*/name \$NAME/" /etc/ppp/options</action>
755 <action>/etc/ppp/scripts/ppp-off</action>
756 <action>/etc/ppp/scripts/ppp-on &</action>
757 </button>
758 <button>
759 <label>Stop</label>
760 <input file icon="stop"></input>
761 <action>/etc/ppp/scripts/ppp-off</action>
762 </button>
763 </hbox>
764 </frame>
765 EOT
766 }
768 #
769 # System Wide configuration.
770 #
771 tab_system()
772 {
773 cat <<EOT
774 <frame Configuration files>
775 <hbox>
776 <text use-markup="true">
777 <label>"<b>Hosts :</b>"</label>
778 </text>
779 <entry editable="false">
780 <default>/etc/hosts</default>
781 <variable>HOSTS</variable>
782 </entry>
783 <button>
784 <input file icon="accessories-text-editor"></input>
785 <action type="lauch">leafpad \$HOSTS</action>
786 </button>
787 </hbox>
788 <hbox>
789 <text use-markup="true">
790 <label>"<b>Host name :</b>"</label>
791 </text>
792 <entry editable="false">
793 <default>/etc/hostname</default>
794 <variable>HOSTNAME</variable>
795 </entry>
796 <button>
797 <input file icon="accessories-text-editor"></input>
798 <action type="lauch">leafpad \$HOSTNAME</action>
799 </button>
800 </hbox>
801 <hbox>
802 <text use-markup="true">
803 <label>"<b>Network :</b>"</label>
804 </text>
805 <entry editable="false">
806 <default>/etc/network.conf</default>
807 <variable>CONFIG_FILE</variable>
808 </entry>
809 <button>
810 <input file icon="accessories-text-editor"></input>
811 <action type="lauch">leafpad \$CONFIG_FILE</action>
812 </button>
813 </hbox>
814 <hbox>
815 <button>
816 <label>Restart</label>
817 <input file icon="reload"></input>
818 <action>echo -n "Stopping interface : \$INTERFACE... "</action>
819 <action>ifconfig \$INTERFACE down</action>
820 <action>killall -q udhcpc; echo "done"</action>
821 <action>/etc/init.d/network.sh restart</action>
822 </button>
823 </hbox>
824 </frame>
825 EOT
826 }
828 #
829 # ssh/ppp
830 #
831 tab_sshppp()
832 {
833 cat <<EOT
834 <frame Virtual Private Network with PPP/SSH>
835 <hbox>
836 <text use-markup="true">
837 <label>"<b>Peer :</b>"</label>
838 </text>
839 <entry>
840 <variable>DROPBEAR_PEERVPN</variable>
841 <default>user@elsewhere</default>
842 </entry>
843 </hbox>
844 <hbox>
845 <text use-markup="true">
846 <label>"<b>Local IP :</b>"</label>
847 </text>
848 <entry>
849 <variable>DROPBEAR_LOCAL</variable>
850 <default>192.168.254.1</default>
851 </entry>
852 </hbox>
853 <hbox>
854 <text use-markup="true">
855 <label>"<b>Remote IP :</b>"</label>
856 </text>
857 <entry>
858 <variable>DROPBEAR_REMOTE</variable>
859 <default>192.168.254.2</default>
860 </entry>
861 </hbox>
862 <hbox>
863 <text use-markup="true">
864 <label>"<b>Route(s) :</b>"</label>
865 </text>
866 <entry>
867 <variable>DROPBEAR_ROUTE</variable>
868 <default>192.168.10.0/24 192.168.20.0/28</default>
869 </entry>
870 </hbox>
871 <hbox>
872 $(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:vpn)
873 <button>
874 <input file icon="forward"></input>
875 <label>Connect</label>
876 <action>$0 call vpnssh \$DROPBEAR_PEERVPN \$DROPBEAR_LOCAL \$DROPBEAR_REMOTE "\$DROPBEAR_ROUTE" &</action>
877 </button>
878 <button>
879 <input file icon="stop"></input>
880 <label>Disconnect</label>
881 <action>$0 call killvpnssh</action>
882 </button>
883 <button>
884 <input file icon="go-up"></input>
885 <label>Send key</label>
886 <action>$xterm -geometry 80x10 -title "Send key" -e "$0 call sendsshkey \$DROPBEAR_PEERVPN; echo -e \"----\nENTER to continue...\" && read close"</action>
887 </button>
888 </hbox>
889 </frame>
890 EOT
891 }
893 #
894 # PPTP client
895 #
896 #FIXME
897 #cat > /etc/ppp/peers/$TUNNEL <<EOT
898 #pty "pptp $SERVER --nolaunchpppd"
899 #lock
900 #noauth
901 #nobsdcomp
902 #nodeflate
903 #name $DOMAIN\\$USERNAME
904 #remotename $TUNNEL
905 #ipparam $TUNNEL
906 #$(encryption && echo "require-mppe-128")
907 #EOT
908 #pppd call $TUNNEL updetach
910 tab_pptp()
911 {
912 [ -f /etc/ppp/options.pptp ] || cat >> /etc/ppp/options.pptp <<EOT
913 lock noauth nobsdcomp nodeflate remotename PPTP
914 EOT
915 [ -f /etc/ppp/pptp-servers ] || cat >> /etc/ppp/pptp-servers <<EOT
916 # PPTP servers list
917 EOT
918 cat <<EOT
919 <frame Virtual Private Network with PPTP>
920 <hbox>
921 <text use-markup="true">
922 <label>"<b>Server:</b>"</label>
923 </text>
924 <combobox>
925 <variable>PPTP_SERVER</variable>
926 EOT
927 grep -v ^\# /etc/ppp/pptp-servers | \
928 awk '{ printf " <item>%s</item>\n",$1 }'
929 cat <<EOT
930 <item>SERVER</item>
931 </combobox>
932 <button>
933 <input file icon="accessories-text-editor"></input>
934 <action type="lauch">leafpad /etc/ppp/pptp-servers</action>
935 </button>
936 </hbox>
937 <hbox>
938 <text use-markup="true">
939 <label>"<b> User:</b>"</label>
940 </text>
941 <combobox>
942 <variable>PPTP_USER</variable>
943 EOT
944 grep '\\' /etc/ppp/chap-secrets | grep -v ^\# | \
945 awk '{ printf " <item>%s</item>\n",$1 }'
946 cat <<EOT
947 <item>DOMAIN\USERNAME</item>
948 </combobox>
949 <button>
950 <input file icon="accessories-text-editor"></input>
951 <action type="lauch">leafpad /etc/ppp/chap-secrets</action>
952 </button>
953 </hbox>
954 <hbox>
955 <text use-markup="true">
956 <label>"<b>Password:</b>"</label>
957 </text>
958 <entry>
959 <variable>PPTP_PASS</variable>
960 </entry>
961 </hbox>
962 <hbox>
963 <checkbox>
964 <label>Encryption</label>
965 <variable>PPTP_ENC</variable>
966 <default>true</default>
967 </checkbox>
968 $(helpbutton pptp 80x35)
969 <button>
970 <input file icon="accessories-text-editor"></input>
971 <label>Options</label>
972 <action type="lauch">leafpad /etc/ppp/options.pptp</action>
973 </button>
974 <button>
975 <input file icon="forward"></input>
976 <label>Connect</label>
977 <action>grep -qs ^\$PPTP_USER /etc/ppp/chap-secrets || \
978 echo "\$PPTP_USER PPTP \"$PPTP_PASS\" *" >> /etc/ppp/chap-secrets</action>
979 <action>grep -qs ^\$PPTP_SERVER /etc/ppp/pptp-servers || \
980 echo "\$PPTP_SERVER" >> /etc/ppp/pptp-servers</action>
981 <action>PASS=""; [ -n "\$PPTP_PASS" ] && PASS="password \$PASS"; \
982 ENC=""; [ x\$PPTP_ENC == xtrue ] && ENC="require-mppe-128"; \
983 /usr/sbin/pptp \$PPTP_SERVER file /etc/ppp/options.pptp \$ENC user \$PPTP_USER \$PASS &
984 </action>
985 </button>
986 <button>
987 <input file icon="stop"></input>
988 <label>Disconnect</label>
989 <action>killall pptp</action>
990 </button>
991 </hbox>
992 </frame>
993 EOT
994 }
996 data_vpn()
997 {
998 cat <<EOT
999 $([ -x /usr/sbin/dropbear -o -x /usr/sbin/sshd ] && echo "pppd" ||
1000 echo "#") PPP/SSH tab_sshppp
1001 pptp PPTP tab_pptp
1002 #TODO openvpn OpenVPN tab_openvpn
1003 #TODO vpnc EasyVPN tab_easyvpn
1004 EOT
1008 # VPN
1010 tab_vpn()
1012 use_tab data_vpn
1015 sshremote()
1017 cat << EOT
1018 <hbox>
1019 <text use-markup="true">
1020 <label>"<b>Remote :</b>"</label>
1021 </text>
1022 <entry>
1023 <variable>$2</variable>
1024 <default>user@elsewhere</default>
1025 </entry>
1026 <button>
1027 <input file icon="utilities-terminal"></input>
1028 <label>Connect</label>
1029 <action>xterm -fa MiscFixed -fs 11 -bg black -fg white -geometry 80x25 -title "$1" -e "$1 \$$2 ; echo -e \"----\nENTER to continue...\" && read close" &</action>
1030 </button>
1031 <button>
1032 <input file icon="go-up"></input>
1033 <label>Send key</label>
1034 <action>$xterm -geometry 80x10 -title "send ssh key" -e "$0 call sendsshkey \$$2; echo -e \"----\nENTER to continue...\" && read close"</action>
1035 </button>
1036 </hbox>
1037 EOT
1041 # Dropbear client & server
1043 tab_dropbear()
1045 . /etc/daemons.conf
1046 set -- $DROPBEAR_OPTIONS
1047 while [ -n "$2" ]; do
1048 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
1049 shift
1050 done
1052 cat <<EOT
1053 <frame Dropbear>
1054 $(helpdaemon dropbear 80x30 DROPBEAR_OPTIONS DROPBEAR_OPTS)
1055 $(datafile /etc/dropbear/banner DROPBEAR_BANNER 'Banner :')
1056 $(sshremote DROPBEAR_PEER 'dbclient -i /etc/dropbear/dropbear_rsa_host_key')
1057 <hbox>
1058 $(startstopdaemon dropbear)
1059 </hbox>
1060 </frame>
1061 EOT
1065 # OpenSSH client & server
1067 tab_openssh()
1069 cat <<EOT
1070 <frame OpenSSH>
1071 $(helpdaemon sshd 80x30 OPENSSH_OPTIONS OPENSSH_OPTS 8 nohelp)
1072 $(configfile /etc/ssh/sshd_config OPENSSH_CONF '5 sshd_config')
1073 $(sshremote OPENSSH_PEER 'ssh -i /etc/ssh/ssh_host_rsa_key')
1074 <hbox>
1075 $(startstopdaemon openssh)
1076 </hbox>
1077 </frame>
1078 EOT
1081 data_sshd()
1083 cat <<EOT
1084 dropbear Dropbear tab_dropbear
1085 sshd OpenSSH tab_openssh
1086 EOT
1090 # SSH tab
1092 tab_sshd()
1094 use_tab data_sshd
1098 # Busybox Inetd
1100 tab_inetd()
1102 cat <<EOT
1103 <frame Inetd (busybox)>
1104 $(helpdaemon inetd 60x14 INETD_OPTIONS INETD_OPTS)
1105 $(configfile /etc/inetd.conf INETD_CONF)
1106 <hbox>
1107 EOT
1108 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
1109 i=$(basename $i)
1110 helpbutton $i 60x19 $i
1111 done
1112 cat <<EOT
1113 $(startstopdaemon inetd)
1114 </hbox>
1115 </frame>
1116 EOT
1120 # ZeroConf
1122 tab_zcip()
1124 if [ -x /sbin/zcip -a -z "$ZCIP_OPTIONS" ]; then
1125 ZCIP_OPTIONS="eth0 /etc/zcip.script"
1126 cat >> /etc/daemons.conf <<EOT
1127 # ZeroConf options
1128 ZCIP_OPTIONS="$ZCIP_OPTIONS"
1130 EOT
1131 fi
1132 cat <<EOT
1133 <frame Zcip (busybox)>
1134 $(helpdaemon zcip 60x14 ZCIP_OPTIONS ZCIP_OPTS)
1135 $(datafile /etc/zcip.script CZIP_SCRIPT 'Script :')
1136 <hbox>
1137 $(startstopdaemon zcip)
1138 </hbox>
1139 </frame>
1140 EOT
1144 # Dhcpd ISC
1146 tab_isc_dhcpd()
1148 cat <<EOT
1149 <frame Dhcpd (ISC)>
1150 $(helpdaemon dhcpd 60x14 DHCPD_OPTIONS DHCPD_OPTS)
1151 $(configfile /etc/dhcpd.conf DHCPD_CONF)
1152 <hbox>
1153 $(startstopdaemon dhcpd dhcp)
1154 </hbox>
1155 </frame>
1156 EOT
1160 # Dhcpd Busybox
1162 tab_udhcpd()
1164 cat <<EOT
1165 <frame Udhcpd (busybox)>
1166 $(helpdaemon udhcpd 60x14 UDHCPD_OPTIONS UDHCPD_OPTS)
1167 $(configfile /etc/udhcpd.conf UDHCPD_CONF)
1168 <hbox>
1169 $(startstopdaemon udhcpd)
1170 </hbox>
1171 </frame>
1172 EOT
1175 data_dhcpd()
1177 cat <<EOT
1178 udhcpd Udhcpd tab_udhcpd
1179 dhcpd Dhcpd tab_isc_dhcpd
1180 dnsmasq DNSmasq tab_dnsmasq
1181 EOT
1185 # dhcpd tab
1187 tab_dhcpd()
1189 use_tab data_dhcpd
1193 # PXE
1195 tab_pxe()
1197 cat <<EOT
1198 <frame Pxelinux>
1199 <hbox>
1200 <text wrap="true">
1201 <label>
1202 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
1203 </label>
1204 </text>
1205 </hbox>
1206 <hbox>
1207 <text use-markup="true">
1208 <label>"<b>Configuration :</b>"</label>
1209 </text>
1210 <entry editable="false">
1211 <default>
1212 $(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')/pxelinux.cfg/default
1213 </default>
1214 <variable>PXE_CONF</variable>
1215 </entry>
1216 <button>
1217 <input file icon="accessories-text-editor"></input>
1218 <action>dir=\$(dirname \$PXE_CONF); [ -d \$dir ] || mkdir -p \$dir</action>
1219 <action>lzma d /usr/share/boot/pxelinux.0.lzma \$(dirname \$PXE_CONF)/../pxelinux.0</action>
1220 <action>grep -q "^boot_file" \$UDHCPD_CONF || echo "boot_file pxelinux.0" >> \$UDHCPD_CONF</action>
1221 <action>grep -q "^siaddr" \$UDHCPD_CONF || echo "siaddr \$(ifconfig \$INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> \$UDHCPD_CONF</action>
1222 <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>
1223 <action type="lauch">leafpad \$PXE_CONF</action>
1224 </button>
1225 </hbox>
1226 <hbox>
1227 $(wikibutton http://wiki.slitaz.org/doku.php?id=quickstart:pxe)
1228 <button>
1229 <input file icon="system-file-manager"></input>
1230 <label>Network boot files</label>
1231 <action>$xterm -geometry 100x25 -title "Network boot files (q to quit)" -e "find \$(dirname \$(dirname \$PXE_CONF)) -exec ls -ld {} \; | less"</action>
1232 </button>
1233 </hbox>
1234 </frame>
1235 EOT
1239 # Busybox dnsd
1241 tab_dnsd()
1243 cat <<EOT
1244 <frame Dnsd (busybox master dns)>
1245 $(helpdaemon dnsd 80x15 DNSD_OPTIONS DNSD_OPTS)
1246 $(configfile /etc/dnsd.conf DNSD_CONF)
1247 <hbox>
1248 $(startstopdaemon dnsd)
1249 </hbox>
1250 </frame>
1251 EOT
1255 # ISC Bind
1257 tab_named()
1259 cat <<EOT
1260 <frame Named (ISC bind)>
1261 $(helpdaemon named 80x10 NAMED_OPTIONS NAMED_OPTS)
1262 $(configfile /etc/bind/named.conf.local NAMED_CONF)
1263 <hbox>
1264 $(startstopdaemon named bind)
1265 </hbox>
1266 </frame>
1267 EOT
1271 # DNSmasq
1273 tab_dnsmasq()
1275 cat <<EOT
1276 <frame DNSmasq (DNS/DHCP/TFTP)>
1277 $(helpdaemon dnsmasq 100x34 DNSMASQ_OPTIONS DNSMASQ_OPTS)
1278 $(configfile /etc/dnsmasq.conf DNSMASQ_CONF)
1279 <hbox>
1280 $(startstopdaemon dnsmasq)
1281 </hbox>
1282 </frame>
1283 EOT
1286 data_dns()
1288 cat <<EOT
1289 dnsd Dnsd tab_dnsd
1290 named Named tab_named
1291 dnsmasq DNSmasq tab_dnsmasq
1292 #TODO sheerdns Sheerdns tab_sheerdns
1293 EOT
1297 # dns tab
1299 tab_dns()
1301 use_tab data_dns
1305 # rsync server
1307 tab_rsync()
1309 cat <<EOT
1310 <frame Rsync>
1311 $(helpdaemon rsync 80x30 RSYNCD_OPTIONS RSYNCD_OPTS 1)
1312 $(configfile /etc/rsyncd.conf RSYNCD_CONF)
1313 $(datafile /etc/rsyncd.secrets RSYNCD_SECRETS 'Secrets file :')
1314 <hbox>
1315 $(startstopdaemon rsyncd rsync)
1316 </hbox>
1317 </frame>
1318 EOT
1321 php_ini()
1323 [ -f /etc/php.ini ] && cat <<EOT
1324 <frame PHP>
1325 $(configfile /etc/php.ini PHP_CONF)
1326 </frame>
1327 EOT
1331 # Apache server
1333 tab_apache()
1335 cat <<EOT
1336 <frame Apache>
1337 $(php_ini)
1338 $(configfile /etc/apache/httpd.conf HTTPD_CONF)
1339 <hbox>
1340 $(startstopdaemon apache)
1341 </hbox>
1342 </frame>
1343 EOT
1347 # Lighttpd server
1349 tab_lighttpd()
1351 cat <<EOT
1352 <frame Lighttpd>
1353 $(php_ini)
1354 $(configfile /etc/lighttpd/lighttpd.conf LIGHTTPD_CONF)
1355 <hbox>
1356 $(startstopdaemon lighttpd)
1357 </hbox>
1358 </frame>
1359 EOT
1362 data_http()
1364 cat <<EOT
1365 httpd Dnsd tab_apache
1366 lighttpd Named tab_lighttpd
1367 EOT
1368 #TODO busybox httpd
1372 # http tab
1374 tab_http()
1376 use_tab data_http
1380 # Samba servers
1382 tab_wins()
1384 cat <<EOT
1385 <frame Samba: smbd & nmbd>
1386 $(configfile /etc/samba/smb.conf SMBD_CONF)
1387 <hbox>
1388 <button>
1389 <label>Reload</label>
1390 <input file icon="reload"></input>
1391 <action>/etc/init.d/samba reload</action>
1392 </button>
1393 $(startstopdaemon samba)
1394 </hbox>
1395 </frame>
1396 EOT
1400 # x11vnc
1402 tab_vnc()
1404 cat <<EOT
1405 <frame x11vnc>
1406 $(helpdaemon x11vnc 80x30 X11VNC_OPTIONS X11VNC_OPTS)
1407 <hbox>
1408 <text use-markup="true">
1409 <label>"<b>New password</b>"</label>
1410 </text>
1411 <entry>
1412 <variable>X11VNC_PASSWD</variable>
1413 </entry>
1414 <button>
1415 <input file icon="reload"></input>
1416 <label>Update</label>
1417 <action>x11vnc -storepasswd \$X11VNC_PASSWD /etc/vnc.secret</action>
1418 </button>
1419 </hbox>
1420 <hbox>
1421 $(startstopdaemon x11vnc)
1422 </hbox>
1423 </frame>
1424 EOT
1428 # knock server
1430 tab_knockd()
1432 cat <<EOT
1433 <frame Knockd: trigger backdoors>
1434 $(helpdaemon knockd 80x15 KNOCK_OPTIONS KNOCK_OPTS)
1435 $(configfile /etc/knockd.conf KNOCKD_CONF)
1436 <hbox>
1437 $(startstopdaemon knockd knock)
1438 </hbox>
1439 </frame>
1440 EOT
1443 data_servers()
1445 local $pxe
1446 pxe="#"
1447 [ -x /usr/sbin/dnsmasq ] && pxe="inetd"
1448 [ -x /usr/bin/tftpd -a -x /usr/sbin/udhcpd ] && pxe="inetd"
1449 [ -f /usr/share/boot/pxelinux.0.lzma ] || pxe="#"
1450 cat <<EOT
1451 $([ -x /usr/sbin/dropbear -o -x /usr/sbin/sshd ] && echo "true" ||
1452 echo "#") SSH tab_sshd
1453 inetd Inetd tab_inetd
1454 zcip ZeroConf tab_zcip
1455 $([ -x /usr/sbin/udhcpd -o -x /usr/sbin/dhcpd -o -x /usr/sbin/dnsmasq ] &&
1456 echo "true" ||
1457 echo "#") DHCP tab_dhcpd
1458 $pxe PXE tab_pxe
1459 dnsmasq tftpd tab_dnsmasq
1460 $([ -x /usr/sbin/dnsd -o -x /usr/sbin/named -o -x /usr/sbin/dnsmasq ] &&
1461 echo "true" ||
1462 echo "#") DNS tab_dns
1463 rsync Rsync tab_rsync
1464 $([ -x /usr/sbin/lighttpd -o -x /usr/bin/httpd ] && echo "true" ||
1465 echo "#") HTTP tab_http
1466 smbd WINS tab_wins
1467 x11vnc VNC tab_vnc
1468 knockd Knock tab_knockd
1469 EOT
1473 # Servers tab
1475 tab_servers()
1477 use_tab data_servers
1481 # Firewall tab
1483 tab_firewall()
1485 cat <<EOT
1486 <frame Iptables>
1487 $(configfile /etc/iptables.conf IPTABLES_CONF)
1488 <hbox>
1489 $(helpbutton iptables 80x30)
1490 $(manbutton 8 iptables)
1491 <button>
1492 <label>Load</label>
1493 <input file icon="reload"></input>
1494 <action>cat \$IPTABLES_CONF | /sbin/iptables-restore</action>
1495 </button>
1496 <button>
1497 <label>Save</label>
1498 <input file icon="go-jump"></input>
1499 <action>/sbin/iptables-save > \$IPTABLES_CONF</action>
1500 </button>
1501 </hbox>
1502 </frame>
1503 EOT
1507 # knock client
1509 tab_knock()
1511 cat <<EOT
1512 <frame Knock>
1513 <hbox>
1514 <text use-markup="true">
1515 <label>"<b>Options : </b>"</label>
1516 </text>
1517 <entry editable="true">
1518 <variable>KNOCK_OPTS</variable>
1519 <default>myserver.example.com 123:tcp 456:udp 789:tcp</default>
1520 </entry>
1521 </hbox>
1522 <hbox>
1523 $(helpbutton knock 80x12)
1524 <button>
1525 <label>Start</label>
1526 <input file icon="forward"></input>
1527 <action>knock \$KNOCK_OPTS</action>
1528 </button>
1529 </hbox>
1530 </frame>
1531 EOT
1535 # ether-wake
1537 tab_etherwake()
1539 cat <<EOT
1540 <frame Ether-wake (busybox)>
1541 <hbox>
1542 <text use-markup="true">
1543 <label>"<b>Machines :</b>"</label>
1544 </text>
1545 <entry editable="false">
1546 <default>/etc/ethers</default>
1547 <variable>ETHERS</variable>
1548 </entry>
1549 <button>
1550 <input file icon="accessories-text-editor"></input>
1551 <action>[ -s \$ETHERS ] || echo "#00:01:02:03:04:05 mystation" >\$ETHERS</action>
1552 <action type="lauch">leafpad \$ETHERS</action>
1553 </button>
1554 </hbox>
1555 <hbox>
1556 <text use-markup="true">
1557 <label>"<b>Options : </b>"</label>
1558 </text>
1559 <entry editable="true">
1560 <variable>ETHERWAKE_OPTS</variable>
1561 </entry>
1562 $(helpbutton ether-wake 80x15)
1563 <button>
1564 <label>Start</label>
1565 <input file icon="forward"></input>
1566 <action>ether-wake \$ETHERWAKE_OPTS</action>
1567 </button>
1568 </hbox>
1569 </frame>
1570 EOT
1573 data_main()
1575 cat <<EOT
1576 #program tab name function
1577 ifconfig Connections tab_connections
1578 udhcpc DHCP tab_udhcpc
1579 ifconfig Static\ IP tab_fixed_ip
1580 pppoe PPPoE tab_pppoe
1581 pppd PPP tab_ppp
1582 true System\ wide tab_system
1583 true VPN tab_vpn
1584 true Servers tab_servers
1585 iptables Firewall tab_firewall
1586 knock Knock tab_knock
1587 ether-wake Etherwake tab_etherwake
1588 EOT
1591 tab_main()
1593 use_tab data_main
1596 ######################################################
1598 # Netbox GUI
1600 ######################################################
1602 # English/French help dialog.
1603 export HELP='
1604 <window title="Network status" icon-name="network-wire">
1605 <vbox>
1606 <text use-markup="true">
1607 <label>
1609 <b>SliTaz - Netbox</b>"
1610 </label>
1611 </text>
1612 <frame English>
1613 <text wrap="true" width-chars="58">
1614 <label>
1615 "Netbox lets you manage network connections by getting a dynamic IP by
1616 DHCP or a static IP and setup servers. Netbox can start or stop
1617 networking, configure network interfaces or directly edit files."
1618 </label>
1619 </text>
1620 </frame>
1621 <frame Francais>
1622 <text wrap="true" width-chars="58">
1623 <label>
1624 "Netbox vous permet de gerer les connexions reseau avec une IP
1625 statique ou en obtenant une IP dynamique par DHCP, et de parametrer
1626 les serveurs. Netbox peut demarrer ou arreter le reseau, configurer
1627 les interfaces reseau ou editer directement les fichiers."
1628 </label>
1629 </text>
1630 </frame>
1631 </vbox>
1632 </window>
1635 # Interface status with ifconfig without arguments to show all
1636 # active connections.
1638 export IFCONFIG="
1639 <window title=\"Network status\" icon-name=\"network-wire\">
1640 <vbox>
1641 $(tab_status)
1642 <hbox>
1643 <button>
1644 <input file icon=\"gtk-close\"></input>
1645 <action type=\"closewindow\">IFCONFIG</action>
1646 </button>
1647 </hbox>
1648 </vbox>
1649 </window>"
1651 # The main dialog with notebook, start/stop buttons and all options.
1652 # Note that /etc/network.conf is seded when an interface is activated.
1654 head='
1655 <window title="SliTaz Netbox Manager" icon-name="network-wired">
1656 <vbox>
1658 <hbox>
1659 <text use-markup="true">
1660 <label>"<b>Network/Server Manager</b>"</label>
1661 </text>
1662 <pixmap>
1663 <input file>/usr/share/pixmaps/netbox.png</input>
1664 </pixmap>
1665 </hbox>
1667 bottom='
1668 <hbox>
1669 <button>
1670 <label>Wireless manager</label>
1671 <input file icon="network-wireless"></input>
1672 <action>wifibox &</action>
1673 </button>
1674 <button>
1675 <label>Refresh list</label>
1676 <input file icon="reload"></input>
1677 <action>refresh:INTERFACE_LIST</action>
1678 </button>
1679 <button>
1680 <label>Full status</label>
1681 <input file icon="dialog-information"></input>
1682 <action type="launch">IFCONFIG</action>
1683 </button>
1684 <button help>
1685 <label>Help</label>
1686 <action type="launch">HELP</action>
1687 </button>
1688 <button>
1689 <label>Quit</label>
1690 <input file icon="exit"></input>
1691 <action type="exit">Exit</action>
1692 </button>
1693 </hbox>
1695 </vbox>
1696 </window>
1699 NET_BOX="${head}$(tab_main)${bottom}"
1701 export NET_BOX
1703 # TODO: Modules(Network kernel modules)
1705 # Only root can configure network.
1706 check_root
1708 # Configure and connect if button Connect was pressed.
1709 if ! grep -qs ^name /etc/ppp/options ; then
1710 # Generate /etc/ppp/options
1711 cat > /etc/ppp/options << _EOT_
1712 plugin rp-pppoe.so
1713 name provider-ID
1714 noipdefault
1715 defaultroute
1716 mtu 1492
1717 mru 1492
1718 lock
1719 _EOT_
1720 # Generate /etc/ppp/pap-secrets
1721 cat > /etc/ppp/pap-secrets << _EOT_
1722 # Secrets for authentication using PAP
1723 # client server secret IP addresses
1724 _EOT_
1725 # Generate /etc/ppp/chap-secrets
1726 cat > /etc/ppp/chap-secrets << _EOT_
1727 # Secrets for authentication using CHAP
1728 # client server secret IP addresses
1729 _EOT_
1730 fi
1731 gtkdialog --center --program=NET_BOX | grep -a 'EXIT="restart"' && continue
1732 exit 0
1733 done