summaryrefslogtreecommitdiffstats
path: root/src/network
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-08-10 12:09:14 +0200
committerJames Rayner <james@archlinux.org>2009-08-10 12:09:14 +0200
commit74fe64cec00d359ce98938754e9cb1b0c96e49a8 (patch)
treedb0567b6b4985d3fa92b529ea6a6f48f6cc4ba03 /src/network
parent65c7253e9f27421e61c0764dcf8843797611db00 (diff)
downloadnetctl-74fe64cec00d359ce98938754e9cb1b0c96e49a8.tar.gz
netctl-74fe64cec00d359ce98938754e9cb1b0c96e49a8.tar.xz
merge logging code from Jim Pryor
Diffstat (limited to 'src/network')
-rw-r--r--src/network43
1 files changed, 14 insertions, 29 deletions
diff --git a/src/network b/src/network
index b45caaa..1e37633 100644
--- a/src/network
+++ b/src/network
@@ -1,20 +1,5 @@
### Globals
-PROFILE_DIR="/etc/network.d/"
-SUBR_DIR="/usr/lib/network/"
-CONN_DIR="${SUBR_DIR}/connections/"
-STATE_DIR="/var/run/network/"
-
-### Messages
-##
-# err msg
-# output specified message
-err_append() {
- echo " - $*"
-}
-
-err() {
- printhl "$*"
-}
+. /usr/lib/network/globals
### Profile loading
##
@@ -30,16 +15,16 @@ validate_profile()
{
[[ -z "$1" ]] && return 1
if [[ ! -f $PROFILE_DIR/$1 ]]; then
- err "Profile \"$1\" does not exist"
+ report_fail "Profile \"$1\" does not exist"
return 1
fi
. $PROFILE_DIR/$1
if [[ -z "$INTERFACE" ]]; then
- err "Profile missing an interface to configure"
+ report_fail "Profile missing an interface to configure"
return 1
fi
if [[ ! -f $CONN_DIR/$CONNECTION ]]; then
- err "$CONNECTION is not a valid connection, check spelling or look at examples"
+ report_fail "$CONNECTION is not a valid connection, check spelling or look at examples"
return 1
fi
}
@@ -93,7 +78,7 @@ profile_up()
load_profile $1 || exit 1
- check_profile $1 && err "$1 already connected" && exit 1
+ check_profile $1 && report_fail "$1 already connected" && exit 1
# NETWORKS_EXCLUSIVE, rc.conf: Profiles are globally mutually exclusive
# EXCLUSIVE, network.d/profile: Individual profile is mutually exclusive
@@ -101,12 +86,12 @@ profile_up()
all_down
fi
- stat_busy "$1 up"
+ report_try "$1 up"
if check_iface $INTERFACE; then
if checkyesno $CHECK; then
err_append "Interface $INTERFACE already in use"
- stat_fail && exit 1
+ report_fail && exit 1
else
interface_down $INTERFACE || exit 1
load_profile $1
@@ -117,7 +102,7 @@ profile_up()
eval $PRE_UP || exit 1
if ! ${CONN_DIR}/${CONNECTION} up $1; then
- stat_fail
+ report_fail
exit 1
fi
@@ -126,7 +111,7 @@ profile_up()
set_profile up $1
unset EXCLUSIVE
- stat_done
+ report_success
); return $?
}
@@ -141,28 +126,28 @@ profile_down()
load_profile $1 || exit 1
if ! check_profile $1; then
- err "Profile not connected"
+ report_fail "Profile not connected"
exit 1
fi
- stat_busy "$1 down"
+ report_try "$1 down"
if [[ "$(get_iface_prof $INTERFACE)" == "external" ]]; then
err_append "$interface was connected by another application"
- stat_fail
+ report_fail
exit 1
fi
eval $PRE_DOWN || exit 1
if ! ${CONN_DIR}/${CONNECTION} down $1; then
- stat_fail
+ report_fail
exit 1
fi
eval $POST_DOWN || exit 1
set_profile down $1
- stat_done
+ report_success
); return $?
}