Uruchamianie sieci kablowych i wifi na laptopie


Poniżej został zamieszczony skrypt do uruchamianie sieci kablowych i wifi na laptopie. Jest napisany w cdialog i musi być uruchamiany z konta root.


#!/bin/sh
set -x
tempfile="/tmp/.tempfile"
a=0
b=0
backtitle="Skrypt do wyboru sieci w Slackware 12.1"
while [ "$a" = "0" ]; do
    dialog --backtitle "$backtitle" \
    --title "Sieci" \
    --menu "Wybierz pozycje do uruchomienia" 0 0 0 \
    Sala_73 "" \
    Sala_74 "" \
    Sala_109 "" \
    Dom_kabel "" \
    Dom_wifi "" 2> $tempfile
    a=$?
    b=`cat $tempfile`
    case $b in 
    Sala_73)
	touch /etc/rc.d/rc.inet1.conf
	chmod 660 /etc/rc.d/rc.inet1.conf
	echo "IPADDR[0]=10.1.73.30
	NETMASK[0]=255.0.0.0
	GATEWAY[0]=10.1.1.1">/etc/rc.d/rc.inet1.conf
	/etc/rc.d/rc.inet1 restart
	exit	
    ;;
    Sala_74)
	touch /etc/rc.d/rc.inet1.conf
	chmod 660 /etc/rc.d/rc.inet1.conf
	echo "IPADDR[0]=10.1.74.33
	NETMASK[0]=255.0.0.0
	GATEWAY[0]=10.1.1.1">/etc/rc.d/rc.inet1.conf
	/etc/rc.d/rc.inet1 restart
	exit
    ;;
    Sala_109)
	touch /etc/rc.d/rc.inet1.conf
	chmod 660 /etc/rc.d/rc.inet1.conf
	echo "IPADDR[0]=10.1.74.200
	NETMASK[0]=255.0.0.0
	GATEWAY[0]=10.1.1.1">/etc/rc.d/rc.inet1.conf
	/etc/rc.d/rc.inet1 restart
	exit	
    ;;
    Dom_kabel)
	touch /etc/rc.d/rc.inet1.conf
	chmod 660 /etc/rc.d/rc.inet1.conf
	echo "IPADDR[0]=10.0.0.2
	NETMASK[0]=255.255.255.0
	GATEWAY[0]=10.0.0.254">/etc/rc.d/rc.inet1.conf
	/etc/rc.d/rc.inet1 restart
	exit	
    ;;
    Dom_wifi)
	modprobe iwl3945
	touch /etc/rc.d/rc.inet1.conf
	chmod 660 /etc/rc.d/rc.inet1.conf
	echo "IFNAME[4]=wlan0
	IPADDR[4]=10.0.0.2
	NETMASK[4]=255.255.255.0
	GATEWAY[4]=10.0.0.254">/etc/rc.d/rc.inet1.conf
	/etc/rc.d/rc.inet1 restart
	wpa_supplicant -iwlan0 -Dwext -c/etc/wpa_supplicant.conf -Bw
	sleep 10
	wpa_cli -iwlan0 add network
	wpa_cli -iwlan0 enable_network 0
	route add default gw 10.0.0.254 dev wlan0 &
	sleep 3	
	exit
    ;;
    esac
done

rm -f $tempfile

do góry 2008.10.14