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.

70 lines
1.9 KiB

  1. #!/bin/sh
  2. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # T2 SDE: package/.../rocknet/ifup.sh
  6. # Copyright (C) 2004 - 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. # --- T2-COPYRIGHT-NOTE-END ---
  15. rocknet_tmp_base="/var/run/rocknet"
  16. [ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
  17. var_contains() {
  18. local tmp
  19. eval "tmp=\"\$$1\""
  20. [ "${tmp/$3$2/}" != "$tmp" ]
  21. }
  22. usage() {
  23. echo "Usage: $0 interface [ profile ] [ -force ]"
  24. exit 1
  25. }
  26. force=0
  27. if="$1" ; shift ; [ "$if" ] || usage
  28. profile=""
  29. action="${0/#*\/if}"
  30. while [ "$1" ] ; do
  31. case $1 in
  32. -force) force=1 ;;
  33. *) [ "$profile" = "" ] && profile="$1" || usage ;;
  34. esac
  35. shift
  36. done
  37. [ "$profile" ] || profile="`cat /etc/conf/network-profile 2> /dev/null`"
  38. profile=${profile:-default}
  39. # sanity checks (...)
  40. if [ $force -eq 0 ] ; then
  41. active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
  42. if test $action = "up" && var_contains active_interfaces ',' "$if($profile)"
  43. then
  44. echo "Interface $if($profile) is already listed active, it is probably a good idea to"
  45. echo "take it down before activating it. Use -force to suppress this warning."
  46. exit 2
  47. fi
  48. if test $action = "down" && ! var_contains active_interfaces ',' "$if($profile)"
  49. then
  50. echo "Interface $if($profile) is not listed active, it is probably a good idea to"
  51. echo "activate it before deactivating it. Use -force to suppress this warning."
  52. exit 2
  53. fi
  54. fi
  55. /sbin/rocknet "$profile" "$if" "$action"
  56. echo "$profile" > /etc/conf/network-profile