slitaz-tools annotate tinyutils/netbox @ rev 637

tazbox: add command all-apps to display all installed application
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jun 17 20:51:43 2011 +0200 (2011-06-17)
parents c2eeac9343bf
children 7a4e0828dd34
rev   line source
pankso@33 1 #!/bin/sh
pankso@194 2 #
paul@317 3 # Gtkdialog box to manage network connections and servers.
pankso@292 4 # Please use tab to indent.
pankso@33 5 #
pankso@292 6 # (c) - SliTaz GNU/Linux 2009.
pankso@292 7 #
jozee@461 8 VERSION=20100315
jozee@461 9
jozee@461 10 . /usr/lib/slitaz/gui_functions
pankso@33 11
pankso@33 12 # Check if user is root.
pankso@33 13 check_root()
pankso@33 14 {
pankso@33 15 if test $(id -u) != 0 ; then
pankso@33 16 echo -e "
pankso@194 17 You must be root to run `basename $0`. Please type 'su' and
pankso@33 18 root password to become super-user.\n"
pankso@33 19 exit 0
pankso@33 20 fi
pankso@33 21 }
pankso@33 22
jozee@461 23
pascal@371 24 #
pankso@297 25 # Functions called by the connection tab to list interfaces.
pascal@371 26 #
pascal@371 27 ############################################################
pascal@371 28
pankso@297 29 interface_status()
pankso@297 30 {
pankso@297 31 if ifconfig | grep -A 1 $i | grep -q inet; then
pankso@297 32 ip=`ifconfig | grep -A 1 $i | grep inet | awk '{ print $2 }' | cut -d ":" -f 2`
pankso@297 33 echo "connected ($ip)"
pankso@297 34 else
pankso@297 35 echo "-"
pankso@297 36 fi
pankso@297 37 }
pankso@297 38 # First column is for icon name.
pankso@297 39 detect_interfaces()
pankso@297 40 {
pankso@297 41 for i in `ls /sys/class/net`
pankso@297 42 do
pankso@297 43 case $i in
pankso@297 44 eth*)
pankso@297 45 echo "network-wired | $i | Ethernet | `interface_status`" ;;
pankso@297 46 wlan*|ath*|ra*)
pankso@297 47 echo "network-wireless | $i | Wireless | `interface_status`" ;;
pankso@297 48 lo)
pankso@297 49 echo "gtk-network | $i | Loopback | `interface_status`" ;;
pankso@297 50 *)
pankso@297 51 continue ;;
pankso@297 52 esac
pankso@297 53 done
pankso@297 54 }
pankso@297 55
pankso@297 56 # When users double click on a connection.
pankso@297 57 interfaces_List_actions()
pankso@297 58 {
pankso@297 59 echo "$INTERFACE_LIST"
pankso@297 60 }
pankso@297 61
paul@317 62 # Netbox can be called with args.
pankso@297 63 case "$1" in
pankso@297 64 detect_interfaces|interfaces_List_actions)
pankso@297 65 $1
pankso@297 66 exit 0 ;;
pankso@297 67 *)
pankso@297 68 continue ;;
pankso@297 69 esac
pankso@297 70
pascal@177 71 set_ipup()
pascal@177 72 {
pascal@177 73 [ -f /etc/ppp/ip-up ] && return
pascal@177 74 cat > /etc/ppp/ip-up <<EOT
pascal@177 75 #!/bin/sh
pascal@177 76 exec $0 call ipup \$@
pascal@177 77 EOT
pascal@177 78 chmod +x /etc/ppp/ip-up
pascal@177 79 }
pascal@177 80
pascal@259 81 while true; do
pascal@259 82
pascal@225 83 # Detect WIFI_INTERFACE and update /etc/network.conf
pascal@224 84 . /etc/network.conf
pascal@256 85 if [ ! -d /sys/class/net/$WIFI_INTERFACE/wireless ]; then
pascal@256 86 WIFI_INTERFACE=$(for i in /sys/class/net/*/wireless; do \
pascal@256 87 [ -d $i ] && echo $(basename $(dirname $i)) || echo wlan0; \
pascal@256 88 break; done)
pascal@224 89 [ -n "$WIFI_INTERFACE" ] && sed -i "s/^WIFI_INTERFACE=.*/WIFI_INTERFACE=\"$WIFI_INTERFACE\"/" /etc/network.conf
pascal@224 90 fi
pascal@224 91
pascal@371 92 #
pascal@371 93 # Netbox internal calls
pascal@371 94 #
pascal@371 95 #########################################################
pascal@371 96
pascal@177 97 if [ "$1" = "call" ]; then
pascal@177 98 ppp="pppd local lock notty"
pascal@177 99 pppup=""
pascal@177 100 sub=$2
pascal@177 101 shift 2
pascal@177 102 case "$sub" in
pascal@177 103 sendsshkey)
pascal@177 104 check_root
pascal@372 105 ( dropbearkey -y -f /etc/dropbear/dropbear_rsa_host_key ;
pascal@372 106 cat /etc/ssh/ssh_host_rsa_key.pub ) 2> /dev/null | \
pascal@372 107 grep ^ssh | ssh $1 "mkdir .ssh 2> /dev/null ; \
pascal@372 108 while read key; do for i in authorized_keys authorized_keys2; do \
pascal@414 109 grep -qs '\$key' .ssh/\$i || echo '\$key' >> .ssh/\$i ; done ; done ; \
pascal@372 110 chmod 700 .ssh ; chmod 600 .ssh/authorized_keys*"
pascal@177 111 exit 0;;
pascal@271 112 # OpenSSH VPN:
pascal@271 113 # PermitTunnel=point-to-point (or yes, ethernet, no)
pascal@271 114 # Tunnel="4" => tun4
pascal@271 115 # Local Client:
pascal@271 116 # # ssh -f -w 0:1 $REMOTE true => local tun0 [, remote tun1]
pascal@271 117 # # ifconfig $TUN $IP1 $IP2 netmask 255.255.255.252
pascal@271 118 # # route add $REMOTE_NETWORK $IP2
pascal@271 119 # Remote Server:
pascal@271 120 # # ifconfig $TUN $IP2 $IP1 netmask 255.255.255.252
pascal@271 121 # # route add $LOCAL_NETWORK $IP1
pascal@177 122 vpnssh) check_root
pascal@177 123 set_ipup
pascal@177 124 ps ww | grep -q "$ppp $2:$3" && exit 1
pascal@177 125 pipe="/tmp/ssh$$"
pascal@177 126 mkfifo $pipe
pascal@177 127 [ -n "$4" ] && pppup="ipparam 'addroutes,$(echo $4 | sed 's/ /,/g')'"
pascal@177 128 cat $pipe | dbclient -i /etc/dropbear/dropbear_rsa_host_key \
pascal@177 129 $1 "$ppp" | $ppp $2:$3 $pppup > $pipe
pascal@177 130 rm -f $pipe
pascal@177 131 exit 0;;
pascal@177 132 killvpnssh)
pascal@177 133 check_root
pascal@177 134 kill $(ps x | grep dbclient | grep "$ppp" | awk '{ print $1 }')
pascal@177 135 exit 0;;
pascal@177 136 ipup)
pascal@177 137 # Arg Name Example
pascal@177 138 # $1 Interface name ppp0
pascal@177 139 # $2 The tty ttyS1
pascal@177 140 # $3 The link speed 38400
pascal@177 141 # $4 Local IP number 12.34.56.78
pascal@177 142 # $5 Peer IP number 12.34.56.99
pascal@177 143 # $6 Optional ``ipparam'' value foo
pascal@177 144 iface=$1
pascal@177 145 # skip tty if present
pascal@177 146 case "$2" in [0-9]*);; *) shift; esac
pascal@177 147 peer=$4
pascal@177 148 IFS=","; set -- $(eval echo $5); unset IFS
pascal@177 149 set -- $1
pascal@177 150 if [ "$1" = "addroutes" ]; then
pascal@177 151 while [ -n "$2" ]; do
pascal@177 152 eval $(ipcalc -n $2)
pascal@177 153 eval $(ipcalc -m $2)
pascal@177 154 route add -net $NETWORK netmask $NETMASK \
pascal@177 155 gw $peer $iface
pascal@177 156 shift
pascal@177 157 done
pascal@177 158 fi
pascal@177 159 exit 0;;
pascal@177 160 esac
pascal@177 161 echo "call $sub unsupported."
pascal@177 162 exit 1
pascal@177 163 fi
pascal@177 164
pascal@371 165
pascal@371 166
pascal@371 167 #
pascal@371 168 # Status wire interfaces
pascal@371 169 #
pascal@371 170 tab_status_iface()
pascal@371 171 {
pascal@375 172 local eth
pascal@375 173 eth="$( (cd /sys/class/net ; [ -d eth0 ] && ls -d eth* ) )"
pascal@375 174 which ethtool > /dev/null || eth=''
pascal@375 175 if [ -n "$eth" ]; then
pascal@375 176 cat <<EOT
pascal@375 177 <notebook labels="Ifconfig|$(echo $eth | sed 's/ /|/g')">
pascal@375 178 EOT
pascal@375 179 fi
pascal@371 180 cat <<EOT
pascal@371 181 <frame Ifconfig>
pascal@371 182 <text wrap="false" width-chars="58">
pascal@371 183 <input>ifconfig</input>
pankso@292 184 </text>
pascal@371 185 </frame>
pascal@371 186 EOT
pascal@375 187 if [ -n "$eth" ]; then
pascal@375 188 local i
pascal@375 189 for i in $eth ; do
pascal@375 190 cat <<EOT
pascal@375 191 <frame $i>
pascal@375 192 <text wrap="false" width-chars="58">
pascal@375 193 <input>ethtool $i</input>
pascal@375 194 </text>
pascal@375 195 </frame>
pascal@375 196 EOT
pascal@375 197 done
pascal@375 198 cat <<EOT
pascal@375 199 </notebook>
pascal@375 200 EOT
pascal@375 201 fi
pascal@371 202 }
pascal@371 203
pascal@371 204 #
pascal@371 205 # Status wifi interfaces
pascal@371 206 #
pascal@371 207 tab_status_wifi_iface()
pascal@371 208 {
pascal@371 209 cat <<EOT
pascal@371 210 <frame Iwconfig>
pascal@371 211 <text wrap="false" width-chars="58">
pascal@371 212 <input>iwconfig</input>
pascal@371 213 </text>
pascal@371 214 </frame>
pascal@371 215 EOT
pascal@371 216 }
pascal@371 217
pascal@371 218 #
pascal@371 219 # Status wifi network
pascal@371 220 #
pascal@371 221 tab_status_wifi_net()
pascal@371 222 {
pascal@371 223 cat <<EOT
pascal@371 224 <frame Wireless networks>
pascal@371 225 <text wrap="false" width-chars="58">
pascal@371 226 <input>iwlist scan</input>
pascal@371 227 </text>
pascal@371 228 </frame>
pascal@371 229 EOT
pascal@371 230 }
pascal@371 231
pascal@371 232 #
pascal@371 233 # Status routing
pascal@371 234 #
pascal@371 235 tab_status_route()
pascal@371 236 {
pascal@371 237 cat <<EOT
pascal@371 238 <frame Routing>
pascal@371 239 <frame Nameservers>
pascal@371 240 <text wrap="false" width-chars="58">
pascal@371 241 <input>cat /etc/resolv.conf</input>
pankso@292 242 </text>
pankso@292 243 </frame>
pascal@371 244 <frame Routing table>
pascal@371 245 <text wrap="false" width-chars="58">
pascal@371 246 <input>route</input>
pankso@292 247 </text>
pankso@292 248 </frame>
pascal@371 249 <frame Arp table>
pascal@371 250 <text wrap="false" width-chars="58">
pascal@371 251 <input>arp</input>
pascal@371 252 </text>
pascal@371 253 </frame>
pascal@371 254 </frame>
pascal@371 255 EOT
pascal@371 256 }
pankso@194 257
pascal@371 258 data_status()
pascal@371 259 {
pascal@371 260 cat <<EOT
pascal@371 261 ifconfig Network\ interfaces tab_status_iface
pascal@371 262 iwconfig Wireless\ interfaces tab_status_wifi_iface
pascal@371 263 iwlist Wireless\ networks tab_status_wifi_net
pascal@371 264 route Routing tab_status_route
pascal@371 265 EOT
pascal@371 266 }
pascal@371 267
pankso@33 268 #
pascal@371 269 # Status
pascal@371 270 #
pascal@371 271 tab_status()
pascal@371 272 {
pascal@371 273 use_tab data_status
pascal@371 274 }
pankso@194 275
pascal@371 276 #
pankso@297 277 # Interfaces list from detect_interfaces()
pascal@371 278 #
pascal@371 279 tab_connections()
pascal@371 280 {
pascal@371 281 cat <<EOT
pankso@297 282 <vbox>
pankso@297 283 <tree>
pankso@297 284 <width>520</width><height>120</height>
pankso@297 285 <variable>INTERFACE_LIST</variable>
pankso@297 286 <label>Interface|Type|Status</label>
pascal@371 287 <input icon_column="0">$0 detect_interfaces</input>
pankso@297 288 <action>refresh:INTERFACE_LIST</action>
pankso@297 289 </tree>
pascal@371 290 </vbox>
pascal@371 291 EOT
pascal@371 292 }
pankso@297 293
pascal@371 294 #
pankso@297 295 # DHCP
pascal@371 296 #
pascal@371 297 tab_udhcpc()
pascal@371 298 {
pascal@371 299 cat <<EOT
pankso@292 300 <frame Udhcpc (busybox)>
pankso@292 301 <text width-chars="58">
pascal@371 302 <label> "Ethernet (cable) default connection." </label>
pankso@292 303 </text>
pankso@292 304 <hbox>
pankso@292 305 <text use-markup="true">
pankso@292 306 <label>"<b>Interface:</b>"</label>
pankso@292 307 </text>
pankso@292 308 <entry>
pascal@371 309 <input>. /etc/network.conf; echo "\$INTERFACE"</input>
pankso@292 310 <variable>INTERFACE</variable>
pankso@292 311 </entry>
pankso@292 312 </hbox>
pankso@292 313 <hbox>
pankso@292 314 <text use-markup="true">
pankso@292 315 <label>"<b>Options: </b>"</label>
pankso@292 316 </text>
pankso@292 317 <entry>
pankso@292 318 <default>-b</default>
pankso@292 319 <variable>UDHCPC_OPTS</variable>
pankso@292 320 </entry>
pascal@372 321 $(helpbutton udhcpc 80x30)
pankso@292 322 </hbox>
pankso@292 323 <hbox>
pankso@292 324 <text use-markup="true">
pankso@292 325 <label>"<b>Script: </b>"</label>
pankso@292 326 </text>
pankso@292 327 <entry editable="false">
pankso@292 328 <default>/usr/share/udhcpc/default.script</default>
pankso@292 329 <variable>UDHCPC_SCRIPT</variable>
pankso@292 330 </entry>
pascal@377 331 $(editbutton \$UDHCPC_SCRIPT)
pankso@292 332 </hbox>
pankso@292 333 <hbox>
pankso@292 334 <button>
pankso@292 335 <label>Start</label>
pankso@292 336 <input file icon="forward"></input>
pascal@545 337 <action>sed -i s/^INTERFACE=.*/INTERFACE=\"\$INTERFACE\"/ /etc/network.conf</action>
pascal@545 338 <action>sed -i s/^DHCP=.*/DHCP=\"yes\"/ /etc/network.conf</action>
pascal@545 339 <action>sed -i s/^STATIC=.*/STATIC=\"no\"/ /etc/network.conf</action>
pascal@371 340 <action>udhcpc \$UDHCPC_OPTS -i \$INTERFACE -p /var/run/udhcpc.\$INTERFACE.pid</action>
pankso@297 341 <action>refresh:INTERFACE_LIST</action>
pankso@292 342 </button>
pankso@292 343 <button>
pankso@292 344 <label>Stop</label>
pankso@292 345 <input file icon="stop"></input>
pascal@371 346 <action>echo -n "Stopping interface : \$INTERFACE... "</action>
pascal@371 347 <action>ifconfig \$INTERFACE down</action>
pankso@292 348 <action>killall -q udhcpc; echo "done"</action>
pankso@297 349 <action>refresh:INTERFACE_LIST</action>
pankso@292 350 </button>
pankso@292 351 </hbox>
pascal@371 352 </frame>
pascal@371 353 EOT
pascal@371 354 }
pankso@194 355
pascal@371 356 #
pankso@292 357 # Static/fixed IP settings.
pascal@371 358 #
pascal@371 359 tab_fixed_ip()
pascal@371 360 {
pascal@371 361 cat <<EOT
pankso@292 362 <frame Ethernet fixed IP>
pankso@292 363 <hbox>
pankso@292 364 <text use-markup="true">
pankso@292 365 <label>"<b>Interface: </b>"</label>
pankso@292 366 </text>
pankso@292 367 <entry>
pascal@371 368 <input>. /etc/network.conf; echo "\$INTERFACE"</input>
pankso@292 369 <variable>INTERFACE</variable>
pankso@292 370 </entry>
pankso@292 371 </hbox>
pankso@292 372 <hbox>
pankso@292 373 <text use-markup="true">
pankso@292 374 <label>"<b>IP: </b>"</label>
pankso@292 375 </text>
pankso@292 376 <entry>
pascal@371 377 <input>. /etc/network.conf; echo "\$IP"</input>
pankso@292 378 <variable>IP</variable>
pankso@292 379 </entry>
pankso@292 380 </hbox>
pankso@292 381 <hbox>
pankso@292 382 <text use-markup="true">
pankso@292 383 <label>"<b>Netmask: </b>"</label>
pankso@292 384 </text>
pankso@292 385 <entry>
pascal@371 386 <input>. /etc/network.conf; echo "\$NETMASK"</input>
pankso@292 387 <variable>NETMASK</variable>
pankso@292 388 </entry>
pankso@292 389 </hbox>
pankso@292 390 <hbox>
pankso@292 391 <text use-markup="true">
pankso@292 392 <label>"<b>Gateway: </b>"</label>
pankso@292 393 </text>
pankso@292 394 <entry>
pascal@371 395 <input>. /etc/network.conf; echo "\$GATEWAY"</input>
pankso@292 396 <variable>GATEWAY</variable>
pankso@292 397 </entry>
pankso@292 398 </hbox>
pankso@292 399 <hbox>
pankso@292 400 <text use-markup="true">
pankso@292 401 <label>"<b>DNS server: </b>"</label>
pankso@292 402 </text>
pankso@292 403 <entry>
pascal@371 404 <input>. /etc/network.conf; echo "\$DNS_SERVER"</input>
pankso@292 405 <variable>DNS_SERVER</variable>
pankso@292 406 </entry>
pascal@371 407 </hbox>
pankso@292 408 <hbox>
pankso@292 409 <button>
pankso@292 410 <label>Start</label>
pankso@292 411 <input file icon="forward"></input>
pankso@292 412 <action>ifconfig lo down</action>
pascal@371 413 <action>ifconfig \$INTERFACE down</action>
pascal@545 414 <action>sed -i s/^INTERFACE=.*/INTERFACE=\"\$INTERFACE\"/ /etc/network.conf</action>
pascal@545 415 <action>sed -i s/^DHCP=.*/DHCP=\"no\"/ /etc/network.conf</action>
pascal@545 416 <action>sed -i s/^WIFI=.*/WIFI=\"no\"/ /etc/network.conf</action>
pascal@545 417 <action>sed -i s/^STATIC=.*/STATIC=\"yes\"/ /etc/network.conf</action>
pascal@545 418 <action>sed -i s/^IP=.*/IP=\"\$IP\"/ /etc/network.conf</action>
pascal@545 419 <action>sed -i s/^NETMASK=.*/NETMASK=\"\$NETMASK\"/ /etc/network.conf</action>
pascal@545 420 <action>sed -i s/^GATEWAY=.*/GATEWAY=\"\$GATEWAY\"/ /etc/network.conf</action>
pascal@545 421 <action>sed -i s/^DNS_SERVER=.*/DNS_SERVER=\"\$DNS_SERVER\"/ /etc/network.conf</action>
pankso@292 422 <action>/etc/init.d/network.sh</action>
pankso@297 423 <action>refresh:INTERFACE_LIST</action>
pankso@292 424 </button>
pankso@292 425 <button>
pankso@292 426 <label>Stop</label>
pankso@292 427 <input file icon="stop"></input>
pascal@371 428 <action>ifconfig \$INTERFACE down</action>
pankso@297 429 <action>refresh:INTERFACE_LIST</action>
pankso@292 430 </button>
pankso@292 431 </hbox>
pascal@371 432 </frame>
pascal@371 433 EOT
pascal@371 434 }
pankso@292 435
pascal@371 436 #
pankso@292 437 # PPPoe settings.
pascal@371 438 #
pascal@371 439 tab_pppoe()
pascal@371 440 {
pascal@371 441 cat <<EOT
pankso@292 442 <frame PPPoE>
pankso@292 443 <hbox>
pankso@292 444 <text use-markup="true">
pankso@292 445 <label>"<b>Name: </b>"</label>
pankso@292 446 </text>
pankso@292 447 <entry>
pascal@371 448 <input>NAME=\$(grep -s ^name /etc/ppp/options); echo "\${NAME#* }"</input>
pankso@292 449 <variable>NAME</variable>
pankso@292 450 </entry>
pankso@292 451 </hbox>
pankso@292 452 <hbox>
pankso@292 453 <text use-markup="true">
pankso@292 454 <label>"<b>Username:</b>"</label>
pankso@292 455 </text>
pankso@292 456 <entry>
pankso@292 457 <variable>USER</variable>
pankso@292 458 </entry>
pankso@292 459 </hbox>
pankso@292 460 <hbox>
pankso@292 461 <text use-markup="true">
pankso@292 462 <label>"<b>Password:</b>"</label>
pankso@292 463 </text>
pankso@292 464 <entry>
pankso@292 465 <variable>PASS</variable>
pankso@292 466 </entry>
pankso@292 467 </hbox>
pankso@292 468 <hbox>
pascal@371 469 $(helpbutton pppd 80x30)
pascal@371 470 $(manbutton 8 pppd)
pascal@374 471 $(webbutton ppp)
pankso@292 472 <button>
pankso@292 473 <input file icon="accessories-text-editor"></input>
pankso@292 474 <label>Tune</label>
pascal@545 475 <action>[ -n "\$NAME" ] && sed -i \"s/^name .*/name \$NAME/\" /etc/ppp/options</action>
pankso@292 476 <action type="lauch">leafpad /etc/ppp/options</action>
pankso@292 477 </button>
pankso@292 478 <button>
pankso@292 479 <label>Start</label>
pankso@292 480 <input file icon="forward"></input>
pascal@371 481 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/pap-secrets
pascal@371 482 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/pap-secrets</action>
pascal@371 483 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/chap-secrets
pascal@371 484 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/chap-secrets</action>
pascal@545 485 <action>[ -n "\$NAME" ] && sed -i \"s/^name .*/name \$NAME/\" /etc/ppp/options</action>
pankso@292 486 <action>killall udhcpc</action>
pascal@545 487 <action>sed -i s/DHCP=.*/DHCP=\"no\"/ /etc/network.conf</action>
pascal@545 488 <action>sed -i s/PPPOE=.*/PPPOE=\"yes\"/ /etc/network.conf</action>
pascal@371 489 <action>pppd \$INTERFACE &</action>
pankso@292 490 </button>
pankso@292 491 <button>
pankso@292 492 <label>Stop</label>
pankso@292 493 <input file icon="stop"></input>
pascal@545 494 <action>sed -i s/PPPOE=.*/PPPOE=\"no\"/ /etc/network.conf</action>
pankso@292 495 <action>killall pppd</action>
pankso@292 496 </button>
pankso@292 497 </hbox>
pascal@371 498 </frame>
pascal@371 499 EOT
pascal@371 500 }
pankso@292 501
pascal@371 502 #
pankso@292 503 # PPP settings.
pascal@371 504 #
pascal@371 505 tab_ppp()
pascal@371 506 {
pascal@371 507 cat <<EOT
pankso@292 508 <frame PPP>
pankso@292 509 <hbox>
pankso@292 510 <text use-markup="true">
pankso@292 511 <label>"<b>Username: </b>"</label>
pankso@292 512 </text>
pankso@292 513 <entry>
pascal@371 514 <input>USER=\$(grep -s ^ACCOUNT= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${USER#*=}"</input>
pankso@292 515 <variable>USER</variable>
pankso@292 516 </entry>
pankso@292 517 </hbox>
pankso@292 518 <hbox>
pankso@292 519 <text use-markup="true">
pankso@292 520 <label>"<b>Password: </b>"</label>
pankso@292 521 </text>
pankso@292 522 <entry>
pascal@371 523 <input>PASS=\$(grep -s ^PASSWORD= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${PASS#*=}"</input>
pankso@292 524 <variable>PASS</variable>
pankso@292 525 </entry>
pankso@292 526 </hbox>
pankso@292 527 <hbox>
pankso@292 528 <text use-markup="true">
pankso@292 529 <label>"<b>Telephone:</b>"</label>
pankso@292 530 </text>
pankso@292 531 <entry>
pascal@371 532 <input>PHONE=\$(grep -s ^TELEPHONE= /etc/ppp/scripts/ppp-on | cut -f1); echo "\${PHONE#*=}"</input>
pankso@292 533 <variable>PHONE</variable>
pankso@292 534 </entry>
pankso@292 535 </hbox>
pankso@292 536 <hbox>
pascal@371 537 $(helpbutton pppd 80x30)
pascal@371 538 $(manbutton 8 pppd)
pascal@374 539 $(webbutton ppp)
pankso@292 540 <button>
pankso@292 541 <input file icon="accessories-text-editor"></input>
pankso@292 542 <label>Tune</label>
pascal@545 543 <action>[ -n "\$NAME" ] && sed -i \"s/^ACCOUNT=.*/ACCOUNT=\$NAME/\" /etc/ppp/scripts/ppp-on</action>
pascal@545 544 <action>[ -n "\$PASS" ] && sed -i \"s/^PASSWORD=.*/PASSWORD=\$PASS/\" /etc/ppp/scripts/ppp-on</action>
pascal@545 545 <action>[ -n "\$PHONE" ] && sed -i \"s/^TELEPHONE=.*/TELEPHONE=\$PHONE/\" /etc/ppp/scripts/ppp-on</action>
pankso@292 546 <action type="lauch">leafpad /etc/ppp/scripts/ppp-on</action>
pankso@292 547 </button>
pankso@292 548 <button>
pankso@292 549 <label>Start</label>
pankso@292 550 <input file icon="forward"></input>
pascal@371 551 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/pap-secrets
pascal@371 552 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/pap-secrets</action>
pascal@371 553 <action>[ -n "\$USER" ] && grep -qs "^\"\$USER\"" /etc/ppp/chap-secrets
pascal@371 554 && echo "\"\$USER\" * \"\$PASS\"" >> /etc/ppp/chap-secrets</action>
pascal@545 555 <action>[ -n "\$NAME" ] && sed -i \"s/^name .*/name \$NAME/\" /etc/ppp/options</action>
pankso@292 556 <action>/etc/ppp/scripts/ppp-off</action>
pankso@292 557 <action>/etc/ppp/scripts/ppp-on &</action>
pankso@292 558 </button>
pankso@292 559 <button>
pankso@292 560 <label>Stop</label>
pankso@292 561 <input file icon="stop"></input>
pankso@292 562 <action>/etc/ppp/scripts/ppp-off</action>
pankso@292 563 </button>
pankso@292 564 </hbox>
pascal@371 565 </frame>
pascal@371 566 EOT
pascal@371 567 }
pankso@292 568
pankso@292 569 #
pascal@371 570 # System Wide configuration.
pankso@292 571 #
pascal@371 572 tab_system()
pascal@371 573 {
pascal@371 574 cat <<EOT
pascal@371 575 <frame Configuration files>
pankso@33 576 <hbox>
pankso@33 577 <text use-markup="true">
pankso@34 578 <label>"<b>Hosts :</b>"</label>
pankso@33 579 </text>
pankso@33 580 <entry editable="false">
pankso@33 581 <default>/etc/hosts</default>
pankso@33 582 <variable>HOSTS</variable>
pankso@33 583 </entry>
pascal@377 584 $(editbutton \$HOSTS)
pankso@33 585 </hbox>
pankso@33 586 <hbox>
pankso@33 587 <text use-markup="true">
pankso@34 588 <label>"<b>Host name :</b>"</label>
pankso@33 589 </text>
pankso@33 590 <entry editable="false">
pankso@33 591 <default>/etc/hostname</default>
pankso@33 592 <variable>HOSTNAME</variable>
pankso@33 593 </entry>
pascal@377 594 $(editbutton \$HOSTNAME)
pankso@33 595 </hbox>
pankso@33 596 <hbox>
pankso@33 597 <text use-markup="true">
pankso@34 598 <label>"<b>Network :</b>"</label>
pankso@33 599 </text>
pankso@33 600 <entry editable="false">
pankso@33 601 <default>/etc/network.conf</default>
pankso@33 602 <variable>CONFIG_FILE</variable>
pankso@33 603 </entry>
pascal@377 604 $(editbutton \$CONFIG_FILE)
pankso@33 605 </hbox>
pankso@33 606 <hbox>
pankso@33 607 <button>
pankso@33 608 <label>Restart</label>
pankso@33 609 <input file icon="reload"></input>
pascal@371 610 <action>echo -n "Stopping interface : \$INTERFACE... "</action>
pascal@371 611 <action>ifconfig \$INTERFACE down</action>
pankso@33 612 <action>killall -q udhcpc; echo "done"</action>
pascal@261 613 <action>/etc/init.d/network.sh restart</action>
pankso@33 614 </button>
pankso@33 615 </hbox>
pascal@371 616 </frame>
pascal@371 617 EOT
pascal@371 618 }
pankso@194 619
pascal@371 620 #
pascal@371 621 # ssh/ppp
pascal@371 622 #
pascal@371 623 tab_sshppp()
pascal@371 624 {
pascal@371 625 cat <<EOT
pascal@177 626 <frame Virtual Private Network with PPP/SSH>
pascal@177 627 <hbox>
pascal@177 628 <text use-markup="true">
pascal@177 629 <label>"<b>Peer :</b>"</label>
pascal@177 630 </text>
pascal@177 631 <entry>
pascal@177 632 <variable>DROPBEAR_PEERVPN</variable>
pascal@177 633 <default>user@elsewhere</default>
pascal@177 634 </entry>
pascal@177 635 </hbox>
pascal@177 636 <hbox>
pascal@177 637 <text use-markup="true">
pascal@177 638 <label>"<b>Local IP :</b>"</label>
pascal@177 639 </text>
pascal@177 640 <entry>
pascal@177 641 <variable>DROPBEAR_LOCAL</variable>
pascal@177 642 <default>192.168.254.1</default>
pascal@177 643 </entry>
pascal@177 644 </hbox>
pascal@177 645 <hbox>
pascal@177 646 <text use-markup="true">
pascal@177 647 <label>"<b>Remote IP :</b>"</label>
pascal@177 648 </text>
pascal@177 649 <entry>
pascal@177 650 <variable>DROPBEAR_REMOTE</variable>
pascal@177 651 <default>192.168.254.2</default>
pascal@177 652 </entry>
pascal@177 653 </hbox>
pascal@177 654 <hbox>
pascal@177 655 <text use-markup="true">
pascal@177 656 <label>"<b>Route(s) :</b>"</label>
pascal@177 657 </text>
pascal@177 658 <entry>
pascal@177 659 <variable>DROPBEAR_ROUTE</variable>
pascal@177 660 <default>192.168.10.0/24 192.168.20.0/28</default>
pascal@177 661 </entry>
pascal@177 662 </hbox>
pascal@177 663 <hbox>
pascal@498 664 $(wikibutton http://doc.slitaz.org/en:guides:vpn)
pascal@247 665 <button>
pascal@177 666 <input file icon="forward"></input>
pascal@177 667 <label>Connect</label>
pascal@371 668 <action>$0 call vpnssh \$DROPBEAR_PEERVPN \$DROPBEAR_LOCAL \$DROPBEAR_REMOTE "\$DROPBEAR_ROUTE" &</action>
pascal@177 669 </button>
pascal@177 670 <button>
pascal@177 671 <input file icon="stop"></input>
pascal@177 672 <label>Disconnect</label>
pascal@371 673 <action>$0 call killvpnssh</action>
pascal@177 674 </button>
pascal@177 675 <button>
pascal@177 676 <input file icon="go-up"></input>
pascal@177 677 <label>Send key</label>
pascal@372 678 <action>$xterm -geometry 80x10 -title "Send key" -e "$0 call sendsshkey \$DROPBEAR_PEERVPN; echo -e \"----\nENTER to continue...\" && read close"</action>
pascal@177 679 </button>
pascal@177 680 </hbox>
pascal@177 681 </frame>
pascal@371 682 EOT
pascal@371 683 }
pascal@371 684
pascal@371 685 #
pascal@371 686 # PPTP client
pascal@371 687 #
pascal@371 688 #FIXME
pascal@371 689 #cat > /etc/ppp/peers/$TUNNEL <<EOT
pascal@371 690 #pty "pptp $SERVER --nolaunchpppd"
pascal@371 691 #lock
pascal@371 692 #noauth
pascal@371 693 #nobsdcomp
pascal@371 694 #nodeflate
pascal@371 695 #name $DOMAIN\\$USERNAME
pascal@371 696 #remotename $TUNNEL
pascal@371 697 #ipparam $TUNNEL
pascal@371 698 #$(encryption && echo "require-mppe-128")
pascal@371 699 #EOT
pascal@371 700 #pppd call $TUNNEL updetach
pascal@371 701
pascal@371 702 tab_pptp()
pascal@371 703 {
pascal@371 704 [ -f /etc/ppp/options.pptp ] || cat >> /etc/ppp/options.pptp <<EOT
pascal@371 705 lock noauth nobsdcomp nodeflate remotename PPTP
pascal@371 706 EOT
pascal@371 707 [ -f /etc/ppp/pptp-servers ] || cat >> /etc/ppp/pptp-servers <<EOT
pascal@371 708 # PPTP servers list
pascal@371 709 EOT
pascal@371 710 cat <<EOT
pascal@371 711 <frame Virtual Private Network with PPTP>
pascal@371 712 <hbox>
pascal@371 713 <text use-markup="true">
pascal@371 714 <label>"<b>Server:</b>"</label>
pascal@371 715 </text>
pascal@371 716 <combobox>
pascal@371 717 <variable>PPTP_SERVER</variable>
pascal@371 718 EOT
pascal@371 719 grep -v ^\# /etc/ppp/pptp-servers | \
pascal@371 720 awk '{ printf " <item>%s</item>\n",$1 }'
pascal@371 721 cat <<EOT
pascal@371 722 <item>SERVER</item>
pascal@371 723 </combobox>
pascal@377 724 $(editbutton /etc/ppp/pptp-servers)
pascal@371 725 </hbox>
pascal@371 726 <hbox>
pascal@371 727 <text use-markup="true">
pascal@371 728 <label>"<b> User:</b>"</label>
pascal@371 729 </text>
pascal@371 730 <combobox>
pascal@371 731 <variable>PPTP_USER</variable>
pascal@371 732 EOT
pascal@371 733 grep '\\' /etc/ppp/chap-secrets | grep -v ^\# | \
pascal@371 734 awk '{ printf " <item>%s</item>\n",$1 }'
pascal@371 735 cat <<EOT
pascal@371 736 <item>DOMAIN\USERNAME</item>
pascal@371 737 </combobox>
pascal@377 738 $(editbutton /etc/ppp/chap-secrets)
pascal@371 739 </hbox>
pascal@371 740 <hbox>
pascal@371 741 <text use-markup="true">
pascal@371 742 <label>"<b>Password:</b>"</label>
pascal@371 743 </text>
pascal@371 744 <entry>
pascal@371 745 <variable>PPTP_PASS</variable>
pascal@371 746 </entry>
pascal@371 747 </hbox>
pascal@371 748 <hbox>
pascal@371 749 <checkbox>
pascal@371 750 <label>Encryption</label>
pascal@371 751 <variable>PPTP_ENC</variable>
pascal@371 752 <default>true</default>
pascal@371 753 </checkbox>
pascal@371 754 $(helpbutton pptp 80x35)
pascal@371 755 <button>
pascal@371 756 <input file icon="accessories-text-editor"></input>
pascal@371 757 <label>Options</label>
pascal@371 758 <action type="lauch">leafpad /etc/ppp/options.pptp</action>
pascal@371 759 </button>
pascal@374 760 $(webbutton pptpclient)
pascal@371 761 <button>
pascal@371 762 <input file icon="forward"></input>
pascal@371 763 <label>Connect</label>
pascal@371 764 <action>grep -qs ^\$PPTP_USER /etc/ppp/chap-secrets || \
pascal@371 765 echo "\$PPTP_USER PPTP \"$PPTP_PASS\" *" >> /etc/ppp/chap-secrets</action>
pascal@371 766 <action>grep -qs ^\$PPTP_SERVER /etc/ppp/pptp-servers || \
pascal@371 767 echo "\$PPTP_SERVER" >> /etc/ppp/pptp-servers</action>
pascal@371 768 <action>PASS=""; [ -n "\$PPTP_PASS" ] && PASS="password \$PASS"; \
pascal@371 769 ENC=""; [ x\$PPTP_ENC == xtrue ] && ENC="require-mppe-128"; \
pascal@371 770 /usr/sbin/pptp \$PPTP_SERVER file /etc/ppp/options.pptp \$ENC user \$PPTP_USER \$PASS &
pascal@371 771 </action>
pascal@371 772 </button>
pascal@371 773 <button>
pascal@371 774 <input file icon="stop"></input>
pascal@371 775 <label>Disconnect</label>
pascal@371 776 <action>killall pptp</action>
pascal@371 777 </button>
pascal@371 778 </hbox>
pascal@371 779 </frame>
pascal@371 780 EOT
pascal@371 781 }
pascal@371 782
pascal@374 783 #
pascal@374 784 # Cisco EasyVPN
pascal@374 785 #
pascal@374 786 tab_easyvpn()
pascal@374 787 {
pascal@374 788 cat <<EOT
pascal@374 789 <frame Cisco EasyVPN>
pascal@374 790 <hbox>
pascal@374 791 <text use-markup="true">
pascal@374 792 <label>"<b>VPNC_OPTIONS</b>"</label>
pascal@374 793 </text>
pascal@374 794 <entry editable="false">
pascal@374 795 EOT
pascal@374 796 [ -n "$VPNC_OPTIONS" ] && cat << EOT
pascal@374 797 <default>$tmp</default>
pascal@374 798 EOT
pascal@374 799 cat << EOT
pascal@374 800 <variable>VPNC_OPTS</variable>
pascal@374 801 </entry>
pascal@374 802 $(helpbutton vpnc 80x30)
pascal@374 803 <button>
pascal@374 804 <input file icon="help"></input>
pascal@374 805 <label>more</label>
pascal@374 806 <action>$xterm -geometry 80x40 -title "vpnc help (q to quit)" -e "$(which vpnc) --long-help 2>&1 | less"</action>
pascal@374 807 </button>
pascal@374 808 $(editbutton /etc/daemons.conf)
pascal@374 809 </hbox>
pascal@374 810 $(configfile /etc/vpnc/default.conf VPNC_CONF)
pascal@374 811 $(datafile "/etc/vpnc/vpnc-script" VPNC_SCRIPT 'Script:')
pascal@374 812 <hbox>
pascal@374 813 $(startstopdaemon vpnc)
pascal@374 814 </hbox>
pascal@374 815 </frame>
pascal@374 816 EOT
pascal@374 817 }
pascal@374 818
pascal@375 819 #
pascal@375 820 # OpenVPN
pascal@375 821 #
pascal@375 822 tab_openvpn()
pascal@375 823 {
pascal@375 824 local i
pascal@375 825 local n
pascal@375 826 cat <<EOT
pascal@375 827 <frame OpenVPN>
pascal@375 828 EOT
pascal@375 829 n=1
pascal@375 830 for i in /etc/openvpn/*.conf ; do
pascal@375 831 [ -f $i ] || continue
pascal@375 832 configfile $i OPENVPN_CONF$n
pascal@375 833 n=$(($n + 1))
pascal@375 834 done
pascal@375 835 cat <<EOT
pascal@375 836 <hbox>
pascal@375 837 $(helpbutton openvpn 80x40)
pascal@375 838 $(startstopdaemon openvpn)
pascal@375 839 </hbox>
pascal@375 840 </frame>
pascal@375 841 EOT
pascal@375 842 }
pascal@375 843
pascal@371 844 data_vpn()
pascal@371 845 {
pascal@371 846 cat <<EOT
pascal@371 847 $([ -x /usr/sbin/dropbear -o -x /usr/sbin/sshd ] && echo "pppd" ||
pascal@371 848 echo "#") PPP/SSH tab_sshppp
pascal@371 849 pptp PPTP tab_pptp
pascal@374 850 vpnc EasyVPN tab_easyvpn
pascal@375 851 openvpn OpenVPN tab_openvpn
pascal@371 852 EOT
pascal@371 853 }
pascal@371 854
pascal@371 855 #
pascal@371 856 # VPN
pascal@371 857 #
pascal@371 858 tab_vpn()
pascal@371 859 {
pascal@371 860 use_tab data_vpn
pascal@371 861 }
pascal@272 862
pascal@371 863 #
pascal@371 864 # ether-wake
pascal@371 865 #
pascal@371 866 tab_etherwake()
pascal@371 867 {
pascal@371 868 cat <<EOT
pascal@271 869 <frame Ether-wake (busybox)>
pascal@141 870 <hbox>
pascal@141 871 <text use-markup="true">
pascal@151 872 <label>"<b>Machines :</b>"</label>
pascal@151 873 </text>
pascal@151 874 <entry editable="false">
pascal@151 875 <default>/etc/ethers</default>
pascal@151 876 <variable>ETHERS</variable>
pascal@151 877 </entry>
pascal@151 878 <button>
pascal@151 879 <input file icon="accessories-text-editor"></input>
pascal@372 880 <action>[ -s \$ETHERS ] || echo "#00:01:02:03:04:05 mystation" >\$ETHERS</action>
pascal@371 881 <action type="lauch">leafpad \$ETHERS</action>
pascal@151 882 </button>
pascal@151 883 </hbox>
pascal@151 884 <hbox>
pascal@151 885 <text use-markup="true">
pascal@141 886 <label>"<b>Options : </b>"</label>
pascal@141 887 </text>
pascal@271 888 <entry editable="true">
pascal@141 889 <variable>ETHERWAKE_OPTS</variable>
pascal@371 890 </entry>
pascal@371 891 $(helpbutton ether-wake 80x15)
pascal@371 892 <button>
pascal@371 893 <label>Start</label>
pascal@371 894 <input file icon="forward"></input>
pascal@371 895 <action>ether-wake \$ETHERWAKE_OPTS</action>
pascal@371 896 </button>
pascal@371 897 </hbox>
pascal@375 898 <frame>
pascal@375 899 <hbox>
pascal@375 900 EOT
pascal@375 901 if which ethtool > /dev/null; then
pascal@375 902 cat <<EOT
pascal@375 903 <text use-markup="true">
pascal@375 904 <label>"<b>Interface:</b>"</label>
pascal@375 905 </text>
pascal@375 906 <combobox>
pascal@375 907 <variable>ETHERWAKE_ETH</variable>
pascal@375 908 EOT
pascal@375 909 (cd /sys/class/net ; [ -d eth0 ] && ls -d eth* ) | \
pascal@375 910 awk '{ printf " <item>%s</item>\n",$1 }'
pascal@375 911 cat <<EOT
pascal@375 912 </combobox>
pascal@375 913 <button>
pascal@375 914 <label>Enable Wake On LAN</label>
pascal@375 915 <input file icon="forward"></input>
pascal@375 916 <action>ethtool -s \$ETHERWAKE_ETH wok g</action>
pascal@375 917 </button>
pascal@375 918 EOT
pascal@375 919 else
pascal@375 920 cat <<EOT
pascal@375 921 <vbox>
pascal@375 922 <text wrap="true" width-chars="58">
pascal@375 923 <label>
paul@398 924 "Ethtool can enable the Wake-on-lan
paul@378 925 feature on many Ethernet cards.
pascal@375 926 "
pascal@375 927 </label>
pascal@375 928 </text>
pascal@375 929 $(installbox ethtool)
pascal@375 930 </vbox>
pascal@375 931 EOT
pascal@375 932 fi
pascal@375 933 cat <<EOT
pascal@375 934 </hbox>
pascal@375 935 </frame>
pascal@371 936 </frame>
pascal@371 937 EOT
pascal@371 938 }
pankso@33 939
pascal@371 940 data_main()
pascal@371 941 {
pascal@371 942 cat <<EOT
pascal@371 943 #program tab name function
pascal@371 944 ifconfig Connections tab_connections
pascal@371 945 udhcpc DHCP tab_udhcpc
pascal@371 946 ifconfig Static\ IP tab_fixed_ip
pascal@371 947 pppoe PPPoE tab_pppoe
pascal@371 948 pppd PPP tab_ppp
pascal@371 949 true VPN tab_vpn
pascal@371 950 ether-wake Etherwake tab_etherwake
jozee@461 951 true Configuration tab_system
pascal@371 952 EOT
pascal@371 953 }
pascal@371 954
pascal@371 955 tab_main()
pascal@371 956 {
pascal@371 957 use_tab data_main
pascal@371 958 }
pascal@371 959
pascal@371 960 ######################################################
pascal@371 961 #
pascal@371 962 # Netbox GUI
pascal@371 963 #
pascal@371 964 ######################################################
pascal@371 965
pascal@371 966 # English/French help dialog.
pascal@371 967 export HELP='
pascal@371 968 <window title="Network status" icon-name="network-wire">
pascal@371 969 <vbox>
pascal@371 970 <text use-markup="true">
pascal@371 971 <label>
pascal@371 972 "
pascal@371 973 <b>SliTaz - Netbox</b>"
pascal@371 974 </label>
pascal@371 975 </text>
pascal@371 976 <frame English>
pascal@371 977 <text wrap="true" width-chars="58">
pascal@371 978 <label>
pascal@371 979 "Netbox lets you manage network connections by getting a dynamic IP by
pascal@371 980 DHCP or a static IP and setup servers. Netbox can start or stop
pascal@371 981 networking, configure network interfaces or directly edit files."
pascal@371 982 </label>
pascal@371 983 </text>
pascal@371 984 </frame>
pascal@371 985 <frame Francais>
pascal@371 986 <text wrap="true" width-chars="58">
pascal@371 987 <label>
pascal@371 988 "Netbox vous permet de gerer les connexions reseau avec une IP
pascal@371 989 statique ou en obtenant une IP dynamique par DHCP, et de parametrer
pascal@371 990 les serveurs. Netbox peut demarrer ou arreter le reseau, configurer
pascal@371 991 les interfaces reseau ou editer directement les fichiers."
pascal@371 992 </label>
pascal@371 993 </text>
pascal@371 994 </frame>
pascal@371 995 </vbox>
pascal@371 996 </window>
pascal@371 997 '
pascal@371 998
pascal@371 999 # Interface status with ifconfig without arguments to show all
pascal@371 1000 # active connections.
pascal@371 1001 #
pascal@371 1002 export IFCONFIG="
pascal@371 1003 <window title=\"Network status\" icon-name=\"network-wire\">
pascal@371 1004 <vbox>
pascal@371 1005 $(tab_status)
pascal@371 1006 <hbox>
pascal@371 1007 <button>
pascal@371 1008 <input file icon=\"gtk-close\"></input>
pascal@371 1009 <action type=\"closewindow\">IFCONFIG</action>
pascal@371 1010 </button>
pascal@371 1011 </hbox>
pascal@371 1012 </vbox>
pascal@371 1013 </window>"
pascal@371 1014
pascal@371 1015 # The main dialog with notebook, start/stop buttons and all options.
pascal@371 1016 # Note that /etc/network.conf is seded when an interface is activated.
pascal@371 1017 #
pascal@371 1018 head='
pascal@371 1019 <window title="SliTaz Netbox Manager" icon-name="network-wired">
pascal@371 1020 <vbox>
pascal@371 1021
pascal@371 1022 <hbox>
pascal@371 1023 <text use-markup="true">
jozee@461 1024 <label>"<b>Network Manager</b>"</label>
pascal@371 1025 </text>
pascal@371 1026 <pixmap>
pascal@371 1027 <input file>/usr/share/pixmaps/netbox.png</input>
pascal@371 1028 </pixmap>
pascal@371 1029 </hbox>
pascal@371 1030 '
pascal@371 1031 bottom='
pankso@297 1032 <hbox>
pankso@297 1033 <button>
pankso@297 1034 <label>Wireless manager</label>
pankso@297 1035 <input file icon="network-wireless"></input>
pankso@297 1036 <action>wifibox &</action>
pankso@297 1037 </button>
pankso@297 1038 <button>
pankso@297 1039 <label>Refresh list</label>
pankso@297 1040 <input file icon="reload"></input>
pankso@297 1041 <action>refresh:INTERFACE_LIST</action>
pankso@297 1042 </button>
pankso@297 1043 <button>
pankso@297 1044 <label>Full status</label>
pankso@297 1045 <input file icon="dialog-information"></input>
pankso@297 1046 <action type="launch">IFCONFIG</action>
pankso@297 1047 </button>
pankso@297 1048 <button help>
pankso@297 1049 <label>Help</label>
pankso@297 1050 <action type="launch">HELP</action>
pankso@297 1051 </button>
pankso@297 1052 <button>
pankso@297 1053 <label>Quit</label>
pankso@297 1054 <input file icon="exit"></input>
pankso@297 1055 <action type="exit">Exit</action>
pankso@297 1056 </button>
pankso@297 1057 </hbox>
pankso@194 1058
pankso@297 1059 </vbox>
pankso@38 1060 </window>
pankso@33 1061 '
pascal@371 1062
pascal@371 1063 NET_BOX="${head}$(tab_main)${bottom}"
pascal@126 1064
pascal@126 1065 export NET_BOX
pascal@126 1066
pascal@371 1067 # TODO: Modules(Network kernel modules)
pankso@33 1068
pankso@33 1069 # Only root can configure network.
pankso@33 1070 check_root
pankso@297 1071
pascal@177 1072 # Configure and connect if button Connect was pressed.
pascal@177 1073 if ! grep -qs ^name /etc/ppp/options ; then
pascal@177 1074 # Generate /etc/ppp/options
pascal@177 1075 cat > /etc/ppp/options << _EOT_
pascal@177 1076 plugin rp-pppoe.so
pascal@177 1077 name provider-ID
pascal@177 1078 noipdefault
pascal@177 1079 defaultroute
pascal@177 1080 mtu 1492
pascal@177 1081 mru 1492
pascal@177 1082 lock
pascal@177 1083 _EOT_
pascal@177 1084 # Generate /etc/ppp/pap-secrets
pascal@177 1085 cat > /etc/ppp/pap-secrets << _EOT_
pascal@177 1086 # Secrets for authentication using PAP
pascal@177 1087 # client server secret IP addresses
pascal@177 1088 _EOT_
pascal@177 1089 # Generate /etc/ppp/chap-secrets
pascal@177 1090 cat > /etc/ppp/chap-secrets << _EOT_
pascal@177 1091 # Secrets for authentication using CHAP
pascal@177 1092 # client server secret IP addresses
pascal@177 1093 _EOT_
pascal@177 1094 fi
pascal@259 1095 gtkdialog --center --program=NET_BOX | grep -a 'EXIT="restart"' && continue
pankso@33 1096 exit 0
pascal@259 1097 done