mirror of the now-defunct rocklinux.org
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.

57 lines
1.3 KiB

  1. #!/bin/sh
  2. rocknet_tmp_base="/var/run/rocknet"
  3. [ -d $rocknet_tmp_base ] || mkdir -p $rocknet_tmp_base
  4. var_contains() {
  5. local tmp
  6. eval "tmp=\"\$$1\""
  7. [ "${tmp/$3$2/}" != "$tmp" ]
  8. }
  9. usage() {
  10. echo "Usage: $0 interface [ profile ] [ -force ]"
  11. exit 1
  12. }
  13. force=0
  14. if="$1" ; shift ; [ "$if" ] || usage
  15. profile=""
  16. action="${0/#*\/if}"
  17. while [ "$1" ] ; do
  18. case $1 in
  19. -force) force=1 ;;
  20. *) [ "$profile" = "" ] && profile="$1" || usage ;;
  21. esac
  22. shift
  23. done
  24. [ "$profile" ] || profile="`cat /etc/network/profile 2> /dev/null`"
  25. profile=${profile:-default}
  26. # sanity checks (...)
  27. if [ $force -eq 0 ] ; then
  28. active_interfaces="`cat $rocknet_tmp_base/active-interfaces 2>/dev/null`"
  29. if test $action = "up" && var_contains active_interfaces ',' "$if($profile)"
  30. then
  31. echo "Interface $if($profile) is already listed active, it is probably a good idea to"
  32. echo "take it down before activating it. Use -force to suppress this warning."
  33. exit 2
  34. fi
  35. if test $action = "down" && ! var_contains active_interfaces ',' "$if($profile)"
  36. then
  37. echo "Interface $if($profile) is not listed active, it is probably a good idea to"
  38. echo "activate it before deactivating it. Use -force to suppress this warning."
  39. exit 2
  40. fi
  41. fi
  42. /etc/network/rocknet "$profile" "$if" "$action"
  43. echo "$profile" > /etc/network/profile