slitaz-tools view tinyutils/netbox @ rev 252

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