PDA

View Full Version : Dual Mode Wan + Lan AZboz HD Script



AJR
05-04-2009, 11:30 AM
With grateful thanks once again to elgeneral for this script by Kameleon74
Translation by Google

DualMode -**** LAN + WLAN

lan_script.sh

#! /bin/sh
export LD_LIBRARY_PATH=/MMP/lib:/MMP/usr/lib
export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/MMP/bin:/MMP/sbin:/MMP/usr/bin:/MMP/usr
/sbin

[ -z "$ACTION" ] && echo "Error: should be called from lan_steup" && exit 1

RESOLV_CONF="/etc/resolv.conf"
IF_0="eth0"
IF_1="ra0"

################################# #####################
### start
################################# #####################
if [ "$ACTION" = "init" ]; then
echo "NET_SCRIPT**** load wireless driver rt61!!!"
killall -9 udh***
insmod /MMP/modules/2.6.15/rt61.ko
ifconfig $IF_0 up
ifconfig $IF_1 up
fi
################################# #####################
### start
################################# #####################
if [ "$ACTION" = "start" ]; then
### MODE: 0=cable
if [ "$MODE" = "0" ]; then
echo "NET_SCRIPT**** ethernet cable setting..."
ifconfig $IF_0 0.0.0.0 &
sleep 1
[ ! -z "`/bin/pidof ifconfig`" ] && /usr/bin/killall -9 ifconfig
ifconfig $IF_1 down
ifconfig $IF_0 up
### IP_DHCP_MODE: 0=dhcp
if [ "$IP_DHCP_MODE" = "0" ]; then
echo "NET_SCRIPT**** ethernet dhcp mode!!!"
fi
### IP_DHCP_MODE: 1=static
if [ "$IP_DHCP_MODE" = "1" ]; then
ifconfig $IF_0 $IP_ADDR netmask $IP_SUBNET_MASK &
sleep 2
if [ ! -z "`/bin/pidof ifconfig`" ] ; then
/usr/bin/killall -9 ifconfig
ifconfig $IF_0 $IP_ADDR netmask $IP_SUBNET_MASK &
sleep 2
fi
if [ -n "$IP_GATEWAY" ] ; then
while route del default gw 0.0.0.0 dev $IF_0 ; do
:
done
for i in $IP_GATEWAY ; do
route add default gw $i dev $IF_0
done
fi
echo -n > $RESOLV_CONF
[ -n "$HOST_DOMAIN" ] && echo search $HOST_DOMAIN **** $RESOLV_CONF
[ -n "$DNS_IP_ADDR1" ] && echo nameserver $DNS_IP_ADDR1 **** $RESOLV_CONF
[ -n "$DNS_IP_ADDR2" ] && echo nameserver $DNS_IP_ADDR2 **** $RESOLV_CONF
fi
echo "NET_SCRIPT**** ethernet cable OK!!!"
fi
### MODE: 1=wireless
if [ "$MODE" = "1" ]; then
echo "NET_SCRIPT**** wireless setting..."
insmod /MMP/modules/2.6.15/rt61.ko

ifconfig $IF_0 0.0.0.0 &
sleep 1
[ ! -z "`/bin/pidof ifconfig`" ] && /usr/bin/killall -9 ifconfig
ifconfig $IF_1 up
iwconfig $IF_1 mode Managed
[ -n "$HOSTNAME" ] && iwconfig $IF_1 nick $HOSTNAME
iwconfig $IF_1 channel auto
iwconfig $IF_1 rate auto
iwpriv $IF_1 set NetworkType=Infra
if [ "$WLAN_ENCYPTION" != "0" ] && [ -n "$WLAN_KEY" ]; then
iwpriv $IF_1 set AuthMode=WPA2PSK
iwpriv $IF_1 set EncrypType=TKIP
iwpriv $IF_1 set WPAPSK="$WLAN_KEY"
else
iwpriv $IF_1 set AuthMode=OPEN
iwpriv $IF_1 set EncrypType=NONE
fi
iwpriv $IF_1 set SSID="$WLAN_ESSID"

