#!/bin/bash # # Example for ROCKNET profile auto-detection. # on default do nothing exit 0 echo -n "Trying to auto-detect network profile .. " echo default > /etc/network/profile # we need to activate the interfaces for the test ip l set eth0 up &> /dev/null ip l set eth1 up &> /dev/null # use arping to check for a well-known IPs ( if arping -i eth0 -c3 10.0.23.42; then echo foo > /etc/network/profile fi ) &> /dev/null & # maybe we have found that essid ( sleep 2 # give it some time to get the essid if iwlist eth1 scan | grep -q 'ESSID:"MyWLAN"'; then echo bar > /etc/network/profile fi ) &> /dev/null & # wait for all childs to finish, output found profile wait; cat /etc/network/profile # deactivate the interfaces, the profile might activate them again ip l set eth0 down &> /dev/null ip l set eth1 down &> /dev/null