Netzwerk Auto-Konfiguration
# Scriptname: network-discovery
# Intention: Try to find some kind of network connection providing a link to
# the internet. For this a list of wired interfaces is checked first.
# Afterwards a list of wireless devices is checked whereas a list of
# provided ESSIDs is prefered for the connection.
# Optionally the script also tries to connect to whatever ESSID it can find
# to get a connection (-> ESSID 'any' ).
#############
# changelog #
#############
# Version: 0.1 (3.11.2007)
# 0.2 (5.11.2007)
# - added several sleeps
# - implemented 5 retries to get the interface up with $IFCONFIG $IF up
# - added a complete shutdown of all involved network interfaces at startup
# to get a clean start
# 0.3 (13.11.2007)
# - cut back the number of retries to 3 to shorten the waiting time
# - added wrapper funktions 'error' and 'verbose'
# - made output more compact
# - added nice stuff for passing options to the script
# - verbose (-v), usage (-h) and precheck_for_internet_connection (-p) switches
# - availability check + global variables holding absolute paths for all needed
# external tools
# - discovery of hidden ESSIDs now possible by setting the ESSID before the scan
# - added hack for wpa support
# 0.3.1 (19.09.2008)
# - removed 'sleep 1' from the search loop to speed things up
# - changed order from 'wired, wireless' to 'wireless, wired' to speed things up
# - changed delimitter (IFS) from ' ' to ':'. Now ESSIDs with spaces are also no problem
#####################
# open improvements #
#####################
# FIXME Log error/status messages via syslog --> logger
# FIXME Trying DHCP on a network without DHCP takes an awfully long time until it aborts
# FIXME Think of something better to test network connectivity
# FIXME Add generic VPN support
# FIXME Add generic wpa support
# FIXME check if the tun module is loaded when using VPN
# FIXME Add static configuration support
# FIXME Check output of dhclient for what really happened
# success + received ip:
# DHCPACK from 192.168.0.2
# bound to 192.168.0.245 -- renewal in 1636 seconds.
# no success:
# No DHCPOFFERS received.
# FIXME dhclient processes stay in background after trying to get an ip
# unsuccessfully (-> quick solution: $KILLALL at the end of the file)