summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2008-12-18 07:37:46 +0100
committerJames Rayner <james@archlinux.org>2008-12-18 07:37:46 +0100
commit5c2dc23703f1261b5b6eb0fd9906a2975e1c37ea (patch)
treea4e3ebcd2d40d824a8cabadda46c231704f6ac90
parent41197e24cfe9d2bf040d411e6c438aff516d943f (diff)
downloadnetctl-5c2dc23703f1261b5b6eb0fd9906a2975e1c37ea.tar.gz
netctl-5c2dc23703f1261b5b6eb0fd9906a2975e1c37ea.tar.xz
use arguments to scripts rather than sourcing in connection functions
-rw-r--r--Makefile2
-rw-r--r--src/connections/ethernet7
-rw-r--r--src/connections/ppp7
-rw-r--r--src/connections/wireless13
-rw-r--r--src/network5
5 files changed, 23 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 38a96e9..54eaa29 100644
--- a/Makefile
+++ b/Makefile
@@ -12,7 +12,7 @@ install:
install -m644 man/*.8 $(DESTDIR)/usr/man/man8
# Libs
install -m644 src/{network,wireless,8021x} $(DESTDIR)/usr/lib/network
- install -m644 src/connections/* ${DESTDIR}/usr/lib/network/connections
+ install -m755 src/connections/* ${DESTDIR}/usr/lib/network/connections
# 'Binaries'
install -m755 src/netcfg $(DESTDIR)/usr/bin/netcfg2
install -m755 src/netcfg-menu $(DESTDIR)/usr/bin/netcfg-menu
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 75976da..68561a8 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -1,7 +1,9 @@
#! /bin/bash
-
+. /usr/lib/network/network
ethernet_up() {
+ load_profile $1
+
if [[ ! -e /sys/class/net/$INTERFACE ]]; then
if ! echo "$INTERFACE"|grep ":"; then
err_append "Interface $INTERFACE does not exist"
@@ -97,6 +99,7 @@ ethernet_up() {
}
ethernet_down() {
+ load_profile $1
case $IP in
dhcp)
if checkyesno $DHCLIENT; then
@@ -119,4 +122,6 @@ ethernet_down() {
}
+ethernet_$1 $2
+exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/connections/ppp b/src/connections/ppp
index ecefd63..9432323 100644
--- a/src/connections/ppp
+++ b/src/connections/ppp
@@ -1,5 +1,9 @@
#! /bin/bash
+. /usr/lib/network/network
+
+
ppp_up() {
+ load_profile $1
[[ -z "$PEER" ]] && PEER="provider"
[[ -z "$PPP_TIMEOUT" ]] && PPP_TIMEOUT=30
@@ -12,7 +16,10 @@ ppp_up() {
}
ppp_down() {
+ load_profile $1
kill $(head -1 /var/run/ppp-$(basename $PEER).pid)
}
+ppp_$1 $2
+exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/connections/wireless b/src/connections/wireless
index bdf458a..04c5819 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -1,4 +1,5 @@
#! /bin/bash
+. /usr/lib/network/network
wireless_up() {
@@ -97,23 +98,23 @@ wireless_up() {
;;
esac
- . $CONN_DIR/ethernet
- if ! ethernet_up $1; then
+ if ! ${CONN_DIR}/ethernet up $1; then
wireless_down $1 YES
return 1
fi
}
wireless_down() {
+ load_profile $1
PROFILE=$1 NOETHERNETDOWN=$2
if ! checkyesno $2; then
- . $CONN_DIR/ethernet
- ethernet_down $1
- fi
+ ${CONN_DIR}/ethernet down $1
+ fi
wpa_cli terminate &> /dev/null
[[ "$SECURITY" == "wpa" ]] && rm -f "/tmp/wpa.${1// /}" # remove wpa config
iwconfig $INTERFACE essid off key off &> /dev/null
-
}
+wireless_$1 $2
+exit $?
# vim: set ts=4 et sw=4:
diff --git a/src/network b/src/network
index f99df53..a05ab2c 100644
--- a/src/network
+++ b/src/network
@@ -117,7 +117,7 @@ profile_up()
eval $PRE_UP || exit 1
- if ! ${CONN_DIR/${CONNECTION} up $1; then
+ if ! ${CONN_DIR}/${CONNECTION} up $1; then
stat_fail
exit 1
fi
@@ -156,8 +156,7 @@ profile_down()
eval $PRE_DOWN || exit 1
- . $CONN_DIR/${CONNECTION}
- if ! ${CONNECTION}_down $1; then
+ if ! ${CONN_DIR}/${CONNECTION} down $1; then
stat_fail
exit 1
fi