#!/bin/bash # --- T2-COPYRIGHT-BEGIN --- # t2/package/*/rocknet/rocknet-getprofile # Copyright (C) 2005 - 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 # --- T2-COPYRIGHT-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