summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-08-10 13:12:21 +0200
committerJames Rayner <james@archlinux.org>2009-08-10 13:12:21 +0200
commit2e0f6bf77d69334e44e890980a671b7c5b4f39b1 (patch)
tree7e9f4605874e404a448524b7eb3a8f3ee8bacbef
parent95b0fd57c0487cf6cb557fbc63de177099ca867c (diff)
downloadnetctl-2e0f6bf77d69334e44e890980a671b7c5b4f39b1.tar.gz
netctl-2e0f6bf77d69334e44e890980a671b7c5b4f39b1.tar.xz
allow interfaces to be marked as externally controlled
-rw-r--r--src/network42
1 files changed, 28 insertions, 14 deletions
diff --git a/src/network b/src/network
index ccf0893..07fb86c 100644
--- a/src/network
+++ b/src/network
@@ -88,16 +88,21 @@ profile_up()
report_try "$1 up"
- if check_iface $INTERFACE; then
- if checkyesno $CHECK; then
- err_append "Interface $INTERFACE already in use"
- report_fail && exit 1
- else
- interface_down $INTERFACE || exit 1
- load_profile $1
- fi
- fi
-
+ case $(check_iface $INTERFACE) in
+ up)
+ if checkyesno $CHECK; then
+ report_fail "Interface $INTERFACE already in use"
+ exit 1
+ else
+ interface_down $INTERFACE || exit 1
+ load_profile $1
+ fi
+ ;;
+ external)
+ report_fail "Interface $INTERFACE externally controlled"
+ exit 1
+ ;;
+ esac
eval $PRE_UP || exit 1
@@ -132,8 +137,7 @@ profile_down()
report_try "$1 down"
if [[ "$(get_iface_prof $INTERFACE)" == "external" ]]; then
- err_append "$interface was connected by another application"
- report_fail
+ report_fail "$interface was connected by another application"
exit 1
fi
@@ -187,8 +191,18 @@ interface_down()
# Return 1 if interface down
#
check_iface() {
- [[ -f $STATE_DIR/interfaces/$1 ]] && return 0
- return 1
+ if [[ -f $STATE_DIR/interfaces/$1 ]]; then (
+ . $STATE_DIR/interfaces/$1
+ if [[ $PROFILE -eq external ]]; then
+ echo "external"
+ else
+ echo "up"
+ fi
+ return 0
+ )
+ else
+ return 1
+ fi
}
# get_iface_prof interface