slitaz-tools view tinyutils/netbox @ rev 226

netbox: simplify wifi tab, add firmware install
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jul 10 21:15:09 2008 +0000 (2008-07-10)
parents cc5a810e2c09
children 74935d005590
line source
1 #!/bin/sh
2 #
3 # Gtkdialog box to manage network connexion.
4 # - SliTaz GNU/Linux 2008.
5 #
6 VERSION=20080113
8 # Check if user is root.
9 check_root()
10 {
11 if test $(id -u) != 0 ; then
12 echo -e "
13 You must be root to run `basename $0`. Please type 'su' and
14 root password to become super-user.\n"
15 exit 0
16 fi
17 }
19 set_ipup()
20 {
21 [ -f /etc/ppp/ip-up ] && return
22 cat > /etc/ppp/ip-up <<EOT
23 #!/bin/sh
24 exec $0 call ipup \$@
25 EOT
26 chmod +x /etc/ppp/ip-up
27 }
29 # 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 dialod.
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 let you manage network connections 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 than /etc/network.conf is seded wehwn an interafce is activate
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'
231 NET_BOX="$NET_BOX$tmp"
232 [ -x /usr/sbin/iwconfig ] && NET_BOX="$NET_BOX|Wifi"
233 NET_BOX="$NET_BOX|System wide|VPN|Servers"
234 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX|Firewall"
235 tmp='|Etherwake">
237 <frame Udhcpc>
238 <hbox>
239 <text use-markup="true">
240 <label>"<b>Options :</b>"</label>
241 </text>
242 <entry>
243 <default>-b</default>
244 <variable>UDHCPC_OPTS</variable>
245 </entry>
246 <button>
247 <input file icon="help"></input>
248 <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>
249 </button>
250 </hbox>
251 <hbox>
252 <button>
253 <label>Start</label>
254 <input file icon="forward"></input>
255 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
256 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
257 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
258 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
259 </button>
260 <button>
261 <label>Stop</label>
262 <input file icon="stop"></input>
263 <action>echo -n "Stopping interface : $INTERFACE... "</action>
264 <action>ifconfig $INTERFACE down</action>
265 <action>killall -q udhcpc; echo "done"</action>
266 </button>
267 </hbox>
268 </frame>
270 <frame PPPoE>
271 <hbox>
272 <text use-markup="true">
273 <label>"<b>Name :</b>"</label>
274 </text>
275 <entry>
276 <input>NAME=$(grep -s ^name /etc/ppp/options); echo "${NAME#* }"</input>
277 <variable>NAME</variable>
278 </entry>
279 </hbox>
280 <hbox>
281 <text use-markup="true">
282 <label>"<b>Username :</b>"</label>
283 </text>
284 <entry>
285 <variable>USER</variable>
286 </entry>
287 </hbox>
288 <hbox>
289 <text use-markup="true">
290 <label>"<b>Password :</b>"</label>
291 </text>
292 <entry>
293 <variable>PASS</variable>
294 </entry>
295 </hbox>
296 <hbox>
297 <button>
298 <input file icon="help"></input>
299 <label>Help</label>
300 <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>
301 </button>
302 <button>
303 <input file icon="accessories-text-editor"></input>
304 <label>Tune</label>
305 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
306 <action type="lauch">leafpad /etc/ppp/options</action>
307 </button>
308 <button>
309 <label>Start</label>
310 <input file icon="forward"></input>
311 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
312 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
313 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
314 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
315 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
316 <action>killall udhcpc</action>
317 <action>sed -i "s/DHCP=\"yes\"/DHCP=\"no\"/" /etc/network.conf</action>
318 <action>sed -i "s/PPPOE=\"no\"/PPPOE=\"yes\"/" /etc/network.conf</action>
319 <action>pppd $INTERFACE &</action>
320 </button>
321 <button>
322 <label>Stop</label>
323 <input file icon="stop"></input>
324 <action>sed -i "s/PPPOE=\"yes\"/PPPOE=\"no\"/" /etc/network.conf</action>
325 <action>killall pppd</action>
326 </button>
327 </hbox>
328 </frame>
330 <frame PPP>
331 <hbox>
332 <text use-markup="true">
333 <label>"<b>Username :</b>"</label>
334 </text>
335 <entry>
336 <input>USER=$(grep -s ^ACCOUNT= /etc/ppp/scripts/ppp-on | cut -f1); echo "${USER#*=}"</input>
337 <variable>USER</variable>
338 </entry>
339 </hbox>
340 <hbox>
341 <text use-markup="true">
342 <label>"<b>Password :</b>"</label>
343 </text>
344 <entry>
345 <input>PASS=$(grep -s ^PASSWORD= /etc/ppp/scripts/ppp-on | cut -f1); echo "${PASS#*=}"</input>
346 <variable>PASS</variable>
347 </entry>
348 </hbox>
349 <hbox>
350 <text use-markup="true">
351 <label>"<b>Telephone:</b>"</label>
352 </text>
353 <entry>
354 <input>PHONE=$(grep -s ^TELEPHONE= /etc/ppp/scripts/ppp-on | cut -f1); echo "${PHONE#*=}"</input>
355 <variable>PHONE</variable>
356 </entry>
357 </hbox>
358 <hbox>
359 <button>
360 <input file icon="help"></input>
361 <label>Help</label>
362 <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>
363 </button>
364 <button>
365 <input file icon="accessories-text-editor"></input>
366 <label>Tune</label>
367 <action>[ -n "$NAME" ] && sed -i "s/^ACCOUNT=.*/ACCOUNT=$NAME/" /etc/ppp/scripts/ppp-on</action>
368 <action>[ -n "$PASS" ] && sed -i "s/^PASSWORD=.*/PASSWORD=$PASS/" /etc/ppp/scripts/ppp-on</action>
369 <action>[ -n "$PHONE" ] && sed -i "s/^TELEPHONE=.*/TELEPHONE=$PHONE/" /etc/ppp/scripts/ppp-on</action>
370 <action type="lauch">leafpad /etc/ppp/scripts/ppp-on</action>
371 </button>
372 <button>
373 <label>Start</label>
374 <input file icon="forward"></input>
375 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
376 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
377 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
378 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
379 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
380 <action>/etc/ppp/scripts/ppp-off</action>
381 <action>/etc/ppp/scripts/ppp-on &</action>
382 </button>
383 <button>
384 <label>Stop</label>
385 <input file icon="stop"></input>
386 <action>/etc/ppp/scripts/ppp-off</action>
387 </button>
388 </hbox>
389 </frame>
391 <frame Configuration>
392 <hbox>
393 <text use-markup="true">
394 <label>"<b>IP :</b>"</label>
395 </text>
396 <entry>
397 <input>. /etc/network.conf; echo "$IP"</input>
398 <variable>IP</variable>
399 </entry>
400 </hbox>
401 <hbox>
402 <text use-markup="true">
403 <label>"<b>Netmask :</b>"</label>
404 </text>
405 <entry>
406 <input>. /etc/network.conf; echo "$NETMASK"</input>
407 <variable>NETMASK</variable>
408 </entry>
409 </hbox>
410 <hbox>
411 <text use-markup="true">
412 <label>"<b>Gateway :</b>"</label>
413 </text>
414 <entry>
415 <input>. /etc/network.conf; echo "$GATEWAY"</input>
416 <variable>GATEWAY</variable>
417 </entry>
418 </hbox>
419 <hbox>
420 <text use-markup="true">
421 <label>"<b>DNS server :</b>"</label>
422 </text>
423 <entry>
424 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
425 <variable>DNS_SERVER</variable>
426 </entry>
427 </hbox>
428 <hbox>
429 <button>
430 <label>Start</label>
431 <input file icon="forward"></input>
432 <action>ifconfig lo down</action>
433 <action>ifconfig $INTERFACE down</action>
434 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
435 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
436 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
437 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
438 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
439 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
440 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
441 <action>/etc/init.d/network.sh</action>
442 </button>
443 <button>
444 <label>Stop</label>
445 <input file icon="stop"></input>
446 <action>echo -n "Stopping interface : $INTERFACE... "</action>
447 <action>ifconfig $INTERFACE down; echo "done"</action>
448 </button>
449 </hbox>
450 </frame>'
451 NET_BOX="$NET_BOX$tmp"
452 tmp='<frame Wireless>
453 <notebook labels="Interface|Extra parameters'
454 [ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp|Kernel Modules"
455 tmp2='">
456 <vbox>
457 <hbox>
458 <text use-markup="true">
459 <label>"<b>Interface :</b>"</label>
460 </text>
461 <entry>
462 <input>. /etc/network.conf; echo "$WIFI_INTERFACE"</input>
463 <variable>WIFI_INTERFACE</variable>
464 </entry>
465 <text use-markup="true">
466 <label>"<b>ESSID :</b>"</label>
467 </text>
468 <combobox>'
469 . /etc/network.conf
470 tmp2="$tmp2<item>$WIFI_ESSID</item>$ESSIDS"
471 tmp3='</combobox>
472 </hbox>
473 <hbox>
474 <text use-markup="true">
475 <label>"<b>Key :</b>"</label>
476 </text>
477 <entry>
478 <input>. /etc/network.conf; echo "$WIFI_KEY"</input>
479 <variable>WIFI_KEY</variable>
480 </entry>
481 <combobox>
482 <item>none</item>
483 <item>WEP</item>
484 <item>WPA</item>
485 <item>any</item>
486 <variable>WIFI_KEY_TYPE</variable>
487 </combobox>
488 </hbox>
489 </vbox>
490 <vbox>
491 <hbox>
492 <text use-markup="true">
493 <label>"<b>Channel :</b>"</label>
494 </text>
495 <entry>
496 <input>. /etc/network.conf; echo "$WIFI_CHANNEL"</input>
497 <variable>WIFI_CHANNEL</variable>
498 </entry>
499 <text use-markup="true">
500 <label>"<b>Mode :</b>"</label>
501 </text>
502 <combobox>
503 <variable>WIFI_MODE</variable>'
504 tmp2="$tmp2$tmp3<item>$WIFI_MODE</item>"
505 for i in managed ad-hoc master repeater secondary monitor; do
506 [ "$i" = "$WIFI_MODE" ] || tmp2="$tmp2<item>$i</item>"
507 done
508 tmp3='</combobox>
509 </hbox>
510 </vbox>'
511 tmp="$tmp$tmp2$tmp3"
512 tmp2='<vbox>
513 <hbox>
514 <button>
515 <label>Load</label>
516 <input file icon="forward"></input>
517 <action>modprobe $MODULE</action>
518 </button>
519 <button>
520 <label>Unload</label>
521 <input file icon="forward"></input>
522 <action>modprobe -r $MODULE</action>
523 </button>
524 <text use-markup="true">
525 <label>"<b>Wifi Module :</b>"</label>
526 </text>
527 <combobox>
528 <variable>MODULE</variable>'
529 tmp2="$tmp2$(find /lib/modules/$(uname -r)/kernel/drivers/net/wireless -type f | sed 's,/.*/\(.*\).ko.gz,<item>\1</item>,')"
530 tmp3='</combobox>
531 <button>
532 <label>Lsmod</label>
533 <input file icon="computer"></input>
534 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title "Modules (q to quit)" -e "lsmod | less"</action>
535 </button>
536 </hbox>'
537 tmp2="$tmp2$tmp3"
538 tmp3=$(for i in /usr/bin/get*firmware; do [ -x $i ] || continue; [ -d /var/lib/tazpkg/installed/${i#/usr/bin/get-} ] && continue; echo "<item>${i#/usr/bin/get-}</item>"; done)
539 [ -n "$tmp3" ] && tmp3="
540 <hbox>
541 <text use-markup=\"true\">
542 <label>\"<b>Firmware :</b>\"</label>
543 </text>
544 <combobox><variable>FIRMWARE</variable>$tmp3</combobox>
545 <button>
546 <label>Install</label>
547 <input file icon=\"go-jump\"></input>
548 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x25 -title \"Install \$FIRMWARE\" -e \"get-\$FIRMWARE\"</action>
549 </button>
550 </hbox>
551 "
552 tmp2="$tmp2$tmp3"
553 tmp3=""
554 [ -x /usr/sbin/ndiswrapper ] && tmp3='
555 <hbox>
556 <text use-markup="true">
557 <label>"<b>Ndiswrapper drivers :</b>"</label>
558 </text>
559 <entry>
560 <input>. /etc/network.conf; echo "$NDISWRAPPER_DRIVERS"</input>
561 <variable>NDISWRAPPER_DRIVERS</variable>
562 </entry>
563 <button>
564 <label>Restart</label>
565 <input file icon="reload"></input>
566 <action>rmmod ndiswrapper</action>
567 <action>for i in $NDISWRAPPER_DRIVERS; do ndiswrapper -i $i; done</action>
568 <action>modprobe ndiswrapper</action>
569 </button>
570 </hbox>
571 '
572 tmp3="$tmp3</vbox>"
573 [ -d /lib/modules/`uname -r`/kernel/drivers/net/wireless ] && tmp="$tmp$tmp2$tmp3"
574 tmp2='</notebook>
575 <hbox>
576 <button>
577 <label>Start</label>
578 <input file icon="forward"></input>
579 <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>
580 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_INTERFACE=`/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/ /etc/network.conf</action>
581 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_ESSID=`/WIFI_ESSID=\"$WIFI_ESSID\"/ /etc/network.conf</action>
582 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_KEY=`/WIFI_KEY=\"$WIFI_KEY\"/ /etc/network.conf</action>
583 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_KEY_TYPE=`/WIFI_KEY_TYPE=\"$WIFI_KEY_TYPE\"/ /etc/network.conf</action>
584 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_MODE=`/WIFI_MODE=\"$WIFI_MODE\"/ /etc/network.conf</action>
585 <action>sed -i s/`cat /etc/network.conf | grep ^WIFI_CHANNEL=`/WIFI_CHANNEL=\"$WIFI_CHANNEL\"/ /etc/network.conf</action>
586 <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
587 <action>ifconfig $WIFI_INTERFACE down</action>
588 <action>iwconfig $WIFI_INTERFACE txpower on</action>
589 <action>/etc/init.d/network.sh</action>
590 </button>
591 <button>
592 <label>Stop</label>
593 <input file icon="stop"></input>
594 <action>[ -x /etc/init.d/wpa_supplicant ] && /etc/init.d/wpa_supplicant stop</action>
595 <action>ifconfig $WIFI_INTERFACE down</action>
596 <action>iwconfig $WIFI_INTERFACE txpower off</action>
597 <action>[ -s /var/run/udhcpc.$WIFI_INTERFACE.pid ] && kill `cat /var/run/udhcpc.$WIFI_INTERFACE.pid`</action>
598 </button>
599 </hbox>
600 </frame>'
601 [ -x /usr/sbin/iwconfig ] && NET_BOX="$NET_BOX$tmp$tmp2"
602 tmp='<frame Configuration files>
603 <hbox>
604 <text use-markup="true">
605 <label>"<b>Hosts :</b>"</label>
606 </text>
607 <entry editable="false">
608 <default>/etc/hosts</default>
609 <variable>HOSTS</variable>
610 </entry>
611 <button>
612 <input file icon="accessories-text-editor"></input>
613 <action type="lauch">leafpad $HOSTS</action>
614 </button>
615 </hbox>
616 <hbox>
617 <text use-markup="true">
618 <label>"<b>Host name :</b>"</label>
619 </text>
620 <entry editable="false">
621 <default>/etc/hostname</default>
622 <variable>HOSTNAME</variable>
623 </entry>
624 <button>
625 <input file icon="accessories-text-editor"></input>
626 <action type="lauch">leafpad $HOSTNAME</action>
627 </button>
628 </hbox>
629 <hbox>
630 <text use-markup="true">
631 <label>"<b>Network :</b>"</label>
632 </text>
633 <entry editable="false">
634 <default>/etc/network.conf</default>
635 <variable>CONFIG_FILE</variable>
636 </entry>
637 <button>
638 <input file icon="accessories-text-editor"></input>
639 <action type="lauch">leafpad $CONFIG_FILE</action>
640 </button>
641 </hbox>
642 <hbox>
643 <button>
644 <label>Restart</label>
645 <input file icon="reload"></input>
646 <action>echo -n "Stopping interface : $INTERFACE... "</action>
647 <action>ifconfig lo down</action>
648 <action>ifconfig $INTERFACE down</action>
649 <action>killall -q udhcpc; echo "done"</action>
650 <action>/etc/init.d/network.sh</action>
651 </button>
652 </hbox>
653 </frame>
655 <frame Virtual Private Network with PPP/SSH>
656 <hbox>
657 <text use-markup="true">
658 <label>"<b>Peer :</b>"</label>
659 </text>
660 <entry>
661 <variable>DROPBEAR_PEERVPN</variable>
662 <default>user@elsewhere</default>
663 </entry>
664 </hbox>
665 <hbox>
666 <text use-markup="true">
667 <label>"<b>Local IP :</b>"</label>
668 </text>
669 <entry>
670 <variable>DROPBEAR_LOCAL</variable>
671 <default>192.168.254.1</default>
672 </entry>
673 </hbox>
674 <hbox>
675 <text use-markup="true">
676 <label>"<b>Remote IP :</b>"</label>
677 </text>
678 <entry>
679 <variable>DROPBEAR_REMOTE</variable>
680 <default>192.168.254.2</default>
681 </entry>
682 </hbox>
683 <hbox>
684 <text use-markup="true">
685 <label>"<b>Route(s) :</b>"</label>
686 </text>
687 <entry>
688 <variable>DROPBEAR_ROUTE</variable>
689 <default>192.168.10.0/24 192.168.20.0/28</default>
690 </entry>
691 </hbox>
692 <hbox>
693 <button>
694 <input file icon="forward"></input>
695 <label>Connect</label>
696 <action>netbox call vpnssh $DROPBEAR_PEERVPN $DROPBEAR_LOCAL $DROPBEAR_REMOTE "$DROPBEAR_ROUTE" &</action>
697 </button>
698 <button>
699 <input file icon="stop"></input>
700 <label>Disconnect</label>
701 <action>netbox call killvpnssh</action>
702 </button>
703 <button>
704 <input file icon="go-up"></input>
705 <label>Send key</label>
706 <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>
707 </button>
708 </hbox>
709 </frame>
710 <notebook labels="'
711 NET_BOX="$NET_BOX$tmp"
712 tmp=''
713 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH" && tmp='|'
714 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}INETD" && tmp='|'
715 [ -x /sbin/zcip ] && NET_BOX="${NET_BOX}${tmp}ZEROCONF" && tmp='|'
716 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}DHCP" && tmp='|'
717 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
718 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] \
719 && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
720 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
721 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
722 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
723 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
724 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}VNC" && tmp='|'
725 . /etc/daemons.conf
726 set -- $DROPBEAR_OPTIONS
727 while [ -n "$2" ]; do
728 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
729 shift
730 done
731 NET_BOX="${NET_BOX}\">"
732 tmp='<frame Dropbear>
733 <hbox>
734 <text use-markup="true">
735 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
736 </text>
737 <entry editable="false">'
738 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
739 tmp2='
740 <variable>DROPBEAR_OPTS</variable>
741 </entry>
742 <button>
743 <input file icon="help"></input>
744 <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>
745 </button>
746 <button>
747 <input file icon="accessories-text-editor"></input>
748 <action type="lauch">leafpad /etc/daemons.conf</action>
749 </button>
750 </hbox>
751 <hbox>
752 <text use-markup="true">
753 <label>"<b>Banner :</b>"</label>
754 </text>
755 <entry editable="false">'
756 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
757 tmp2='
758 <variable>DROPBEAR_BANNER</variable>
759 </entry>
760 <button>
761 <input file icon="accessories-text-editor"></input>
762 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
763 </button>
764 </hbox>
765 <hbox>
766 <text use-markup="true">
767 <label>"<b>Remote :</b>"</label>
768 </text>
769 <entry>
770 <variable>DROPBEAR_PEER</variable>
771 <default>user@elsewhere</default>
772 </entry>
773 <button>
774 <input file icon="utilities-terminal"></input>
775 <label>Connect</label>
776 <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>
777 </button>
778 <button>
779 <input file icon="go-up"></input>
780 <label>Send key</label>
781 <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>
782 </button>
783 </hbox>
784 <hbox>
785 <button>
786 <label>Start</label>
787 <input file icon="forward"></input>
788 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
789 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
790 <action>/etc/init.d/dropbear start</action>
791 </button>
792 <button>
793 <label>Stop</label>
794 <input file icon="stop"></input>
795 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
796 <action>/etc/init.d/dropbear stop</action>
797 </button>
798 </hbox>
799 </frame>
800 '
801 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
802 tmp='<frame Inetd>
803 <hbox>
804 <text use-markup="true">
805 <label>"<b>INETD_OPTIONS</b>"</label>
806 </text>
807 <entry editable="false">'
808 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
809 tmp2='
810 <variable>INETD_OPTS</variable>
811 </entry>
812 <button>
813 <input file icon="help"></input>
814 <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>
815 </button>
816 <button>
817 <input file icon="accessories-text-editor"></input>
818 <action type="lauch">leafpad /etc/daemons.conf</action>
819 </button>
820 </hbox>
821 <hbox>
822 <text use-markup="true">
823 <label>"<b>Configuration :</b>"</label>
824 </text>
825 <entry editable="false">
826 <default>/etc/inetd.conf</default>
827 <variable>INETD_CONF</variable>
828 </entry>
829 <button>
830 <input file icon="accessories-text-editor"></input>
831 <action type="lauch">leafpad $INETD_CONF</action>
832 </button>
833 </hbox>
834 <hbox>
835 '
836 tmp="$tmp$tmp2"
837 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
838 i=$(basename $i)
839 tmp2="
840 <button>
841 <input file icon=\"help\"></input>
842 <label>$i</label>
843 <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>
844 </button>
845 "
846 tmp="$tmp$tmp2"
847 done
848 tmp2='
849 <button>
850 <label>Start</label>
851 <input file icon="forward"></input>
852 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
853 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
854 <action>/etc/init.d/inetd start</action>
855 </button>
856 <button>
857 <label>Stop</label>
858 <input file icon="stop"></input>
859 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
860 <action>/etc/init.d/inetd stop</action>
861 </button>
862 </hbox>
863 </frame>
864 '
865 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
866 if [ -x /sbin/zcip -a -z "$ZCIP_OPTS" ]; then
867 ZCIP_OPTS="eth0 /etc/zcip.script"
868 cat >> /etc/daemons.conf <<EOT
869 # ZeroConf options
870 ZCIP_OPTS="$ZCIP_OPTS"
872 EOT
873 fi
874 tmp='<frame Zcip>
875 <hbox>
876 <text use-markup="true">
877 <label>"<b>ZCIP_OPTIONS</b>"</label>
878 </text>
879 <entry editable="false">'
880 [ -n "$ZCIP_OPTS" ] && tmp="$tmp<default>$ZCIP_OPTS</default>"
881 tmp2='
882 <variable>CZIP_OPTS</variable>
883 </entry>
884 <button>
885 <input file icon="help"></input>
886 <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>
887 </button>
888 <button>
889 <input file icon="accessories-text-editor"></input>
890 <action type="lauch">leafpad /etc/daemons.conf</action>
891 </button>
892 </hbox>
893 <hbox>
894 <text use-markup="true">
895 <label>"<b>Script :</b>"</label>
896 </text>
897 <entry editable="false">
898 <default>/etc/zcip.script</default>
899 <variable>CZIP_SCRIPT</variable>
900 </entry>
901 <button>
902 <input file icon="accessories-text-editor"></input>
903 <action type="lauch">leafpad $CZIP_SCRIPT</action>
904 </button>
905 </hbox>
906 <hbox>
907 <button>
908 <label>Start</label>
909 <input file icon="forward"></input>
910 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)zcip \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
911 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"zcip \1\"/" /etc/rcS.conf</action>
912 <action>/etc/init.d/zcip start</action>
913 </button>
914 <button>
915 <label>Stop</label>
916 <input file icon="stop"></input>
917 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)zcip \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
918 <action>/etc/init.d/zcip stop</action>
919 </button>
920 </hbox>
921 </frame>
922 '
923 [ -x /sbin/zcip ] && NET_BOX="${NET_BOX}$tmp$tmp2"
924 tmp='<frame Dhcpd>
925 <hbox>
926 <text use-markup="true">
927 <label>"<b>UDHCPD_OPTIONS</b>"</label>
928 </text>
929 <entry editable="false">'
930 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
931 tmp2='
932 <variable>UDHCPD_OPTS</variable>
933 </entry>
934 <button>
935 <input file icon="help"></input>
936 <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>
937 </button>
938 <button>
939 <input file icon="accessories-text-editor"></input>
940 <action type="lauch">leafpad /etc/daemons.conf</action>
941 </button>
942 </hbox>
943 <hbox>
944 <text use-markup="true">
945 <label>"<b>Configuration :</b>"</label>
946 </text>
947 <entry editable="false">
948 <default>/etc/udhcpd.conf</default>
949 <variable>UDHCPD_CONF</variable>
950 </entry>
951 <button>
952 <input file icon="accessories-text-editor"></input>
953 <action type="lauch">leafpad $UDHCPD_CONF</action>
954 </button>
955 </hbox>
956 <hbox>
957 <text use-markup="true">
958 <label>"<b>Script :</b>"</label>
959 </text>
960 <entry editable="false">
961 <default>/usr/share/udhcpc/default.script</default>
962 <variable>UDHCPD_SCRIPT</variable>
963 </entry>
964 <button>
965 <input file icon="accessories-text-editor"></input>
966 <action type="lauch">leafpad $UDHCPD_SCRIPT</action>
967 </button>
968 </hbox>
969 <hbox>
970 <button>
971 <label>Start</label>
972 <input file icon="forward"></input>
973 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
974 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
975 <action>/etc/init.d/udhcpd start</action>
976 </button>
977 <button>
978 <label>Stop</label>
979 <input file icon="stop"></input>
980 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
981 <action>/etc/init.d/udhcpd stop</action>
982 </button>
983 </hbox>
984 </frame>
985 '
986 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
987 tmp='<frame Pxelinux>
988 <hbox>
989 <text wrap="true">
990 <label>
991 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
992 </label>
993 </text>
994 </hbox>
995 <hbox>
996 <text use-markup="true">
997 <label>"<b>Configuration :</b>"</label>
998 </text>
999 <entry editable="false">
1000 <default>'
1001 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
1002 tmp2='/pxelinux.cfg/default</default>
1003 <variable>PXE_CONF</variable>
1004 </entry>
1005 <button>
1006 <input file icon="accessories-text-editor"></input>
1007 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
1008 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
1009 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
1010 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
1011 <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>
1012 <action type="lauch">leafpad $PXE_CONF</action>
1013 </button>
1014 </hbox>
1015 <hbox>
1016 <button>
1017 <input file icon="system-file-manager"></input>
1018 <label>Network boot files</label>
1019 <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>
1020 </button>
1021 </hbox>
1022 </frame>
1024 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
1025 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
1026 tmp='<frame Dnsd>
1027 <hbox>
1028 <text use-markup="true">
1029 <label>"<b>DNSD_OPTIONS</b>"</label>
1030 </text>
1031 <entry editable="false">'
1032 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
1033 tmp2='
1034 <variable>DNSD_OPTS</variable>
1035 </entry>
1036 <button>
1037 <input file icon="help"></input>
1038 <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>
1039 </button>
1040 <button>
1041 <input file icon="accessories-text-editor"></input>
1042 <action type="lauch">leafpad /etc/daemons.conf</action>
1043 </button>
1044 </hbox>
1045 <hbox>
1046 <text use-markup="true">
1047 <label>"<b>Configuration :</b>"</label>
1048 </text>
1049 <entry editable="false">
1050 <default>/etc/dnsd.conf</default>
1051 <variable>DNSD_CONF</variable>
1052 </entry>
1053 <button>
1054 <input file icon="accessories-text-editor"></input>
1055 <action type="lauch">leafpad $DNSD_CONF</action>
1056 </button>
1057 </hbox>
1058 <hbox>
1059 <button>
1060 <label>Start</label>
1061 <input file icon="forward"></input>
1062 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1063 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
1064 <action>/etc/init.d/dnsd start</action>
1065 </button>
1066 <button>
1067 <label>Stop</label>
1068 <input file icon="stop"></input>
1069 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1070 <action>/etc/init.d/dnsd stop</action>
1071 </button>
1072 </hbox>
1073 </frame>
1075 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1076 tmp='<frame Rsync>
1077 <hbox>
1078 <text use-markup="true">
1079 <label>"<b>RSYNCD_OPTIONS</b>"</label>
1080 </text>
1081 <entry editable="false">'
1082 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
1083 tmp2='
1084 <variable>RSYNC_OPTS</variable>
1085 </entry>
1086 <button>
1087 <input file icon="help"></input>
1088 <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>
1089 </button>
1090 <button>
1091 <input file icon="accessories-text-editor"></input>
1092 <action type="lauch">leafpad /etc/daemons.conf</action>
1093 </button>
1094 </hbox>
1095 <hbox>
1096 <text use-markup="true">
1097 <label>"<b>Configuration :</b>"</label>
1098 </text>
1099 <entry editable="false">
1100 <default>/etc/rsyncd.conf</default>
1101 <variable>RSYNCD_CONF</variable>
1102 </entry>
1103 <button>
1104 <input file icon="accessories-text-editor"></input>
1105 <action type="lauch">leafpad $RSYNCD_CONF</action>
1106 </button>
1107 </hbox>
1108 <hbox>
1109 <text use-markup="true">
1110 <label>"<b>Secrets file :</b>"</label>
1111 </text>
1112 <entry editable="true">
1113 <default>/etc/rsyncd.secrets</default>
1114 <variable>RSYNCD_SECRETS</variable>
1115 </entry>
1116 <button>
1117 <input file icon="accessories-text-editor"></input>
1118 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
1119 </button>
1120 </hbox>
1121 <hbox>
1122 <button>
1123 <label>Start</label>
1124 <input file icon="forward"></input>
1125 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1126 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
1127 <action>/etc/init.d/rsyncd start</action>
1128 </button>
1129 <button>
1130 <label>Stop</label>
1131 <input file icon="stop"></input>
1132 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1133 <action>/etc/init.d/rsyncd stop</action>
1134 </button>
1135 </hbox>
1136 </frame>
1138 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1139 tmp='<frame Lighttpd>'
1140 tmp2='<frame PHP>
1141 <hbox>
1142 <text use-markup="true">
1143 <label>"<b>Configuration :</b>"</label>
1144 </text>
1145 <entry editable="false">
1146 <default>/etc/php.ini</default>
1147 <variable>PHP_CONF</variable>
1148 </entry>
1149 <button>
1150 <input file icon="accessories-text-editor"></input>
1151 <action type="lauch">leafpad $PHP_CONF</action>
1152 </button>
1153 </hbox>
1154 </frame>
1156 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
1157 tmp2='<hbox>
1158 <text use-markup="true">
1159 <label>"<b>Configuration :</b>"</label>
1160 </text>
1161 <entry editable="false">
1162 <default>/etc/lighttpd/lighttpd.conf</default>
1163 <variable>LIGHTTPD_CONF</variable>
1164 </entry>
1165 <button>
1166 <input file icon="accessories-text-editor"></input>
1167 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
1168 </button>
1169 </hbox>
1170 <hbox>
1171 <button>
1172 <label>Start</label>
1173 <input file icon="forward"></input>
1174 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1175 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
1176 <action>/etc/init.d/lighttpd start</action>
1177 </button>
1178 <button>
1179 <label>Stop</label>
1180 <input file icon="stop"></input>
1181 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1182 <action>/etc/init.d/lighttpd stop</action>
1183 </button>
1184 </hbox>
1185 </frame>
1187 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1188 tmp='<frame Samba: smbd & nmbd>
1189 <hbox>
1190 <text use-markup="true">
1191 <label>"<b>Configuration :</b>"</label>
1192 </text>
1193 <entry editable="false">
1194 <default>/etc/samba/smb.conf</default>
1195 <variable>SMBD_CONF</variable>
1196 </entry>
1197 <button>
1198 <input file icon="accessories-text-editor"></input>
1199 <action type="lauch">leafpad $SMBD_CONF</action>
1200 </button>
1201 </hbox>
1202 <hbox>
1203 <button>
1204 <label>Reload</label>
1205 <input file icon="reload"></input>
1206 <action>/etc/init.d/samba reload</action>
1207 </button>
1208 <button>
1209 <label>Start</label>
1210 <input file icon="forward"></input>
1211 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1212 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
1213 <action>/etc/init.d/samba start</action>
1214 </button>
1215 <button>
1216 <label>Stop</label>
1217 <input file icon="stop"></input>
1218 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1219 <action>/etc/init.d/samba stop</action>
1220 </button>
1221 </hbox>
1222 </frame>
1224 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
1225 tmp='<frame x11vnc>
1226 <hbox>
1227 <text use-markup="true">
1228 <label>"<b>X11VNC_OPTIONS</b>"</label>
1229 </text>
1230 <entry editable="false">'
1231 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
1232 tmp2='
1233 <variable>X11VNC_OPTS</variable>
1234 </entry>
1235 <button>
1236 <input file icon="help"></input>
1237 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
1238 </button>
1239 <button>
1240 <input file icon="accessories-text-editor"></input>
1241 <action type="lauch">leafpad /etc/daemons.conf</action>
1242 </button>
1243 </hbox>
1244 <hbox>
1245 <text use-markup="true">
1246 <label>"<b>New password</b>"</label>
1247 </text>
1248 <entry>
1249 <variable>X11VNC_PASSWD</variable>
1250 </entry>
1251 <button>
1252 <input file icon="reload"></input>
1253 <label>Update</label>
1254 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
1255 </button>
1256 </hbox>
1257 <hbox>
1258 <button>
1259 <label>Start</label>
1260 <input file icon="forward"></input>
1261 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1262 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
1263 <action>/etc/init.d/x11vnc start</action>
1264 </button>
1265 <button>
1266 <label>Stop</label>
1267 <input file icon="stop"></input>
1268 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
1269 <action>/etc/init.d/x11vnc stop</action>
1270 </button>
1271 </hbox>
1272 </frame>
1274 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
1275 NET_BOX="${NET_BOX}
1276 </notebook>
1278 tmp='<frame Iptables>
1279 <hbox>
1280 <text use-markup="true">
1281 <label>"<b>Configuration :</b>"</label>
1282 </text>
1283 <entry editable="false">
1284 <default>/etc/iptables.conf</default>
1285 <variable>IPTABLES_CONF</variable>
1286 </entry>
1287 <button>
1288 <input file icon="accessories-text-editor"></input>
1289 <action type="lauch">leafpad $IPTABLES_CONF</action>
1290 </button>
1291 </hbox>
1292 <hbox>
1293 <button>
1294 <label>Load</label>
1295 <input file icon="reload"></input>
1296 <action>cat $IPTABLES_CONF | /sbin/iptables-restore</action>
1297 </button>
1298 <button>
1299 <label>Save</label>
1300 <input file icon="go-jump"></input>
1301 <action>/sbin/iptables-save > $IPTABLES_CONF</action>
1302 </button>
1303 </hbox>
1304 </frame>
1306 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
1307 tmp='
1308 <frame Ether-wake>
1309 <hbox>
1310 <text use-markup="true">
1311 <label>"<b>Machines :</b>"</label>
1312 </text>
1313 <entry editable="false">
1314 <default>/etc/ethers</default>
1315 <variable>ETHERS</variable>
1316 </entry>
1317 <button>
1318 <input file icon="accessories-text-editor"></input>
1319 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
1320 <action type="lauch">leafpad $ETHERS</action>
1321 </button>
1322 </hbox>
1323 <hbox>
1324 <text use-markup="true">
1325 <label>"<b>Options : </b>"</label>
1326 </text>
1327 <entry editable="false">
1328 <variable>ETHERWAKE_OPTS</variable>
1329 </entry>
1330 <button>
1331 <input file icon="help"></input>
1332 <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>
1333 </button>
1334 <button>
1335 <label>Start</label>
1336 <input file icon="forward"></input>
1337 <action>ether-wake $ETHERWAKE_OPTS</action>
1338 </button>
1339 </hbox>
1340 </frame>
1341 </notebook>
1343 <hbox>
1344 <button>
1345 <label>Status</label>
1346 <input file icon="dialog-information"></input>
1347 <action type="launch">IFCONFIG</action>
1348 </button>
1349 <button help>
1350 <label>Help</label>
1351 <action type="launch">HELP</action>
1352 </button>
1353 <button>
1354 <label>Quit</label>
1355 <input file icon="exit"></input>
1356 <action type="exit">Exit</action>
1357 </button>
1358 </hbox>
1360 </vbox>
1361 </window>
1363 NET_BOX="${NET_BOX}${tmp}"
1365 export NET_BOX
1367 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
1369 # Only root can configure network.
1370 check_root
1371 # Configure and connect if button Connect was pressed.
1372 if ! grep -qs ^name /etc/ppp/options ; then
1373 # Generate /etc/ppp/options
1374 cat > /etc/ppp/options << _EOT_
1375 plugin rp-pppoe.so
1376 name provider-ID
1377 noipdefault
1378 defaultroute
1379 mtu 1492
1380 mru 1492
1381 lock
1382 _EOT_
1383 # Generate /etc/ppp/pap-secrets
1384 cat > /etc/ppp/pap-secrets << _EOT_
1385 # Secrets for authentication using PAP
1386 # client server secret IP addresses
1387 _EOT_
1388 # Generate /etc/ppp/chap-secrets
1389 cat > /etc/ppp/chap-secrets << _EOT_
1390 # Secrets for authentication using CHAP
1391 # client server secret IP addresses
1392 _EOT_
1393 fi
1394 gtkdialog --center --program=NET_BOX
1396 exit 0