iwgetid -m $IF_1
iwgetid -a $IF_1
iwgetid -c $IF_1
iwgetid -f $IF_1
iwgetid -p $IF_1
iwgetid -r $IF_1

### IP_DHCP_MODE: 0=dhcp
if [ "$IP_DHCP_MODE" = "0" ]; then
echo "NET_SCRIPT**** wireless dhcp mode!!!"
fi
### IP_DHCP_MODE: 1=static
if [ "$IP_DHCP_MODE" = "1" ]; then
ifconfig $IF_1 $IP_ADDR netmask $IP_SUBNET_MASK &
sleep 2
if [ ! -z "`/bin/pidof ifconfig`" ] ; then
/usr/bin/killall -9 ifconfig
ifconfig $IF_1 $IP_ADDR netmask $IP_SUBNET_MASK &
sleep 2
fi
if [ -n "$IP_GATEWAY" ] ; then
while route del default gw 0.0.0.0 dev $IF_1 ; do
:
done
for i in $IP_GATEWAY ; do
route add default gw $i dev $IF_1
done
fi
echo -n > $RESOLV_CONF
[ -n "$HOST_DOMAIN" ] && echo search $HOST_DOMAIN **** $RESOLV_CONF
[ -n "$DNS_IP_ADDR1" ] && echo nameserver $DNS_IP_ADDR1 **** $RESOLV_CONF
[ -n "$DNS_IP_ADDR2" ] && echo nameserver $DNS_IP_ADDR2 **** $RESOLV_CONF
fi
echo "NET_SCRIPT**** wireless OK!!!"

echo "NET_SCRIPT**** ethernet cable setting..."
ifconfig $IF_0 0.0.0.0 &
sleep 1
[ ! -z "`/bin/pidof ifconfig`" ] && /usr/bin/killall -9 ifconfig
ifconfig $IF_0 up
ifconfig $IF_0 192.168.2.3 netmask 255.255.255.0 &
sleep 2
if [ ! -z "`/bin/pidof ifconfig`" ] ; then
/usr/bin/killall -9 ifconfig
ifconfig $IF_1 192.168.2.3 netmask 255.255.255.0 &
sleep 2
fi

echo "NET_SCRIPT**** ethernet cable OK!!!"
fi


fi
################################# #####################
### alive
################################# #####################
if [ "$ACTION" = "alive" ]; then
rdate -s time.bora.net &
fi
################################# #####################
exit 0

via telnet:

mount-o remount, rw-t ext3 / dev/hda1 / SMP ...... ********** See corrected line in next post

and at the end via FTP script created above to / MMP / usr / bin (replace existing lan_script.sh - for safety initially back up original script)

Azbox restart.

And when network settings, normally set up for wifi with WEP 128bit.

Azbox Settings -> Wireless

(WPA or WPA2) in red script editing worth

for EPA WPAPSK
for WPA2 WPA2PSK

IP for LAN party. In this case is 192.168.2.3


by Kameleon74

AJR
05-04-2009, 07:26 PM
It seems that the syntax of


mount-o remount, rw-t ext3 / dev/hda1 / SMP

is not correct, but the correct line is

mount -o remount,rw -t ext3 /dev/hda1 /MMP

with thanks to tinos for the correction.

elgeneral
16-04-2009, 09:23 AM
Dual-Mode WLAN+LAN ab. 0.9.1759

per telnet :

mount -o remount,rw -t ext3 /dev/hda1 /MMP

dann per FTP lan_script nach /MMP/usr/bin kopieren (vorhandene lan_script.sh ersetzen - fuer sicherheits vorerst originale Script sichern)

Azbox neu starten.

Dual-Mode ist active bei Azbox Einstellungen -> Wireless

PS. IP fuer LAN ist Fest. In diese fall ist 192.168.2.3

Tarzan
16-04-2009, 12:17 PM
What is this script for?

AJR
16-04-2009, 02:05 PM
I believe that is so you can have lan (wired connection) and wan (wireless connection) running at the same time with 2 different ip addresses for the azbox.