slitaz-tools view tinyutils/netbox @ rev 261

netbox: do not always reconfigure lo and hostname
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Jul 22 22:33:51 2008 +0000 (2008-07-22)
parents 8859d482a3b1
children dcb02be8076c
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box to manage network connection.
4 # - SliTaz GNU/Linux 2008.
5 #
6 VERSION=20080719
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 while true; do
31 # Detect WIFI_INTERFACE and update /etc/network.conf
32 . /etc/network.conf
33 if [ ! -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
34 WIFI_INTERFACE=$(for i in /sys/class/net/*/wireless; do \
35 [ -d $i ] && echo $(basename $(dirname $i)) || echo wlan0; \
36 break; done)
37 [ -n "$WIFI_INTERFACE" ] && sed -i "s/^WIFI_INTERFACE=.*/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" /etc/network.conf
38 fi
40 ESSIDS=""
41 # Detect ESSID list
42 if [ -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
43 ifconfig $WIFI_INTERFACE up
44 for i in $(iwlist $WIFI_INTERFACE scanning | grep "ESSID" | \
45 grep -v "<hidden>" | sed -n 's/ESSID:"//p' | sed -n 's/"//p'); do
46 ESSIDS="$ESSIDS<item>$i</item>"
47 done
48 fi
50 if [ "$1" = "call" ]; then
51 ppp="pppd local lock notty"
52 pppup=""
53 sub=$2
54 shift 2
55 case "$sub" in
56 sendsshkey)
57 check_root
58 dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key | \
59 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*"
60 exit 0;;
61 vpnssh) check_root
62 set_ipup
63 ps ww | grep -q "$ppp $2:$3" && exit 1
64 pipe="/tmp/ssh$$"
65 mkfifo $pipe
66 [ -n "$4" ] && pppup="ipparam 'addroutes,$(echo $4 | sed 's/ /,/g')'"
67 cat $pipe | dbclient -i /etc/dropbear/dropbear_rsa_host_key \
68 $1 "$ppp" | $ppp $2:$3 $pppup > $pipe
69 rm -f $pipe
70 exit 0;;
71 killvpnssh)
72 check_root
73 kill $(ps x | grep dbclient | grep "$ppp" | awk '{ print $1 }')
74 exit 0;;
75 ipup)
76 # Arg Name Example
77 # $1 Interface name ppp0
78 # $2 The tty ttyS1
79 # $3 The link speed 38400
80 # $4 Local IP number 12.34.56.78
81 # $5 Peer IP number 12.34.56.99
82 # $6 Optional ``ipparam'' value foo
83 iface=$1
84 # skip tty if present
85 case "$2" in [0-9]*);; *) shift; esac
86 peer=$4
87 IFS=","; set -- $(eval echo $5); unset IFS
88 set -- $1
89 if [ "$1" = "addroutes" ]; then
90 while [ -n "$2" ]; do
91 eval $(ipcalc -n $2)
92 eval $(ipcalc -m $2)
93 route add -net $NETWORK netmask $NETMASK \
94 gw $peer $iface
95 shift
96 done
97 fi
98 exit 0;;
99 esac
100 echo "call $sub unsupported."
101 exit 1
102 fi
104 # English/French help dialog.
105 export HELP='
106 <window title="Network status" icon-name="network-wire">
107 <vbox>
108 <text use-markup="true">
109 <label>"
110 <b>SliTaz - Netbox</b>"
111 </label>
112 </text>
113 <frame English>
114 <text wrap="true" width-chars="58">
115 <label>
116 "Netbox lets you manage network connections by getting dynamic IP by DHCP
117 or static IP and setup servers. Netbox can start or stop networking,
118 configure network interfaces or directly edit files."
119 </label>
120 </text>
121 </frame>
122 <frame Francais>
123 <text wrap="true" width-chars="58">
124 <label>
125 "Netbox vous permet de gerer les connexions reseau avec une IP
126 statique ou en obtenant une IP dynamique par DHCP, et de parametrer
127 les serveurs. Netbox peut demarrer ou arreter le reseau, configurer
128 les interfaces reseau ou editer directement les fichiers."
129 </label>
130 </text>
131 </frame>
132 </vbox>
133 </window>
134 '
136 # Interafce status with ifconfig without arguments to show all
137 # active connections.
138 #
139 export IFCONFIG='
140 <window title="Network status" icon-name="network-wire">
141 <vbox>
142 <text wrap="false">
143 <input>date</input>
144 </text>
145 <notebook labels="Network interfaces'
146 [ -x /usr/sbin/iwlist ] && IFCONFIG="$IFCONFIG|Wireless interfaces|Wireless networks"
147 tmp='|Routing|Servers">
148 <frame Ifconfig>
149 <text wrap="false" width-chars="58">
150 <input>ifconfig</input>
151 </text>
152 </frame>'
153 IFCONFIG="$IFCONFIG$tmp"
154 tmp='<frame Iwconfig>
155 <text wrap="false" width-chars="58">
156 <input>iwconfig</input>
157 </text>
158 </frame>
159 <frame Wireless networks>
160 <text wrap="false" width-chars="58">
161 <input>iwlist scan</input>
162 </text>
163 </frame>'
164 [ -x /usr/sbin/iwlist ] && IFCONFIG="$IFCONFIG$tmp"
165 tmp='<frame Routing>
166 <frame Nameservers>
167 <text wrap="false" width-chars="58">
168 <input>cat /etc/resolv.conf</input>
169 </text>
170 </frame>
171 <frame Routing table>
172 <text wrap="false" width-chars="58">
173 <input>route</input>
174 </text>
175 </frame>
176 <frame Arp table>
177 <text wrap="false" width-chars="58">
178 <input>arp</input>
179 </text>
180 </frame>
181 </frame>
182 <frame Servers>
183 <text wrap="false" width-chars="58">
184 <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>
185 </text>
186 </frame>
187 </notebook>
188 <hbox>
189 <button>
190 <input file icon="gtk-close"></input>
191 <action type="closewindow">IFCONFIG</action>
192 </button>
193 </hbox>
194 </vbox>
195 </window>
196 '
197 IFCONFIG="$IFCONFIG$tmp"
199 # The main dialog with notebook, start/stop buttons and all options.
200 # Note that /etc/network.conf is seded when an interface is activated.
201 #
202 NET_BOX='
203 <window title="SliTaz Netbox Manager" icon-name="network-wired">
204 <vbox>
206 <hbox>
207 <text use-markup="true">
208 <label>"<b>Network/Server Manager</b>"</label>
209 </text>
210 <pixmap>
211 <input file>/usr/share/pixmaps/netbox.png</input>
212 </pixmap>
213 </hbox>
215 <frame General>
216 <hbox>
217 <text use-markup="true">
218 <label>"<b>Interface :</b>"</label>
219 </text>
220 <combobox>
221 <variable>INTERFACE</variable>'
222 . /etc/network.conf
223 NET_BOX="$NET_BOX<item>$INTERFACE</item>$(for dev in $(ls /sys/class/net); do
224 echo "<item>$dev</item>"; done)"
225 tmp=' </combobox>
226 </hbox>
227 </frame>
229 <notebook labels="DHCP|PPPoE|PPP|Static IP|Wifi|System wide|VPN|Servers'
230 NET_BOX="$NET_BOX$tmp"
231 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX|Firewall"
232 tmp='|Etherwake">
234 <frame Udhcpc>
235 <hbox>
236 <text use-markup="true">
237 <label>"<b>Options :</b>"</label>
238 </text>
239 <entry>
240 <default>-b</default>
241 <variable>UDHCPC_OPTS</variable>
242 </entry>
243 <button>
244 <input file icon="help"></input>
245 <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>
246 </button>
247 </hbox>
248 <hbox>
249 <text use-markup="true">
250 <label>"<b>Script :</b>"</label>
251 </text>
252 <entry editable="false">
253 <default>/usr/share/udhcpc/default.script</default>
254 <variable>UDHCPC_SCRIPT</variable>
255 </entry>
256 <button>
257 <input file icon="accessories-text-editor"></input>
258 <action type="lauch">leafpad $UDHCPC_SCRIPT</action>
259 </button>
260 </hbox>
261 <hbox>
262 <button>
263 <label>Start</label>
264 <input file icon="forward"></input>
265 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
266 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
267 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
268 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
269 </button>
270 <button>
271 <label>Stop</label>
272 <input file icon="stop"></input>
273 <action>echo -n "Stopping interface : $INTERFACE... "</action>
274 <action>ifconfig $INTERFACE down</action>
275 <action>killall -q udhcpc; echo "done"</action>
276 </button>
277 </hbox>
278 </frame>
280 <frame PPPoE>
281 <hbox>
282 <text use-markup="true">
283 <label>"<b>Name :</b>"</label>
284 </text>
285 <entry>
286 <input>NAME=$(grep -s ^name /etc/ppp/options); echo "${NAME#* }"</input>
287 <variable>NAME</variable>
288 </entry>
289 </hbox>
290 <hbox>
291 <text use-markup="true">
292 <label>"<b>Username :</b>"</label>
293 </text>
294 <entry>
295 <variable>USER</variable>
296 </entry>
297 </hbox>
298 <hbox>
299 <text use-markup="true">
300 <label>"<b>Password :</b>"</label>
301 </text>
302 <entry>
303 <variable>PASS</variable>
304 </entry>
305 </hbox>
306 <hbox>
307 <button>
308 <input file icon="help"></input>
309 <label>Help</label>
310 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "pppd help (q to quit)" -e "pppd --help 2>&1 | less"</action>
311 </button>
312 <button>
313 <input file icon="accessories-text-editor"></input>
314 <label>Tune</label>
315 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
316 <action type="lauch">leafpad /etc/ppp/options</action>
317 </button>
318 <button>
319 <label>Start</label>
320 <input file icon="forward"></input>
321 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
322 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
323 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
324 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
325 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
326 <action>killall udhcpc</action>
327 <action>sed -i "s/DHCP=\"yes\"/DHCP=\"no\"/" /etc/network.conf</action>
328 <action>sed -i "s/PPPOE=\"no\"/PPPOE=\"yes\"/" /etc/network.conf</action>
329 <action>pppd $INTERFACE &</action>
330 </button>
331 <button>
332 <label>Stop</label>
333 <input file icon="stop"></input>
334 <action>sed -i "s/PPPOE=\"yes\"/PPPOE=\"no\"/" /etc/network.conf</action>
335 <action>killall pppd</action>
336 </button>
337 </hbox>
338 </frame>
340 <frame PPP>
341 <hbox>
342 <text use-markup="true">
343 <label>"<b>Username :</b>"</label>
344 </text>
345 <entry>
346 <input>USER=$(grep -s ^ACCOUNT= /etc/ppp/scripts/ppp-on | cut -f1); echo "${USER#*=}"</input>
347 <variable>USER</variable>
348 </entry>
349 </hbox>
350 <hbox>
351 <text use-markup="true">
352 <label>"<b>Password :</b>"</label>
353 </text>
354 <entry>
355 <input>PASS=$(grep -s ^PASSWORD= /etc/ppp/scripts/ppp-on | cut -f1); echo "${PASS#*=}"</input>
356 <variable>PASS</variable>
357 </entry>
358 </hbox>
359 <hbox>
360 <text use-markup="true">
361 <label>"<b>Telephone:</b>"</label>
362 </text>
363 <entry>
364 <input>PHONE=$(grep -s ^TELEPHONE= /etc/ppp/scripts/ppp-on | cut -f1); echo "${PHONE#*=}"</input>
365 <variable>PHONE</variable>
366 </entry>
367 </hbox>
368 <hbox>
369 <button>
370 <input file icon="help"></input>
371 <label>Help</label>
372 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "pppd help (q to quit)" -e "pppd --help 2>&1 | less"</action>
373 </button>
374 <button>
375 <input file icon="accessories-text-editor"></input>
376 <label>Tune</label>
377 <action>[ -n "$NAME" ] && sed -i "s/^ACCOUNT=.*/ACCOUNT=$NAME/" /etc/ppp/scripts/ppp-on</action>
378 <action>[ -n "$PASS" ] && sed -i "s/^PASSWORD=.*/PASSWORD=$PASS/" /etc/ppp/scripts/ppp-on</action>
379 <action>[ -n "$PHONE" ] && sed -i "s/^TELEPHONE=.*/TELEPHONE=$PHONE/" /etc/ppp/scripts/ppp-on</action>
380 <action type="lauch">leafpad /etc/ppp/scripts/ppp-on</action>
381 </button>
382 <button>
383 <label>Start</label>
384 <input file icon="forward"></input>
385 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
386 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
387 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
388 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
389 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
390 <action>/etc/ppp/scripts/ppp-off</action>
391 <action>/etc/ppp/scripts/ppp-on &</action>
392 </button>
393 <button>
394 <label>Stop</label>
395 <input file icon="stop"></input>
396 <action>/etc/ppp/scripts/ppp-off</action>
397 </button>
398 </hbox>
399 </frame>
401 <frame Configuration>
402 <hbox>
403 <text use-markup="true">
404 <label>"<b>IP :</b>"</label>
405 </text>
406 <entry>
407 <input>. /etc/network.conf; echo "$IP"</input>
408 <variable>IP</variable>
409 </entry>
410 </hbox>
411 <hbox>
412 <text use-markup="true">
413 <label>"<b>Netmask :</b>"</label>
414 </text>
415 <entry>
416 <input>. /etc/network.conf; echo "$NETMASK"</input>
417 <variable>NETMASK</variable>
418 </entry>
419 </hbox>
420 <hbox>
421 <text use-markup="true">
422 <label>"<b>Gateway :</b>"</label>
423 </text>
424 <entry>
425 <input>. /etc/network.conf; echo "$GATEWAY"</input>
426 <variable>GATEWAY</variable>
427 </entry>
428 </hbox>
429 <hbox>
430 <text use-markup="true">
431 <label>"<b>DNS server :</b>"</label>
432 </text>
433 <entry>
434 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
435 <variable>DNS_SERVER</variable>
436 </entry>
437 </hbox>
438 <hbox>
439 <button>
440 <label>Start</label>
441 <input file icon="forward"></input>
442 <action>ifconfig lo down</action>
443 <action>ifconfig $INTERFACE down</action>
444 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
445 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
446 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
447 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
448 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
449 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
450 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
451 <action>/etc/init.d/network.sh</action>
452 </button>
453 <button>
454 <label>Stop</label>
455 <input file icon="stop"></input>
456 <action>echo -n "Stopping interface : $INTERFACE... "</action>
457 <action>ifconfig $INTERFACE down; echo "done"</action>
458 </button>
459 </hbox>
460 </frame>'
461 NET_BOX="$NET_BOX$tmp"
462 tmp='<frame Wireless>
463 <notebook labels="Interface|Extra parameters'
464 [ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp|Kernel Modules"
465 tmp2='">
466 <vbox>
467 <hbox>
468 <text use-markup="true">
469 <label>"<b>Interface :</b>"</label>
470 </text>
471 <entry>
472 <input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
473 <variable>WIFI_INTERFACE</variable>
474 </entry>
475 <text use-markup="true">
476 <label>"<b>ESSID :</b>"</label>
477 </text>
478 <combobox>'
479 . /etc/network.conf
480 tmp2="$tmp2<item>$WIFI_ESSID</item>$ESSIDS<variable>WIFI_ESSID</variable>"
481 tmp3='</combobox>
482 </hbox>
483 <hbox>
484 <text use-markup="true">
485 <label>"<b>Key :</b>"</label>
486 </text>
487 <entry>
488 <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
489 <variable>WIFI_KEY</variable>
490 </entry>
491 <combobox>'
492 tmp2="$tmp2$tmp3<item>$WIFI_KEY_TYPE</item>"
493 for i in none WEP WPA any; do
494 [ "$i" = "$WIFI_KEY_TYPE" ] || tmp2="$tmp2<item>$i</item>"
495 done
496 tmp3=' <variable>WIFI_KEY_TYPE</variable>
497 </combobox>
498 </hbox>
499 </vbox>
500 <vbox>
501 <hbox>
502 <text use-markup="true">
503 <label>"<b>Channel :</b>"</label>
504 </text>
505 <entry>
506 <input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
507 <variable>WIFI_CHANNEL</variable>
508 </entry>
509 <text use-markup="true">
510 <label>"<b>Mode :</b>"</label>
511 </text>
512 <combobox>
513 <variable>WIFI_MODE</variable>'
514 tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
515 for i in managed ad-hoc master repeater secondary monitor; do
516 [ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
517 done
518 tmp3='</combobox>
519 </hbox>
520 <hbox>
521 <text use-markup="true">
522 <label>"<b>Other iwconfig args :</b>"</label>
523 </text>
524 <entry>
525 <input>. /etc/network.conf; echo "$WIFI_IWCONFIG_ARGS"</input>
526 <variable>WIFI_IWCONFIG_ARGS</variable>
527 </entry>
528 <button>
529 <input file icon="help"></input>
530 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x24 -title "iwconfig help" -e "iwconfig --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
531 </button>
532 <button>
533 <input file icon="help"></input>
534 <label>man</label>
535 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x24 -title "iwconfig man (q to quit)" -e ". /etc/profile; man 8 iwconfig"</action>
536 </button>
537 </hbox>
538 </vbox>'
539 tmp="$tmp$tmp2$tmp3"
540 tmp2='<vbox>
541 <hbox>
542 <button>
543 <label>Load</label>
544 <input file icon="forward"></input>
545 <action>modprobe $MODULE</action>
546 <action type="exit">restart</action>
547 </button>
548 <button>
549 <label>Unload</label>
550 <input file icon="forward"></input>
551 <action>modprobe -r $MODULE</action>
552 <action type="exit">restart</action>
553 </button>
554 <text use-markup="true">
555 <label>"<b>Wifi Module :</b>"</label>
556 </text>
557 <combobox>
558 <variable>MODULE</variable>'
559 tmp2="$tmp2$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f | sed 's,/.*/\(.*\).ko.gz,<item>\1</item>,')"
560 tmp3='</combobox>
561 <button>
562 <label>Lsmod</label>
563 <input file icon="computer"></input>
564 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
565 </button>
566 </hbox>'
567 tmp2="$tmp2$tmp3"
568 tmp3=$(for i in /usr/bin/get*firmware; do
569 [ -x $i ] || continue
570 [ "$i" = "/usr/bin/get-wifi-firmware" ] && continue
571 [ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue
572 echo "<item>${i#/usr/bin/get-}</item>"; done)
573 [ -n "$tmp3" ] && tmp3="
574 <hbox>
575 <text use-markup=\"true\">
576 <label>\"<b>Firmware :</b>\"</label>
577 </text>
578 <combobox><variable>FIRMWARE</variable>$tmp3</combobox>
579 <button>
580 <label>Install</label>
581 <input file icon=\"go-jump\"></input>
582 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
583 <action type=\"exit\">restart</action>
584 </button>
585 <button>
586 <input file icon=\"system-file-manager\"></input>
587 <label>Firmware files</label>
588 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 100x25 -title \"Firmware files (q to quit)\" -e \"find /lib/firmware -exec ls -ld {} \; | less\"</action>
589 </button>
590 </hbox>
591 "
592 tmp2="$tmp2$tmp3"
593 tmp3='
594 <hbox>
595 <text wrap="true" use-markup="true">
596 <label>
597 "<i>The package <b>ndiswrapper</b> is not yet installed</i>"
598 </label>
599 </text>
600 <button>
601 <input file icon="go-jump"></input>
602 <label>Install</label>
603 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "ndiswrapper install" -e "yes y | tazpkg get-install ndiswrapper ; echo -e \"----\n\nENTER to continue...\" && read close"</action>
604 <action type="exit">restart</action>
605 </button>
606 </hbox>
607 '
608 [ -x /usr/sbin/ndiswrapper ] && tmp3='
609 <hbox>
610 <text use-markup="true">
611 <label>"<b>Ndiswrapper drivers :</b>"</label>
612 </text>
613 <entry>
614 <input>. /etc/network.conf; echo "$NDISWRAPPER_DRIVERS"</input>
615 <variable>NDISWRAPPER_DRIVERS</variable>
616 </entry>
617 <button>
618 <label>Restart</label>
619 <input file icon="reload"></input>
620 <action>rmmod ndiswrapper</action>
621 <action>for i in $NDISWRAPPER_DRIVERS; do ndiswrapper -i $i; done</action>
622 <action>modprobe ndiswrapper</action>
623 </button>
624 </hbox>
625 '
626 tmp3="$tmp3</vbox>"
627 [ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp$tmp2$tmp3"
628 tmp2='</notebook>
629 <hbox>
630 <button>
631 <label>Start</label>
632 <input file icon="forward"></input>
633 <action>[ "$WIFI_KEY_TYPE" = "WPA" -a ! -x /usr/bin/wpa_supplicant ] && xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wpa_supplicant install" -e "tazpkg get-install wpa_supplicant ; echo -e \"----\n\nENTER to continue...\" && read close"</action>
634 <action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"yes\"/ /etc/network.conf</action>
635 <action>sed -i s/`grep ^WIFI_INTERFACE= /etc/network.conf`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
636 <action>sed -i s/`grep ^WIFI_ESSID= /etc/network.conf`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
637 <action>sed -i s/`grep ^WIFI_KEY= /etc/network.conf`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
638 <action>sed -i s/`grep ^WIFI_MODE= /etc/network.conf`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
639 <action>sed -i "s/`grep ^WIFI_IWCONFIG_ARGS= /etc/network.conf`/WIFI_IWCONFIG_ARGS=\"$WIFI_IWCONFIG_ARGS\"/" /etc/network.conf</action>
640 <action>sed -i s/`grep ^WIFI_KEY_TYPE= /etc/network.conf`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
641 <action>sed -i s/`grep ^WIFI_CHANNEL= /etc/network.conf`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
642 <action>sed -i "s/`grep ^NDISWRAPPER_DRIVERS= /etc/network.conf`/NDISWRAPPER_DRIVERS=\"$NDISWRAPPER_DRIVERS\"/" /etc/network.conf</action>
643 <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
644 <action>ifconfig $WIFI_INTERFACE down</action>
645 <action>iwconfig $WIFI_INTERFACE txpower auto</action>
646 <action>/etc/init.d/network.sh restart</action>
647 </button>
648 <button>
649 <label>Stop</label>
650 <input file icon="stop"></input>
651 <action>sed -i s/`grep ^WIFI= /etc/network.conf`/WIFI=\"no\"/ /etc/network.conf</action>
652 <action>[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop</action>
653 <action>ifconfig $WIFI_INTERFACE down</action>
654 <action>iwconfig $WIFI_INTERFACE txpower off</action>
655 <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
656 </button>
657 </hbox>
658 </frame>'
659 [ -x /usr/sbin/iwconfig ] && NET_BOX="$NET_BOX$tmp$tmp2"
660 tmp='<frame Wireless>
661 <hbox>
662 <text wrap="true" use-markup="true">
663 <label>
664 "<i>The package <b>wireless_tools</b> is not yet installed</i>"
665 </label>
666 </text>
667 <button>
668 <input file icon="go-jump"></input>
669 <label>Install</label>
670 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x17 -title "wireless_tools install" -e "yes y | tazpkg get-install wireless_tools ; echo -e \"----\n\nENTER to continue...\" && read close"</action>
671 <action type="exit">restart</action>
672 </button>
673 </hbox>
674 </frame>'
675 [ -x /usr/sbin/iwconfig ] || NET_BOX="$NET_BOX$tmp"
676 tmp='<frame Configuration files>
677 <hbox>
678 <text use-markup="true">
679 <label>"<b>Hosts :</b>"</label>
680 </text>
681 <entry editable="false">
682 <default>/etc/hosts</default>
683 <variable>HOSTS</variable>
684 </entry>
685 <button>
686 <input file icon="accessories-text-editor"></input>
687 <action type="lauch">leafpad $HOSTS</action>
688 </button>
689 </hbox>
690 <hbox>
691 <text use-markup="true">
692 <label>"<b>Host name :</b>"</label>
693 </text>
694 <entry editable="false">
695 <default>/etc/hostname</default>
696 <variable>HOSTNAME</variable>
697 </entry>
698 <button>
699 <input file icon="accessories-text-editor"></input>
700 <action type="lauch">leafpad $HOSTNAME</action>
701 </button>
702 </hbox>
703 <hbox>
704 <text use-markup="true">
705 <label>"<b>Network :</b>"</label>
706 </text>
707 <entry editable="false">
708 <default>/etc/network.conf</default>
709 <variable>CONFIG_FILE</variable>
710 </entry>
711 <button>
712 <input file icon="accessories-text-editor"></input>
713 <action type="lauch">leafpad $CONFIG_FILE</action>
714 </button>
715 </hbox>
716 <hbox>
717 <button>
718 <label>Restart</label>
719 <input file icon="reload"></input>
720 <action>echo -n "Stopping interface : $INTERFACE... "</action>
721 <action>ifconfig $INTERFACE down</action>
722 <action>killall -q udhcpc; echo "done"</action>
723 <action>/etc/init.d/network.sh restart</action>
724 </button>
725 </hbox>
726 </frame>
728 <frame Virtual Private Network with PPP/SSH>
729 <hbox>
730 <text use-markup="true">
731 <label>"<b>Peer :</b>"</label>
732 </text>
733 <entry>
734 <variable>DROPBEAR_PEERVPN</variable>
735 <default>user@elsewhere</default>
736 </entry>
737 </hbox>
738 <hbox>
739 <text use-markup="true">
740 <label>"<b>Local IP :</b>"</label>
741 </text>
742 <entry>
743 <variable>DROPBEAR_LOCAL</variable>
744 <default>192.168.254.1</default>
745 </entry>
746 </hbox>
747 <hbox>
748 <text use-markup="true">
749 <label>"<b>Remote IP :</b>"</label>
750 </text>
751 <entry>
752 <variable>DROPBEAR_REMOTE</variable>
753 <default>192.168.254.2</default>
754 </entry>
755 </hbox>
756 <hbox>
757 <text use-markup="true">
758 <label>"<b>Route(s) :</b>"</label>
759 </text>
760 <entry>
761 <variable>DROPBEAR_ROUTE</variable>
762 <default>192.168.10.0/24 192.168.20.0/28</default>
763 </entry>
764 </hbox>
765 <hbox>
766 <button>
767 <input file icon="browser"></input>
768 <label>Wiki</label>
769 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:vpn &</action>
770 </button>
771 <button>
772 <input file icon="forward"></input>
773 <label>Connect</label>
774 <action>netbox call vpnssh $DROPBEAR_PEERVPN $DROPBEAR_LOCAL $DROPBEAR_REMOTE "$DROPBEAR_ROUTE" &</action>
775 </button>
776 <button>
777 <input file icon="stop"></input>
778 <label>Disconnect</label>
779 <action>netbox call killvpnssh</action>
780 </button>
781 <button>
782 <input file icon="go-up"></input>
783 <label>Send key</label>
784 <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>
785 </button>
786 </hbox>
787 </frame>
788 <notebook labels="'
789 NET_BOX="$NET_BOX$tmp"
790 tmp=''
791 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH" && tmp='|'
792 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}INETD" && tmp='|'
793 [ -x /sbin/zcip ] && NET_BOX="${NET_BOX}${tmp}ZEROCONF" && tmp='|'
794 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}DHCP" && tmp='|'
795 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
796 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] \
797 && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
798 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
799 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
800 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
801 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
802 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}VNC" && tmp='|'
803 . /etc/daemons.conf
804 set -- $DROPBEAR_OPTIONS
805 while [ -n "$2" ]; do
806 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
807 shift
808 done
809 NET_BOX="${NET_BOX}\">"
810 tmp='<frame Dropbear>
811 <hbox>
812 <text use-markup="true">
813 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
814 </text>
815 <entry editable="false">'
816 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
817 tmp2='
818 <variable>DROPBEAR_OPTS</variable>
819 </entry>
820 <button>
821 <input file icon="help"></input>
822 <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>
823 </button>
824 <button>
825 <input file icon="accessories-text-editor"></input>
826 <action type="lauch">leafpad /etc/daemons.conf</action>
827 </button>
828 </hbox>
829 <hbox>
830 <text use-markup="true">
831 <label>"<b>Banner :</b>"</label>
832 </text>
833 <entry editable="false">'
834 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
835 tmp2='
836 <variable>DROPBEAR_BANNER</variable>
837 </entry>
838 <button>
839 <input file icon="accessories-text-editor"></input>
840 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
841 </button>
842 </hbox>
843 <hbox>
844 <text use-markup="true">
845 <label>"<b>Remote :</b>"</label>
846 </text>
847 <entry>
848 <variable>DROPBEAR_PEER</variable>
849 <default>user@elsewhere</default>
850 </entry>
851 <button>
852 <input file icon="utilities-terminal"></input>
853 <label>Connect</label>
854 <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>
855 </button>
856 <button>
857 <input file icon="go-up"></input>
858 <label>Send key</label>
859 <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>
860 </button>
861 </hbox>
862 <hbox>
863 <button>
864 <label>Start</label>
865 <input file icon="forward"></input>
866 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
867 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
868 <action>/etc/init.d/dropbear start</action>
869 </button>
870 <button>
871 <label>Stop</label>
872 <input file icon="stop"></input>
873 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
874 <action>/etc/init.d/dropbear stop</action>
875 </button>
876 </hbox>
877 </frame>
878 '
879 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
880 tmp='<frame Inetd>
881 <hbox>
882 <text use-markup="true">
883 <label>"<b>INETD_OPTIONS</b>"</label>
884 </text>
885 <entry editable="false">'
886 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
887 tmp2='
888 <variable>INETD_OPTS</variable>
889 </entry>
890 <button>
891 <input file icon="help"></input>
892 <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>
893 </button>
894 <button>
895 <input file icon="accessories-text-editor"></input>
896 <action type="lauch">leafpad /etc/daemons.conf</action>
897 </button>
898 </hbox>
899 <hbox>
900 <text use-markup="true">
901 <label>"<b>Configuration :</b>"</label>
902 </text>
903 <entry editable="false">
904 <default>/etc/inetd.conf</default>
905 <variable>INETD_CONF</variable>
906 </entry>
907 <button>
908 <input file icon="accessories-text-editor"></input>
909 <action type="lauch">leafpad $INETD_CONF</action>
910 </button>
911 </hbox>
912 <hbox>
913 '
914 tmp="$tmp$tmp2"
915 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
916 i=$(basename $i)
917 tmp2="
918 <button>
919 <input file icon=\"help\"></input>
920 <label>$i</label>
921 <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>
922 </button>
923 "
924 tmp="$tmp$tmp2"
925 done
926 tmp2='
927 <button>
928 <label>Start</label>
929 <input file icon="forward"></input>
930 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
931 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
932 <action>/etc/init.d/inetd start</action>
933 </button>
934 <button>
935 <label>Stop</label>
936 <input file icon="stop"></input>
937 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
938 <action>/etc/init.d/inetd stop</action>
939 </button>
940 </hbox>
941 </frame>
942 '
943 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
944 if [ -x /sbin/zcip -a -z "$ZCIP_OPTS" ]; then
945 ZCIP_OPTS="eth0 /etc/zcip.script"
946 cat >> /etc/daemons.conf <<EOT
947 # ZeroConf options
948 ZCIP_OPTS="$ZCIP_OPTS"
950 EOT
951 fi
952 tmp='<frame Zcip>
953 <hbox>
954 <text use-markup="true">
955 <label>"<b>ZCIP_OPTS</b>"</label>
956 </text>
957 <entry editable="false">'
958 [ -n "$ZCIP_OPTS" ] && tmp="$tmp<default>$ZCIP_OPTS</default>"
959 tmp2='
960 <variable>ZCIP_OPTS</variable>
961 </entry>
962 <button>
963 <input file icon="help"></input>
964 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 60x14 -title "zcip help" -e "zcip --help ; echo -e \"----\nENTER to continue...\" && read close"</action>
965 </button>
966 <button>
967 <input file icon="accessories-text-editor"></input>
968 <action type="lauch">leafpad /etc/daemons.conf</action>
969 </button>
970 </hbox>
971 <hbox>
972 <text use-markup="true">
973 <label>"<b>Script :</b>"</label>
974 </text>
975 <entry editable="false">
976 <default>/etc/zcip.script</default>
977 <variable>CZIP_SCRIPT</variable>
978 </entry>
979 <button>
980 <input file icon="accessories-text-editor"></input>
981 <action type="lauch">leafpad $CZIP_SCRIPT</action>
982 </button>
983 </hbox>
984 <hbox>
985 <button>
986 <label>Start</label>
987 <input file icon="forward"></input>
988 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)zcip \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
989 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"zcip \1\"/" /etc/rcS.conf</action>
990 <action>/etc/init.d/zcip start</action>
991 </button>
992 <button>
993 <label>Stop</label>
994 <input file icon="stop"></input>
995 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)zcip \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
996 <action>/etc/init.d/zcip stop</action>
997 </button>
998 </hbox>
999 </frame>
1001 [ -x /sbin/zcip ] && NET_BOX="${NET_BOX}$tmp$tmp2"
1002 tmp='<frame Dhcpd>
1003 <hbox>
1004 <text use-markup="true">
1005 <label>"<b>UDHCPD_OPTIONS</b>"</label>
1006 </text>
1007 <entry editable="false">'
1008 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
1009 tmp2='
1010 <variable>UDHCPD_OPTS</variable>
1011 </entry>
1012 <button>
1013 <input file icon="help"></input>
1014 <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>
1015 </button>
1016 <button>
1017 <input file icon="accessories-text-editor"></input>
1018 <action type="lauch">leafpad /etc/daemons.conf</action>
1019 </button>
1020 </hbox>
1021 <hbox>
1022 <text use-markup="true">
1023 <label>"<b>Configuration :</b>"</label>
1024 </text>
1025 <entry editable="false">
1026 <default>/etc/udhcpd.conf</default>
1027 <variable>UDHCPD_CONF</variable>
1028 </entry>
1029 <button>
1030 <input file icon="accessories-text-editor"></input>
1031 <action type="lauch">leafpad $UDHCPD_CONF</action>
1032 </button>
1033 </hbox>
1034 <hbox>
1035 <button>
1036 <label>Start</label>
1037 <input file icon="forward"></input>
1038 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1039 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
1040 <action>/etc/init.d/udhcpd start</action>
1041 </button>
1042 <button>
1043 <label>Stop</label>
1044 <input file icon="stop"></input>
1045 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1046 <action>/etc/init.d/udhcpd stop</action>
1047 </button>
1048 </hbox>
1049 </frame>
1051 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
1052 tmp='<frame Pxelinux>
1053 <hbox>
1054 <text wrap="true">
1055 <label>
1056 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
1057 </label>
1058 </text>
1059 </hbox>
1060 <hbox>
1061 <text use-markup="true">
1062 <label>"<b>Configuration :</b>"</label>
1063 </text>
1064 <entry editable="false">
1065 <default>'
1066 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
1067 tmp2='/pxelinux.cfg/default</default>
1068 <variable>PXE_CONF</variable>
1069 </entry>
1070 <button>
1071 <input file icon="accessories-text-editor"></input>
1072 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
1073 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
1074 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
1075 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
1076 <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>
1077 <action type="lauch">leafpad $PXE_CONF</action>
1078 </button>
1079 </hbox>
1080 <hbox>
1081 <button>
1082 <input file icon="browser"></input>
1083 <label>Wiki</label>
1084 <action>firefox http://wiki.slitaz.org/doku.php?id=quickstart:pxe &</action>
1085 </button>
1086 <button>
1087 <input file icon="system-file-manager"></input>
1088 <label>Network boot files</label>
1089 <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>
1090 </button>
1091 </hbox>
1092 </frame>
1094 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
1095 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
1096 tmp='<frame Dnsd>
1097 <hbox>
1098 <text use-markup="true">
1099 <label>"<b>DNSD_OPTIONS</b>"</label>
1100 </text>
1101 <entry editable="false">'
1102 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
1103 tmp2='
1104 <variable>DNSD_OPTS</variable>
1105 </entry>
1106 <button>
1107 <input file icon="help"></input>
1108 <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>
1109 </button>
1110 <button>
1111 <input file icon="accessories-text-editor"></input>
1112 <action type="lauch">leafpad /etc/daemons.conf</action>
1113 </button>
1114 </hbox>
1115 <hbox>
1116 <text use-markup="true">
1117 <label>"<b>Configuration :</b>"</label>
1118 </text>
1119 <entry editable="false">
1120 <default>/etc/dnsd.conf</default>
1121 <variable>DNSD_CONF</variable>
1122 </entry>
1123 <button>
1124 <input file icon="accessories-text-editor"></input>
1125 <action type="lauch">leafpad $DNSD_CONF</action>
1126 </button>
1127 </hbox>
1128 <hbox>
1129 <button>
1130 <label>Start</label>
1131 <input file icon="forward"></input>
1132 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1133 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
1134 <action>/etc/init.d/dnsd start</action>
1135 </button>
1136 <button>
1137 <label>Stop</label>
1138 <input file icon="stop"></input>
1139 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1140 <action>/etc/init.d/dnsd stop</action>
1141 </button>
1142 </hbox>
1143 </frame>
1145 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1146 tmp='<frame Rsync>
1147 <hbox>
1148 <text use-markup="true">
1149 <label>"<b>RSYNCD_OPTIONS</b>"</label>
1150 </text>
1151 <entry editable="false">'
1152 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
1153 tmp2='
1154 <variable>RSYNC_OPTS</variable>
1155 </entry>
1156 <button>
1157 <input file icon="help"></input>
1158 <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>
1159 </button>
1160 <button>
1161 <input file icon="accessories-text-editor"></input>
1162 <action type="lauch">leafpad /etc/daemons.conf</action>
1163 </button>
1164 </hbox>
1165 <hbox>
1166 <text use-markup="true">
1167 <label>"<b>Configuration :</b>"</label>
1168 </text>
1169 <entry editable="false">
1170 <default>/etc/rsyncd.conf</default>
1171 <variable>RSYNCD_CONF</variable>
1172 </entry>
1173 <button>
1174 <input file icon="accessories-text-editor"></input>
1175 <action type="lauch">leafpad $RSYNCD_CONF</action>
1176 </button>
1177 </hbox>
1178 <hbox>
1179 <text use-markup="true">
1180 <label>"<b>Secrets file :</b>"</label>
1181 </text>
1182 <entry editable="true">
1183 <default>/etc/rsyncd.secrets</default>
1184 <variable>RSYNCD_SECRETS</variable>
1185 </entry>
1186 <button>
1187 <input file icon="accessories-text-editor"></input>
1188 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
1189 </button>
1190 </hbox>
1191 <hbox>
1192 <button>
1193 <label>Start</label>
1194 <input file icon="forward"></input>
1195 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1196 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
1197 <action>/etc/init.d/rsyncd start</action>
1198 </button>
1199 <button>
1200 <label>Stop</label>
1201 <input file icon="stop"></input>
1202 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1203 <action>/etc/init.d/rsyncd stop</action>
1204 </button>
1205 </hbox>
1206 </frame>
1208 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1209 tmp='<frame Lighttpd>'
1210 tmp2='<frame PHP>
1211 <hbox>
1212 <text use-markup="true">
1213 <label>"<b>Configuration :</b>"</label>
1214 </text>
1215 <entry editable="false">
1216 <default>/etc/php.ini</default>
1217 <variable>PHP_CONF</variable>
1218 </entry>
1219 <button>
1220 <input file icon="accessories-text-editor"></input>
1221 <action type="lauch">leafpad $PHP_CONF</action>
1222 </button>
1223 </hbox>
1224 </frame>
1226 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
1227 tmp2='<hbox>
1228 <text use-markup="true">
1229 <label>"<b>Configuration :</b>"</label>
1230 </text>
1231 <entry editable="false">
1232 <default>/etc/lighttpd/lighttpd.conf</default>
1233 <variable>LIGHTTPD_CONF</variable>
1234 </entry>
1235 <button>
1236 <input file icon="accessories-text-editor"></input>
1237 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
1238 </button>
1239 </hbox>
1240 <hbox>
1241 <button>
1242 <label>Start</label>
1243 <input file icon="forward"></input>
1244 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1245 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
1246 <action>/etc/init.d/lighttpd start</action>
1247 </button>
1248 <button>
1249 <label>Stop</label>
1250 <input file icon="stop"></input>
1251 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1252 <action>/etc/init.d/lighttpd stop</action>
1253 </button>
1254 </hbox>
1255 </frame>
1257 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1258 tmp='<frame Samba: smbd & nmbd>
1259 <hbox>
1260 <text use-markup="true">
1261 <label>"<b>Configuration :</b>"</label>
1262 </text>
1263 <entry editable="false">
1264 <default>/etc/samba/smb.conf</default>
1265 <variable>SMBD_CONF</variable>
1266 </entry>
1267 <button>
1268 <input file icon="accessories-text-editor"></input>
1269 <action type="lauch">leafpad $SMBD_CONF</action>
1270 </button>
1271 </hbox>
1272 <hbox>
1273 <button>
1274 <label>Reload</label>
1275 <input file icon="reload"></input>
1276 <action>/etc/init.d/samba reload</action>
1277 </button>
1278 <button>
1279 <label>Start</label>
1280 <input file icon="forward"></input>
1281 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1282 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
1283 <action>/etc/init.d/samba start</action>
1284 </button>
1285 <button>
1286 <label>Stop</label>
1287 <input file icon="stop"></input>
1288 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1289 <action>/etc/init.d/samba stop</action>
1290 </button>
1291 </hbox>
1292 </frame>
1294 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
1295 tmp='<frame x11vnc>
1296 <hbox>
1297 <text use-markup="true">
1298 <label>"<b>X11VNC_OPTIONS</b>"</label>
1299 </text>
1300 <entry editable="false">'
1301 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
1302 tmp2='
1303 <variable>X11VNC_OPTS</variable>
1304 </entry>
1305 <button>
1306 <input file icon="help"></input>
1307 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
1308 </button>
1309 <button>
1310 <input file icon="accessories-text-editor"></input>
1311 <action type="lauch">leafpad /etc/daemons.conf</action>
1312 </button>
1313 </hbox>
1314 <hbox>
1315 <text use-markup="true">
1316 <label>"<b>New password</b>"</label>
1317 </text>
1318 <entry>
1319 <variable>X11VNC_PASSWD</variable>
1320 </entry>
1321 <button>
1322 <input file icon="reload"></input>
1323 <label>Update</label>
1324 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
1325 </button>
1326 </hbox>
1327 <hbox>
1328 <button>
1329 <label>Start</label>
1330 <input file icon="forward"></input>
1331 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1332 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
1333 <action>/etc/init.d/x11vnc start</action>
1334 </button>
1335 <button>
1336 <label>Stop</label>
1337 <input file icon="stop"></input>
1338 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1339 <action>/etc/init.d/x11vnc stop</action>
1340 </button>
1341 </hbox>
1342 </frame>
1344 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1345 NET_BOX="${NET_BOX}
1346 </notebook>
1348 tmp='<frame Iptables>
1349 <hbox>
1350 <text use-markup="true">
1351 <label>"<b>Configuration :</b>"</label>
1352 </text>
1353 <entry editable="false">
1354 <default>/etc/iptables.conf</default>
1355 <variable>IPTABLES_CONF</variable>
1356 </entry>
1357 <button>
1358 <input file icon="accessories-text-editor"></input>
1359 <action type="lauch">leafpad $IPTABLES_CONF</action>
1360 </button>
1361 </hbox>
1362 <hbox>
1363 <button>
1364 <label>Load</label>
1365 <input file icon="reload"></input>
1366 <action>cat $IPTABLES_CONF | /sbin/iptables-restore</action>
1367 </button>
1368 <button>
1369 <label>Save</label>
1370 <input file icon="go-jump"></input>
1371 <action>/sbin/iptables-save > $IPTABLES_CONF</action>
1372 </button>
1373 </hbox>
1374 </frame>
1376 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
1377 tmp='
1378 <frame Ether-wake>
1379 <hbox>
1380 <text use-markup="true">
1381 <label>"<b>Machines :</b>"</label>
1382 </text>
1383 <entry editable="false">
1384 <default>/etc/ethers</default>
1385 <variable>ETHERS</variable>
1386 </entry>
1387 <button>
1388 <input file icon="accessories-text-editor"></input>
1389 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
1390 <action type="lauch">leafpad $ETHERS</action>
1391 </button>
1392 </hbox>
1393 <hbox>
1394 <text use-markup="true">
1395 <label>"<b>Options : </b>"</label>
1396 </text>
1397 <entry editable="false">
1398 <variable>ETHERWAKE_OPTS</variable>
1399 </entry>
1400 <button>
1401 <input file icon="help"></input>
1402 <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>
1403 </button>
1404 <button>
1405 <label>Start</label>
1406 <input file icon="forward"></input>
1407 <action>ether-wake $ETHERWAKE_OPTS</action>
1408 </button>
1409 </hbox>
1410 </frame>
1411 </notebook>
1413 <hbox>
1414 <button>
1415 <label>Status</label>
1416 <input file icon="dialog-information"></input>
1417 <action type="launch">IFCONFIG</action>
1418 </button>
1419 <button help>
1420 <label>Help</label>
1421 <action type="launch">HELP</action>
1422 </button>
1423 <button>
1424 <label>Quit</label>
1425 <input file icon="exit"></input>
1426 <action type="exit">Exit</action>
1427 </button>
1428 </hbox>
1430 </vbox>
1431 </window>
1433 NET_BOX="${NET_BOX}${tmp}"
1435 export NET_BOX
1437 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
1439 # Only root can configure network.
1440 check_root
1441 # Configure and connect if button Connect was pressed.
1442 if ! grep -qs ^name /etc/ppp/options ; then
1443 # Generate /etc/ppp/options
1444 cat > /etc/ppp/options << _EOT_
1445 plugin rp-pppoe.so
1446 name provider-ID
1447 noipdefault
1448 defaultroute
1449 mtu 1492
1450 mru 1492
1451 lock
1452 _EOT_
1453 # Generate /etc/ppp/pap-secrets
1454 cat > /etc/ppp/pap-secrets << _EOT_
1455 # Secrets for authentication using PAP
1456 # client server secret IP addresses
1457 _EOT_
1458 # Generate /etc/ppp/chap-secrets
1459 cat > /etc/ppp/chap-secrets << _EOT_
1460 # Secrets for authentication using CHAP
1461 # client server secret IP addresses
1462 _EOT_
1463 fi
1464 gtkdialog --center --program=NET_BOX | grep -a 'EXIT="restart"' && continue
1465 exit 0
1466 done