slitaz-tools view tinyutils/netbox @ rev 177

netbox: add PPPoE and SSH/PPP vpn
author Pascal Bellard <pascal.bellard@slitaz.org>
date Fri May 09 15:18:31 2008 +0000 (2008-05-09)
parents af16b5d7db36
children 644b5d8208b6
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="exit"></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="44">
159 <label>
160 "
161 Manage network connections getting dynamic IP
162 by DHCP or static IP, and setup servers.
163 Netbox can start or stop networking, configure
164 network interfaces or directly edit files.
165 Wifi users may configure System wide / Network.
166 "
167 </label>
168 </text>
170 <frame General>
171 <hbox>
172 <text use-markup="true">
173 <label>"<b>Interface :</b>"</label>
174 </text>
175 <entry>
176 <input>. /etc/network.conf; echo $INTERFACE</input>
177 <variable>INTERFACE</variable>
178 </entry>
179 </hbox>
180 </frame>
182 <notebook labels="DHCP|PPPoE|Static IP|System wide|VPN|Servers'
183 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX|Firewall"
184 tmp='|Etherwake">
186 <frame Udhcpc>
187 <hbox>
188 <text use-markup="true">
189 <label>"<b>Options :</b>"</label>
190 </text>
191 <entry>
192 <default>-b</default>
193 <variable>UDHCPC_OPTS</variable>
194 </entry>
195 <button>
196 <input file icon="help"></input>
197 <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>
198 </button>
199 </hbox>
200 <hbox>
201 <button>
202 <label>Start</label>
203 <input file icon="forward"></input>
204 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
205 <action>sed -i s/DHCP=\"no\"/DHCP=\"yes\"/ /etc/network.conf</action>
206 <action>sed -i s/STATIC=\"yes\"/STATIC=\"no\"/ /etc/network.conf</action>
207 <action>udhcpc $UDHCPC_OPTS -i $INTERFACE -p /var/run/udhcpc.$INTERFACE.pid</action>
208 </button>
209 <button>
210 <label>Stop</label>
211 <input file icon="stop"></input>
212 <action>echo -n "Stopping interface : $INTERFACE... "</action>
213 <action>ifconfig $INTERFACE down</action>
214 <action>killall -q udhcpc; echo "done"</action>
215 </button>
216 </hbox>
217 </frame>
219 <frame PPPoE>
220 <hbox>
221 <text use-markup="true">
222 <label>"<b>Name :</b>"</label>
223 </text>
224 <entry>
225 <input>NAME=$(grep -s ^name /etc/ppp/options); echo "${NAME#* }"</input>
226 <variable>NAME</variable>
227 </entry>
228 </hbox>
229 <hbox>
230 <text use-markup="true">
231 <label>"<b>Username :</b>"</label>
232 </text>
233 <entry>
234 <variable>USER</variable>
235 </entry>
236 </hbox>
237 <hbox>
238 <text use-markup="true">
239 <label>"<b>Password :</b>"</label>
240 </text>
241 <entry>
242 <variable>USER</variable>
243 </entry>
244 </hbox>
245 <hbox>
246 <button>
247 <input file icon="accessories-text-editor"></input>
248 <label>Tune</label>
249 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
250 <action type="lauch">leafpad /etc/ppp/options</action>
251 </button>
252 <button>
253 <label>Start</label>
254 <input file icon="forward"></input>
255 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/pap-secrets
256 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/pap-secrets</action>
257 <action>[ -n "$USER" ] && grep -qs "^\"$USER\"" /etc/ppp/chap-secrets
258 && echo "\"$USER\" * \"$PASS\"" >> /etc/ppp/chap-secrets</action>
259 <action>[ -n "$NAME" ] && sed -i "s/^name .*/name $NAME/" /etc/ppp/options</action>
260 <action>killall udhcpc</action>
261 <action>sed -i "s/DHCP=\"yes\"/DHCP=\"no\"/" /etc/network.conf</action>
262 <action>sed -i "s/PPPOE=\"no\"/PPPOE=\"yes\"/" /etc/network.conf</action>
263 <action>pppd $INTERFACE &</action>
264 </button>
265 <button>
266 <label>Stop</label>
267 <input file icon="stop"></input>
268 <action>sed -i "s/PPPOE=\"yes\"/PPPOE=\"no\"/" /etc/network.conf</action>
269 <action>killall pppd</action>
270 </button>
271 </hbox>
272 </frame>
274 <frame Configuration>
275 <hbox>
276 <text use-markup="true">
277 <label>"<b>IP :</b>"</label>
278 </text>
279 <entry>
280 <input>. /etc/network.conf; echo "$IP"</input>
281 <variable>IP</variable>
282 </entry>
283 </hbox>
284 <hbox>
285 <text use-markup="true">
286 <label>"<b>Netmask :</b>"</label>
287 </text>
288 <entry>
289 <input>. /etc/network.conf; echo "$NETMASK"</input>
290 <variable>NETMASK</variable>
291 </entry>
292 </hbox>
293 <hbox>
294 <text use-markup="true">
295 <label>"<b>Gateway :</b>"</label>
296 </text>
297 <entry>
298 <input>. /etc/network.conf; echo "$GATEWAY"</input>
299 <variable>GATEWAY</variable>
300 </entry>
301 </hbox>
302 <hbox>
303 <text use-markup="true">
304 <label>"<b>DNS server :</b>"</label>
305 </text>
306 <entry>
307 <input>. /etc/network.conf; echo "$DNS_SERVER"</input>
308 <variable>DNS_SERVER</variable>
309 </entry>
310 </hbox>
311 <hbox>
312 <button>
313 <label>Start</label>
314 <input file icon="forward"></input>
315 <action>ifconfig lo down</action>
316 <action>ifconfig $INTERFACE down</action>
317 <action>sed -i s/`cat /etc/network.conf | grep ^INTERFACE=`/INTERFACE=\"$INTERFACE\"/ /etc/network.conf</action>
318 <action>sed -i s/DHCP=\"yes\"/DHCP=\"no\"/ /etc/network.conf</action>
319 <action>sed -i s/STATIC=\"no\"/STATIC=\"yes\"/ /etc/network.conf</action>
320 <action>sed -i s/`cat /etc/network.conf | grep ^IP=`/IP=\"$IP\"/ /etc/network.conf</action>
321 <action>sed -i s/`cat /etc/network.conf | grep ^NETMASK=`/NETMASK=\"$NETMASK\"/ /etc/network.conf</action>
322 <action>sed -i s/`cat /etc/network.conf | grep ^GATEWAY=`/GATEWAY=\"$GATEWAY\"/ /etc/network.conf</action>
323 <action>sed -i s/`cat /etc/network.conf | grep ^DNS_SERVER=`/DNS_SERVER=\"$DNS_SERVER\"/ /etc/network.conf</action>
324 <action>/etc/init.d/network.sh</action>
325 </button>
326 <button>
327 <label>Stop</label>
328 <input file icon="stop"></input>
329 <action>echo -n "Stopping interface : $INTERFACE... "</action>
330 <action>ifconfig $INTERFACE down; echo "done"</action>
331 </button>
332 </hbox>
333 </frame>
335 <frame Configuration files>
336 <hbox>
337 <text use-markup="true">
338 <label>"<b>Hosts :</b>"</label>
339 </text>
340 <entry editable="false">
341 <default>/etc/hosts</default>
342 <variable>HOSTS</variable>
343 </entry>
344 <button>
345 <input file icon="accessories-text-editor"></input>
346 <action type="lauch">leafpad $HOSTS</action>
347 </button>
348 </hbox>
349 <hbox>
350 <text use-markup="true">
351 <label>"<b>Host name :</b>"</label>
352 </text>
353 <entry editable="false">
354 <default>/etc/hostname</default>
355 <variable>HOSTNAME</variable>
356 </entry>
357 <button>
358 <input file icon="accessories-text-editor"></input>
359 <action type="lauch">leafpad $HOSTNAME</action>
360 </button>
361 </hbox>
362 <hbox>
363 <text use-markup="true">
364 <label>"<b>Network :</b>"</label>
365 </text>
366 <entry editable="false">
367 <default>/etc/network.conf</default>
368 <variable>CONFIG_FILE</variable>
369 </entry>
370 <button>
371 <input file icon="accessories-text-editor"></input>
372 <action type="lauch">leafpad $CONFIG_FILE</action>
373 </button>
374 </hbox>
375 <hbox>
376 <button>
377 <label>Restart</label>
378 <input file icon="reload"></input>
379 <action>echo -n "Stopping interface : $INTERFACE... "</action>
380 <action>ifconfig lo down</action>
381 <action>ifconfig $INTERFACE down</action>
382 <action>killall -q udhcpc; echo "done"</action>
383 <action>/etc/init.d/network.sh</action>
384 </button>
385 </hbox>
386 </frame>
388 <frame Virtual Private Network with PPP/SSH>
389 <hbox>
390 <text use-markup="true">
391 <label>"<b>Peer :</b>"</label>
392 </text>
393 <entry>
394 <variable>DROPBEAR_PEERVPN</variable>
395 <default>user@elsewhere</default>
396 </entry>
397 </hbox>
398 <hbox>
399 <text use-markup="true">
400 <label>"<b>Local IP :</b>"</label>
401 </text>
402 <entry>
403 <variable>DROPBEAR_LOCAL</variable>
404 <default>192.168.254.1</default>
405 </entry>
406 </hbox>
407 <hbox>
408 <text use-markup="true">
409 <label>"<b>Remote IP :</b>"</label>
410 </text>
411 <entry>
412 <variable>DROPBEAR_REMOTE</variable>
413 <default>192.168.254.2</default>
414 </entry>
415 </hbox>
416 <hbox>
417 <text use-markup="true">
418 <label>"<b>Route(s) :</b>"</label>
419 </text>
420 <entry>
421 <variable>DROPBEAR_ROUTE</variable>
422 <default>192.168.10.0/24 192.168.20.0/28</default>
423 </entry>
424 </hbox>
425 <hbox>
426 <button>
427 <input file icon="forward"></input>
428 <label>Connect</label>
429 <action>netbox call vpnssh $DROPBEAR_PEERVPN $DROPBEAR_LOCAL $DROPBEAR_REMOTE "$DROPBEAR_ROUTE" &</action>
430 </button>
431 <button>
432 <input file icon="stop"></input>
433 <label>Disconnect</label>
434 <action>netbox call killvpnssh</action>
435 </button>
436 <button>
437 <input file icon="go-up"></input>
438 <label>Send key</label>
439 <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>
440 </button>
441 </hbox>
442 </frame>
443 <notebook labels="'
444 NET_BOX="$NET_BOX$tmp"
445 tmp=''
446 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}SSH" && tmp='|'
447 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}INETD" && tmp='|'
448 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}${tmp}DHCP" && tmp='|'
449 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
450 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] \
451 && NET_BOX="${NET_BOX}${tmp}PXE" && tmp='|'
452 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}DNS" && tmp='|'
453 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}RSYNC" && tmp='|'
454 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}HTTP" && tmp='|'
455 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}WINS" && tmp='|'
456 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}VNC" && tmp='|'
457 . /etc/daemons.conf
458 set -- $DROPBEAR_OPTIONS
459 while [ -n "$2" ]; do
460 [ "$1" = "-b" ] && DROPBEAR_BANNER="$2" && break
461 shift
462 done
463 NET_BOX="${NET_BOX}\">"
464 tmp='<frame Dropbear>
465 <hbox>
466 <text use-markup="true">
467 <label>"<b>DROPBEAR_OPTIONS</b>"</label>
468 </text>
469 <entry editable="false">'
470 [ -n "$DROPBEAR_OPTIONS" ] && tmp="$tmp<default>$DROPBEAR_OPTIONS</default>"
471 tmp2='
472 <variable>DROPBEAR_OPTS</variable>
473 </entry>
474 <button>
475 <input file icon="help"></input>
476 <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>
477 </button>
478 <button>
479 <input file icon="accessories-text-editor"></input>
480 <action type="lauch">leafpad /etc/daemons.conf</action>
481 </button>
482 </hbox>
483 <hbox>
484 <text use-markup="true">
485 <label>"<b>Banner :</b>"</label>
486 </text>
487 <entry editable="false">'
488 [ -n "$DROPBEAR_BANNER" ] && tmp="$tmp$tmp2<default>$DROPBEAR_BANNER</default>"
489 tmp2='
490 <variable>DROPBEAR_BANNER</variable>
491 </entry>
492 <button>
493 <input file icon="accessories-text-editor"></input>
494 <action type="lauch">leafpad $DROPBEAR_BANNER</action>
495 </button>
496 </hbox>
497 <hbox>
498 <text use-markup="true">
499 <label>"<b>Remote :</b>"</label>
500 </text>
501 <entry>
502 <variable>DROPBEAR_PEER</variable>
503 <default>user@elsewhere</default>
504 </entry>
505 <button>
506 <input file icon="utilities-terminal"></input>
507 <label>Connect</label>
508 <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>
509 </button>
510 <button>
511 <input file icon="go-up"></input>
512 <label>Send key</label>
513 <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>
514 </button>
515 </hbox>
516 <hbox>
517 <button>
518 <label>Start</label>
519 <input file icon="forward"></input>
520 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
521 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dropbear \1\"/" /etc/rcS.conf</action>
522 <action>/etc/init.d/dropbear start</action>
523 </button>
524 <button>
525 <label>Stop</label>
526 <input file icon="stop"></input>
527 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dropbear \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
528 <action>/etc/init.d/dropbear stop</action>
529 </button>
530 </hbox>
531 </frame>
532 '
533 [ -x /usr/sbin/dropbear ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
534 tmp='<frame Inetd>
535 <hbox>
536 <text use-markup="true">
537 <label>"<b>INETD_OPTIONS</b>"</label>
538 </text>
539 <entry editable="false">'
540 [ -n "$INETD_OPTS" ] && tmp="$tmp<default>$INETD_OPTS</default>"
541 tmp2='
542 <variable>INETD_OPTS</variable>
543 </entry>
544 <button>
545 <input file icon="help"></input>
546 <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>
547 </button>
548 <button>
549 <input file icon="accessories-text-editor"></input>
550 <action type="lauch">leafpad /etc/daemons.conf</action>
551 </button>
552 </hbox>
553 <hbox>
554 <text use-markup="true">
555 <label>"<b>Configuration :</b>"</label>
556 </text>
557 <entry editable="false">
558 <default>/etc/inetd.conf</default>
559 <variable>INETD_CONF</variable>
560 </entry>
561 <button>
562 <input file icon="accessories-text-editor"></input>
563 <action type="lauch">leafpad $INETD_CONF</action>
564 </button>
565 </hbox>
566 <hbox>
567 '
568 tmp="$tmp$tmp2"
569 for i in $(grep bin /etc/inetd.conf | awk '{ print $6}'); do
570 i=$(basename $i)
571 tmp2="
572 <button>
573 <input file icon=\"help\"></input>
574 <label>$i</label>
575 <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>
576 </button>
577 "
578 tmp="$tmp$tmp2"
579 done
580 tmp2='
581 <button>
582 <label>Start</label>
583 <input file icon="forward"></input>
584 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
585 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"inetd \1\"/" /etc/rcS.conf</action>
586 <action>/etc/init.d/inetd start</action>
587 </button>
588 <button>
589 <label>Stop</label>
590 <input file icon="stop"></input>
591 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)inetd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
592 <action>/etc/init.d/inetd stop</action>
593 </button>
594 </hbox>
595 </frame>
596 '
597 [ -x /usr/sbin/inetd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
598 tmp='<frame Dhcpd>
599 <hbox>
600 <text use-markup="true">
601 <label>"<b>UDHCPD_OPTIONS</b>"</label>
602 </text>
603 <entry editable="false">'
604 [ -n "$UDHCPD_OPTS" ] && tmp="$tmp<default>$UDHCPD_OPTS</default>"
605 tmp2='
606 <variable>UDHCPD_OPTS</variable>
607 </entry>
608 <button>
609 <input file icon="help"></input>
610 <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>
611 </button>
612 <button>
613 <input file icon="accessories-text-editor"></input>
614 <action type="lauch">leafpad /etc/daemons.conf</action>
615 </button>
616 </hbox>
617 <hbox>
618 <text use-markup="true">
619 <label>"<b>Configuration :</b>"</label>
620 </text>
621 <entry editable="false">
622 <default>/etc/udhcpd.conf</default>
623 <variable>UDHCPD_CONF</variable>
624 </entry>
625 <button>
626 <input file icon="accessories-text-editor"></input>
627 <action type="lauch">leafpad $UDHCPD_CONF</action>
628 </button>
629 </hbox>
630 <hbox>
631 <button>
632 <label>Start</label>
633 <input file icon="forward"></input>
634 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
635 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"udhcpd \1\"/" /etc/rcS.conf</action>
636 <action>/etc/init.d/udhcpd start</action>
637 </button>
638 <button>
639 <label>Stop</label>
640 <input file icon="stop"></input>
641 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)udhcpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
642 <action>/etc/init.d/udhcpd stop</action>
643 </button>
644 </hbox>
645 </frame>
646 '
647 [ -x /usr/sbin/udhcpd ] && NET_BOX="${NET_BOX}$tmp$tmp2"
648 tmp='<frame Pxelinux>
649 <hbox>
650 <text wrap="true">
651 <label>
652 "Launch Dhcpd and Inetd with Tftpd to start the PXE service."
653 </label>
654 </text>
655 </hbox>
656 <hbox>
657 <text use-markup="true">
658 <label>"<b>Configuration :</b>"</label>
659 </text>
660 <entry editable="false">
661 <default>'
662 tmp="$tmp$(grep bin/tftpd /etc/inetd.conf | awk '{ print $NF }')"
663 tmp2='/pxelinux.cfg/default</default>
664 <variable>PXE_CONF</variable>
665 </entry>
666 <button>
667 <input file icon="accessories-text-editor"></input>
668 <action>dir=$(dirname $PXE_CONF); [ -d $dir ] || mkdir -p $dir</action>
669 <action>lzma d /usr/share/boot/pxelinux.0.lzma $(dirname $PXE_CONF)/../pxelinux.0</action>
670 <action>grep -q "^boot_file" $UDHCPD_CONF || echo "boot_file pxelinux.0" >> $UDHCPD_CONF</action>
671 <action>grep -q "^siaddr" $UDHCPD_CONF || echo "siaddr $(ifconfig $INTERFACE | grep inet.ad | cut -d: -f2 | cut -d\ -f1)" >> $UDHCPD_CONF</action>
672 <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>
673 <action type="lauch">leafpad $PXE_CONF</action>
674 </button>
675 </hbox>
676 <hbox>
677 <button>
678 <input file icon="system-file-manager"></input>
679 <label>Network boot files</label>
680 <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>
681 </button>
682 </hbox>
683 </frame>
684 '
685 [ -f /usr/share/boot/pxelinux.0.lzma -a -x /usr/bin/tftpd -a \
686 -x /usr/sbin/inetd -a -x /usr/sbin/udhcpd ] && NET_BOX="$NET_BOX$tmp$tmp2"
687 tmp='<frame Dnsd>
688 <hbox>
689 <text use-markup="true">
690 <label>"<b>DNSD_OPTIONS</b>"</label>
691 </text>
692 <entry editable="false">'
693 [ -n "$DNSD_OPTIONS" ] && tmp="$tmp<default>$DNSD_OPTIONS</default>"
694 tmp2='
695 <variable>DNSD_OPTS</variable>
696 </entry>
697 <button>
698 <input file icon="help"></input>
699 <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>
700 </button>
701 <button>
702 <input file icon="accessories-text-editor"></input>
703 <action type="lauch">leafpad /etc/daemons.conf</action>
704 </button>
705 </hbox>
706 <hbox>
707 <text use-markup="true">
708 <label>"<b>Configuration :</b>"</label>
709 </text>
710 <entry editable="false">
711 <default>/etc/dnsd.conf</default>
712 <variable>DNSD_CONF</variable>
713 </entry>
714 <button>
715 <input file icon="accessories-text-editor"></input>
716 <action type="lauch">leafpad $DNSD_CONF</action>
717 </button>
718 </hbox>
719 <hbox>
720 <button>
721 <label>Start</label>
722 <input file icon="forward"></input>
723 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
724 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"dnsd \1\"/" /etc/rcS.conf</action>
725 <action>/etc/init.d/dnsd start</action>
726 </button>
727 <button>
728 <label>Stop</label>
729 <input file icon="stop"></input>
730 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)dnsd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
731 <action>/etc/init.d/dnsd stop</action>
732 </button>
733 </hbox>
734 </frame>
735 '
736 [ -x /usr/sbin/dnsd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
737 tmp='<frame Rsync>
738 <hbox>
739 <text use-markup="true">
740 <label>"<b>RSYNCD_OPTIONS</b>"</label>
741 </text>
742 <entry editable="false">'
743 [ -n "${RSYNCD_OPTIONS#* }" ] && tmp="$tmp<default>${RSYNCD_OPTIONS#* }</default>"
744 tmp2='
745 <variable>RSYNC_OPTS</variable>
746 </entry>
747 <button>
748 <input file icon="help"></input>
749 <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>
750 </button>
751 <button>
752 <input file icon="accessories-text-editor"></input>
753 <action type="lauch">leafpad /etc/daemons.conf</action>
754 </button>
755 </hbox>
756 <hbox>
757 <text use-markup="true">
758 <label>"<b>Configuration :</b>"</label>
759 </text>
760 <entry editable="false">
761 <default>/etc/rsyncd.conf</default>
762 <variable>RSYNCD_CONF</variable>
763 </entry>
764 <button>
765 <input file icon="accessories-text-editor"></input>
766 <action type="lauch">leafpad $RSYNCD_CONF</action>
767 </button>
768 </hbox>
769 <hbox>
770 <text use-markup="true">
771 <label>"<b>Secrets file :</b>"</label>
772 </text>
773 <entry editable="true">
774 <default>/etc/rsyncd.secrets</default>
775 <variable>RSYNCD_SECRETS</variable>
776 </entry>
777 <button>
778 <input file icon="accessories-text-editor"></input>
779 <action type="lauch">leafpad $RSYNCD_SECRETS</action>
780 </button>
781 </hbox>
782 <hbox>
783 <button>
784 <label>Start</label>
785 <input file icon="forward"></input>
786 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
787 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"rsyncd \1\"/" /etc/rcS.conf</action>
788 <action>/etc/init.d/rsyncd start</action>
789 </button>
790 <button>
791 <label>Stop</label>
792 <input file icon="stop"></input>
793 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)rsyncd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
794 <action>/etc/init.d/rsyncd stop</action>
795 </button>
796 </hbox>
797 </frame>
798 '
799 [ -x /usr/bin/rsync ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
800 tmp='<frame Lighttpd>'
801 tmp2='<frame PHP>
802 <hbox>
803 <text use-markup="true">
804 <label>"<b>Configuration :</b>"</label>
805 </text>
806 <entry editable="false">
807 <default>/etc/php.ini</default>
808 <variable>PHP_CONF</variable>
809 </entry>
810 <button>
811 <input file icon="accessories-text-editor"></input>
812 <action type="lauch">leafpad $PHP_CONF</action>
813 </button>
814 </hbox>
815 </frame>
816 '
817 [ -f /etc/php.ini ] && tmp="${tmp}${tmp2}"
818 tmp2='<hbox>
819 <text use-markup="true">
820 <label>"<b>Configuration :</b>"</label>
821 </text>
822 <entry editable="false">
823 <default>/etc/lighttpd/lighttpd.conf</default>
824 <variable>LIGHTTPD_CONF</variable>
825 </entry>
826 <button>
827 <input file icon="accessories-text-editor"></input>
828 <action type="lauch">leafpad $LIGHTTPD_CONF</action>
829 </button>
830 </hbox>
831 <hbox>
832 <button>
833 <label>Start</label>
834 <input file icon="forward"></input>
835 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
836 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"lighttpd \1\"/" /etc/rcS.conf</action>
837 <action>/etc/init.d/lighttpd start</action>
838 </button>
839 <button>
840 <label>Stop</label>
841 <input file icon="stop"></input>
842 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)lighttpd \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
843 <action>/etc/init.d/lighttpd stop</action>
844 </button>
845 </hbox>
846 </frame>
847 '
848 [ -x /usr/sbin/lighttpd ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
849 tmp='<frame Samba: smbd & nmbd>
850 <hbox>
851 <text use-markup="true">
852 <label>"<b>Configuration :</b>"</label>
853 </text>
854 <entry editable="false">
855 <default>/etc/samba/smb.conf</default>
856 <variable>SMBD_CONF</variable>
857 </entry>
858 <button>
859 <input file icon="accessories-text-editor"></input>
860 <action type="lauch">leafpad $SMBD_CONF</action>
861 </button>
862 </hbox>
863 <hbox>
864 <button>
865 <label>Reload</label>
866 <input file icon="reload"></input>
867 <action>/etc/init.d/samba reload</action>
868 </button>
869 <button>
870 <label>Start</label>
871 <input file icon="forward"></input>
872 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
873 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"samba \1\"/" /etc/rcS.conf</action>
874 <action>/etc/init.d/samba start</action>
875 </button>
876 <button>
877 <label>Stop</label>
878 <input file icon="stop"></input>
879 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)samba \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
880 <action>/etc/init.d/samba stop</action>
881 </button>
882 </hbox>
883 </frame>
884 '
885 [ -x /usr/sbin/smbd ] && NET_BOX="${NET_BOX}${tmp}"
886 tmp='<frame x11vnc>
887 <hbox>
888 <text use-markup="true">
889 <label>"<b>X11VNC_OPTIONS</b>"</label>
890 </text>
891 <entry editable="false">'
892 [ -n "$X11VNC_OPTIONS" ] && tmp="$tmp<default>$X11VNC_OPTIONS</default>"
893 tmp2='
894 <variable>X11VNC_OPTS</variable>
895 </entry>
896 <button>
897 <input file icon="help"></input>
898 <action>xterm -fa MiscFixed -fs 11 -bg gray93 -fg black -geometry 80x30 -title "x11vnc daemon help (q to quit)" -e "x11vnc --help | less"</action>
899 </button>
900 <button>
901 <input file icon="accessories-text-editor"></input>
902 <action type="lauch">leafpad /etc/daemons.conf</action>
903 </button>
904 </hbox>
905 <hbox>
906 <text use-markup="true">
907 <label>"<b>New password</b>"</label>
908 </text>
909 <entry>
910 <variable>X11VNC_PASSWD</variable>
911 </entry>
912 <button>
913 <input file icon="reload"></input>
914 <label>Update</label>
915 <action>x11vnc -storepasswd $X11VNC_PASSWD /etc/vnc.secret</action>
916 </button>
917 </hbox>
918 <hbox>
919 <button>
920 <label>Start</label>
921 <input file icon="forward"></input>
922 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
923 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)\"/RUN_DAEMONS=\"x11vnc \1\"/" /etc/rcS.conf</action>
924 <action>/etc/init.d/x11vnc start</action>
925 </button>
926 <button>
927 <label>Stop</label>
928 <input file icon="stop"></input>
929 <action>sed -i "s/RUN_DAEMONS=\"\(.*\)x11vnc \?\(.*\)\"/RUN_DAEMONS=\"\1\2\"/" /etc/rcS.conf</action>
930 <action>/etc/init.d/x11vnc stop</action>
931 </button>
932 </hbox>
933 </frame>
934 '
935 [ -x /usr/bin/x11vnc ] && NET_BOX="${NET_BOX}${tmp}${tmp2}"
936 NET_BOX="${NET_BOX}
937 </notebook>
938 "
939 tmp='<frame Iptables>
940 <hbox>
941 <text use-markup="true">
942 <label>"<b>Configuration :</b>"</label>
943 </text>
944 <entry editable="false">
945 <default>/etc/iptables.conf</default>
946 <variable>IPTABLES_CONF</variable>
947 </entry>
948 <button>
949 <input file icon="accessories-text-editor"></input>
950 <action type="lauch">leafpad $IPTABLES_CONF</action>
951 </button>
952 </hbox>
953 <hbox>
954 <button>
955 <label>Load</label>
956 <input file icon="reload"></input>
957 <action>/sbin/iptables-restore \< $IPTABLES_CONF</action>
958 </button>
959 <button>
960 <label>Save</label>
961 <input file icon="go-jump"></input>
962 <action>/sbin/iptables-save \> $IPTABLES_CONF</action>
963 </button>
964 </hbox>
965 </frame>
966 '
967 [ -x /sbin/iptables ] && NET_BOX="$NET_BOX${tmp}"
968 tmp='
969 <frame Ether-wake>
970 <hbox>
971 <text use-markup="true">
972 <label>"<b>Machines :</b>"</label>
973 </text>
974 <entry editable="false">
975 <default>/etc/ethers</default>
976 <variable>ETHERS</variable>
977 </entry>
978 <button>
979 <input file icon="accessories-text-editor"></input>
980 <action>[ -s $ETHERS ] || echo "#00:01:02:03:04:05 mystation" >$ETHERS</action>
981 <action type="lauch">leafpad $ETHERS</action>
982 </button>
983 </hbox>
984 <hbox>
985 <text use-markup="true">
986 <label>"<b>Options : </b>"</label>
987 </text>
988 <entry editable="false">
989 <variable>ETHERWAKE_OPTS</variable>
990 </entry>
991 <button>
992 <input file icon="help"></input>
993 <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>
994 </button>
995 <button>
996 <label>Start</label>
997 <input file icon="forward"></input>
998 <action>ether-wake $ETHERWAKE_OPTS</action>
999 </button>
1000 </hbox>
1001 </frame>
1002 </notebook>
1004 <hbox>
1005 <button>
1006 <label>Status</label>
1007 <input file icon="network-wired"></input>
1008 <action type="launch">IFCONFIG</action>
1009 </button>
1010 <button>
1011 <input file icon="exit"></input>
1012 <action type="exit">Exit</action>
1013 </button>
1014 </hbox>
1016 </vbox>
1017 </window>
1019 NET_BOX="${NET_BOX}${tmp}"
1021 export NET_BOX
1023 # TODO: Modules(Network kernel modules) VPN(OpenVPN)
1025 # Only root can configure network.
1026 check_root
1027 # Configure and connect if button Connect was pressed.
1028 if ! grep -qs ^name /etc/ppp/options ; then
1029 # Generate /etc/ppp/options
1030 cat > /etc/ppp/options << _EOT_
1031 plugin rp-pppoe.so
1032 name provider-ID
1033 noipdefault
1034 defaultroute
1035 mtu 1492
1036 mru 1492
1037 lock
1038 _EOT_
1039 # Generate /etc/ppp/pap-secrets
1040 cat > /etc/ppp/pap-secrets << _EOT_
1041 # Secrets for authentication using PAP
1042 # client server secret IP addresses
1043 _EOT_
1044 # Generate /etc/ppp/chap-secrets
1045 cat > /etc/ppp/chap-secrets << _EOT_
1046 # Secrets for authentication using CHAP
1047 # client server secret IP addresses
1048 _EOT_
1049 fi
1050 gtkdialog --center --program=NET_BOX
1052 exit 0