Wireless in Powerbook G4 part 2

Below is a small script to configure the network interfaces in the Powerbook. It will probably work in other Linux systems too, maybe some modifications would need to be made. wlan0 is the wireless interface and eth0 the broadband interface.


#!/bin/bash
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

echo "Checking whether NetworkManager is running"
if [ -f /var/run/NetworkManager.pid ]; then
        echo "NetworkManager is running, stopping it"
        /etc/init.d/network-manager stop
else
        echo "NetworkManager is not running"
fi

Interface() {
echo "Choose the name of the interface you want to configure"
echo "1 = Interface ethernet eth0"
echo "2 = Interface wireless wlan0"
echo "0 = Quit the program"
echo
read INT

if [ $INT = 1 ]; then
ETH=eth0

elif [ $INT = 2 ]; then
ETH=wlan0 
echo "Choose the essid you want to connect to"
iwlist $ETH scan | grep -i essid
read ESSID
iwconfig $ETH "$ESSID"

elif [ $INT = 0 ]; then
echo "Quitting"
exit 0
fi
}

Interface

Configure() {
echo
echo " 1 = static "
echo " 2 = dhcp "
echo " 0 to quit the program "
echo
read CHOICE

static() {
echo "Write the IP of the interface"
read IP
echo "Write the network mask"
read NETMASK
echo "Write the default gateway"
read ROUTE
echo "Configuraning the interface"
ifconfig $ETH $IP netmask $NETMASK
echo "Configuraning the gateway"
route add default gw $ROUTE
echo "search" > /etc/resolv.conf
echo "Write the IP of the first DNS server"
read DNS_1
echo nameserver $DNS_1 >> /etc/resolv.conf
echo "Write the IP of your second DNS server"
read DNS_2
echo nameserver $DNS_2 >> /etc/resolv.conf
} 

dhcp() {
        dhclient $ETH
        }

if [ $CHOICE = 1 ]; then
static

elif [ $CHOICE = 2 ]; then
dhcp

elif [ $CHOICE = 0 ]; then
echo "Quitting the program."
exit 0
fi
}

Configure

exit 0

Suggestions are always welcome. 🙂

Leave a Reply