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.

71 lines
1.9 KiB

  1. #!/bin/sh
  2. # --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. #
  5. # Filename: package/.../rocknet/ifup.sh
  6. # Copyright (C) 2008 The OpenSDE Project
  7. # Copyright (C) 2004 - 2006 The T2 SDE Project
  8. #
  9. # More information can be found in the files COPYING and README.
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; version 2 of the License. A copy of the
  14. # GNU General Public License can be found in the file COPYING.
  15. # --- SDE-COPYRIGHT-NOTE-END ---
  16. rocknet_tmp_base="/var/run/rocknet"
  17. [ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
  18. var_contains() {
  19. local tmp
  20. eval "tmp=\"\$$1\""
  21. [ "${tmp/$3$2/}" != "$tmp" ]
  22. }
  23. usage() {
  24. echo "Usage: $0 interface [ profile ] [ -force ]"
  25. exit 1
  26. }
  27. force=0
  28. if="$1" ; shift ; [ "$if" ] || usage
  29. profile=
  30. action="${0/#*\/if}"
  31. while [ "$1" ] ; do
  32. case $1 in
  33. -force) force=1 ;;
  34. *) [ "$profile" = "" ] && profile="$1" || usage ;;
  35. esac
  36. shift
  37. done
  38. [ "$profile" ] || profile="`cat /etc/conf/network-profile 2> /dev/null`"
  39. profile=${profile:-default}
  40. # sanity checks (...)
  41. if [ $force -eq 0 ] ; then
  42. active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
  43. if test $action = "up" && var_contains active_interfaces ',' "$if($profile)"
  44. then
  45. echo "Interface $if($profile) is already listed active, it is probably a good idea to"
  46. echo "take it down before activating it. Use -force to suppress this warning."
  47. exit 2
  48. fi
  49. if test $action = "down" && ! var_contains active_interfaces ',' "$if($profile)"
  50. then
  51. echo "Interface $if($profile) is not listed active, it is probably a good idea to"
  52. echo "activate it before deactivating it. Use -force to suppress this warning."
  53. exit 2
  54. fi
  55. fi
  56. /sbin/rocknet "$profile" "$if" "$action"
  57. echo "$profile" > /etc/conf/network-profile