summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2009-02-16 11:09:06 +0100
committerJames Rayner <james@archlinux.org>2009-02-16 11:09:06 +0100
commit371cd06f36328ba0ddb75fe64102e8fc232a7fd3 (patch)
tree1584bb6d4eafe2cd2ee257d9c9b1d3ef1cc67a58 /src
parentcfcf836b94c5f3b520f0022942b1932c566eefdb (diff)
downloadnetctl-371cd06f36328ba0ddb75fe64102e8fc232a7fd3.tar.gz
netctl-371cd06f36328ba0ddb75fe64102e8fc232a7fd3.tar.xz
various fixes, and new quirk 'noacheck'
Diffstat (limited to 'src')
-rw-r--r--src/connections/ethernet12
-rw-r--r--src/connections/ethernet-iproute4
-rw-r--r--src/connections/wireless20
-rw-r--r--src/netcfg13
-rw-r--r--src/network2
5 files changed, 24 insertions, 27 deletions
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 12b9e49..042b32b 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -34,7 +34,7 @@ ethernet_up() {
if checkyesno "${DHCLIENT:-no}"; then
rm -r /var/run/dhclient-${INTERFACE}.pid >/dev/null 2>&1
if ! dhclient -q -e TIMEOUT="${DHCP_TIMEOUT:-10}" -pf /var/run/dhclient-${INTERFACE}.pid $INTERFACE; then
- err_append "DHCP IP lease attempt failed"
+ err_append "DHCP IP lease attempt failed."
return 1
fi
else
@@ -44,7 +44,7 @@ ethernet_up() {
[[ -n "$DNS1" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS"
# Start dhcpcd
if ! dhcpcd -qL -t "${DHCP_TIMEOUT:-10}" $DHCP_OPTIONS "$INTERFACE"; then
- err_append "DHCP IP lease attempt failed"
+ err_append "DHCP IP lease attempt failed."
return 1
fi
fi
@@ -52,20 +52,20 @@ ethernet_up() {
;;
static)
if ! ifconfig "$INTERFACE" $IFOPTS up; then
- err_append "could not bring interface up"
+ err_append "Bringing interface up failed."
return 1
fi
# bring up the default route (gateway)
if [[ -n "$GATEWAY" ]]; then
if ! route add default gw $GATEWAY; then
- err_append "adding gateway failed"
+ err_append "Adding gateway failed."
return 1
fi
fi
;;
*)
- err_append "IP must be either 'dhcp' or 'static'"
+ err_append "IP=\"\" must be either 'dhcp' or 'static'."
return 1
;;
esac
@@ -73,7 +73,7 @@ ethernet_up() {
# set the hostname
if [[ -n "$HOSTNAME" ]]; then
if ! hostname "$HOSTNAME"; then
- err_append "cannot set hostname"
+ err_append "Setting hostname failed."
return 1
fi
fi
diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute
index a491419..a960e1d 100644
--- a/src/connections/ethernet-iproute
+++ b/src/connections/ethernet-iproute
@@ -46,7 +46,6 @@ ethernet_up() {
if ! dhcpcd -qL -t ${DHCP_TIMEOUT:-10} $DHCP_OPTIONS $INTERFACE; then
error "DHCP IP lease attempt failed"
- return 1
fi
;;
static)
@@ -58,13 +57,11 @@ ethernet_up() {
if [[ -n "$GATEWAY" ]]; then
if ! ip route add default via $GATEWAY; then
error "Adding gateway failed"
- return 1
fi
fi
;;
*)
error "Profile error: IP must be either 'dhcp' or 'static'"
- return 1
;;
esac
@@ -81,7 +78,6 @@ ethernet_up() {
if [[ -n "$HOSTNAME" ]]; then
if ! hostname $HOSTNAME; then
error "Cannot set hostname"
- return 1
fi
fi
diff --git a/src/connections/wireless b/src/connections/wireless
index 04c5819..e8ff2e5 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -7,8 +7,9 @@ wireless_up() {
. ${SUBR_DIR}/wireless
+ if [[ ! -d /sys
if [[ ! -d /sys/class/net/$INTERFACE/wireless ]]; then
- err_append "Interface $INTERFACE is not a wireless interface"
+ err_append "$INTERFACE is not a valid wireless interface."
return 1
fi
@@ -30,7 +31,7 @@ wireless_up() {
[[ ! "$SCAN" ]] && SCAN="no"
if checkyesno $SCAN; then
if ! find_essid $INTERFACE "$ESSID"; then
- err_append "Network unavailable"
+ err_append "Network not present."
return 1
fi
fi
@@ -54,15 +55,20 @@ wireless_up() {
quirk "predown" && ifconfig $INTERFACE down
if ! eval iwconfig $INTERFACE $WEP_OPTS; then
- err_append "Could not set wireless configuration"
+ err_append "Could not set wireless configuration."
return 1
fi
quirk "postsleep" && sleep 1
quirk "postscan" && sleep 1 && iwlist $INTERFACE scan &>/dev/null
quirk "predown" && ifconfig $INTERFACE up
-
- wep_check $INTERFACE $TIMEOUT|| return 1
+
+ # Some devices appear to not associate until DHCP is run.
+ if quirk "noacheck"; then
+ sleep ${WIRELESS_TIMEOUT:-20}
+ else
+ wep_check $INTERFACE $TIMEOUT|| return 1
+ fi
;;
wpa)
. ${SUBR_DIR}/8021x
@@ -72,14 +78,14 @@ wireless_up() {
local WPA_CONF="/tmp/wpa.${1// /}" # substitute spaces out
echo "ctrl_interface=/var/run/wpa_supplicant" >> $WPA_CONF
- echo "ctrl_interface_group=0" >> $WPA_CONF
+ echo "ctrl_interface_group=wheel" >> $WPA_CONF
chmod 600 $WPA_CONF
# Generate configuration
if [[ "${#KEY}" == "64" ]]; then
echo -e 'network={ \nssid="$ESSID" \npsk=$KEY \n}'> $WPA_CONF
elif ! echo "$KEY" | wpa_passphrase "$ESSID" >> $WPA_CONF; then
- err_append "Configuration generation failed: `cat $WPA_CONF`"
+ err_append "Configuration generation failed. $(cat $WPA_CONF)"
return 1
fi
diff --git a/src/netcfg b/src/netcfg
index 86a4e9c..816c043 100644
--- a/src/netcfg
+++ b/src/netcfg
@@ -28,10 +28,7 @@ usage()
echo "-v, --version Output version information and exit"
}
-if [ "`id -u`" != "0" ]; then
- err "This script should be run as root."
- exit 1
-fi
+# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ
case $1 in
--version|-v)
@@ -42,10 +39,10 @@ case $1 in
CHECK="YES";
profile_up $2;;
clean)
- rm /var/run/network/interfaces/*
- rm /var/run/network/profiles/*
- killall wpa_supplicant
- killall dhcpcd
+ rm /var/run/network/interfaces/* 2> /dev/null
+ rm /var/run/network/profiles/* 2> /dev/null
+ killall wpa_supplicant 2> /dev/null
+ killall dhcpcd 2> /dev/null
;;
-d|down)
profile_down $2;;
diff --git a/src/network b/src/network
index 3766172..1011c9d 100644
--- a/src/network
+++ b/src/network
@@ -54,7 +54,6 @@ all_down()
for prof in find "$STATE_DIR/profiles" -maxdepth 1 -type f; do
profile_down $prof
done
- rm_daemon net-profiles
}
# all_suspend
@@ -127,7 +126,6 @@ profile_up()
set_profile up $1
unset EXCLUSIVE
- add_daemon net-profiles
stat_done
); return $?
}