#!/bin/bash # --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: package/*/rocknet/rocknet-getprofile # Copyright (C) 2005 - 2022 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2. # --- T2-COPYRIGHT-NOTE-END --- # # Example for ROCKNET profile auto-detection. # on default do nothing exit 0 # location of profile file profile_file=/etc/conf/network-profile echo -n "Trying to auto-detect network profile .. " echo default > $profile_file # we need to activate the interfaces for the test ip link set eth0 up &> /dev/null ip link set eth1 up &> /dev/null # use arping to check for a well-known IPs ( if arping -0 -i eth0 -c3 10.0.23.42; then echo foo > $profile_file 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 > $profile_file fi ) &> /dev/null & # wait for all childs to finish, output found profile wait; cat $profile_file # deactivate the interfaces, the profile might activate them again ip link set eth0 down &> /dev/null ip link set eth1 down &> /dev/null