OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

  1. #!/bin/bash
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../rocknet/rocknet-getprofile
  6. # Copyright (C) 2005 - 2006 The T2 SDE Project
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- SDE-COPYRIGHT-NOTE-END ---
  15. #
  16. # Example for ROCKNET profile auto-detection.
  17. # on default do nothing
  18. exit 0
  19. # location of profile file
  20. profile_file=/etc/conf/network-profile
  21. echo -n "Trying to auto-detect network profile .. "
  22. echo default > $profile_file
  23. # we need to activate the interfaces for the test
  24. ip link set eth0 up &> /dev/null
  25. ip link set eth1 up &> /dev/null
  26. # use arping to check for a well-known IPs
  27. (
  28. if arping -0 -i eth0 -c3 10.0.23.42; then
  29. echo foo > $profile_file
  30. fi
  31. ) &> /dev/null &
  32. # maybe we have found that essid
  33. (
  34. sleep 2 # give it some time to get the essid
  35. if iwlist eth1 scan | grep -q 'ESSID:"MyWLAN"'; then
  36. echo bar > $profile_file
  37. fi
  38. ) &> /dev/null &
  39. # wait for all childs to finish, output found profile
  40. wait; cat $profile_file
  41. # deactivate the interfaces, the profile might activate them again
  42. ip link set eth0 down &> /dev/null
  43. ip link set eth1 down &> /dev/null