summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xsrc-wireless/net-auto28
-rwxr-xr-xsrc-wireless/netcfg-auto-wireless4
-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
7 files changed, 39 insertions, 44 deletions
diff --git a/src-wireless/net-auto b/src-wireless/net-auto
index add6711..a4f68b2 100755
--- a/src-wireless/net-auto
+++ b/src-wireless/net-auto
@@ -14,23 +14,21 @@ case "$1" in
fi
done
- for network in ${AUTO_NETWORKS[@]}; do
- case $network in
- auto-*) # Automatic configuration, store type and get interface next
- auto=$network
- ;;
- *) # Either interface or profile
- if [[ "$auto" ]]; then # Auto set, so interface
- /usr/bin/netcfg-$auto $network
- unset auto
- fi
- esac
- done
-
- add_daemon net-auto
+ # TODO: check if any way of using 'stacks' in bash
+ for iface in ${AUTO_NETWORKS[@]}; do
+ if [[ "${iface:0:4}" = "auto" ]]; then
+ auto=$iface
+ elif [[ "$auto" ]]; then
+ /usr/bin/netcfg-$auto $iface
+ [[ $? -eq 0 ]] && echo $iface >> /var/run/daemons/net-auto
+ unset auto
+ fi
+ done
;;
stop)
- /usr/bin/netcfg2 -a
+ for iface in $(cat /var/run/daemons/net-auto); do
+ netcfg interface-down $iface
+ done
rm_daemon net-auto
;;
restart)
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless
index e5e4fc1..a523bdd 100755
--- a/src-wireless/netcfg-auto-wireless
+++ b/src-wireless/netcfg-auto-wireless
@@ -11,7 +11,7 @@
# $1 - wireless interface
wifi_auto()
{
- interface=$1; RETRIES=6
+ interface=$1;
stat_busy "Scanning for networks"
ifconfig $interface up
@@ -37,7 +37,7 @@ wifi_auto()
done < $networks
if [[ "$found" ]]; then
- netcfg2 $found
+ netcfg $found
exit $?
fi
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 $?
}