slitaz-tools view tinyutils/netbox @ rev 192

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