summaryrefslogtreecommitdiffstats
path: root/src-wireless/net-auto
diff options
context:
space:
mode:
Diffstat (limited to 'src-wireless/net-auto')
-rw-r--r--[-rwxr-xr-x]src-wireless/net-auto43
1 files changed, 31 insertions, 12 deletions
diff --git a/src-wireless/net-auto b/src-wireless/net-auto
index 8b724a5..98bb91d 100755..100644
--- a/src-wireless/net-auto
+++ b/src-wireless/net-auto
@@ -2,12 +2,16 @@
. /etc/rc.conf
. /etc/rc.d/functions
+. /usr/lib/network/globals
case "$1" in
start)
+ if ! ck_daemon net-auto; then # JP: check if it's already running
+ exit_stderr "net-auto has already been started: try \"/etc/rc.d/net-auto restart\""
+ fi
# Ensure any device renaming has occurred as intended
for daemon in "${DAEMONS[@]}"; do
- if [ "$daemon" = "${daemon#!}" -a "$daemon" = "net-rename" ]; then
+ if [[ "$daemon" = "${daemon#!}" && "$daemon" = net-rename ]]; then
if ck_daemon net-rename; then
/etc/rc.d/net-rename start
fi
@@ -15,28 +19,43 @@ case "$1" in
done
# 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
+
+ rm -f "$STATE_DIR/net-auto"
+ for iface in "${AUTO_NETWORKS[@]}"; do
+ if [[ "${iface:0:4}" = auto ]]; then
+ auto="$iface"
+ elif [[ -n "$auto" ]]; then
+ if /usr/bin/netcfg-"$auto" "$iface"; then
+ echo "$iface" >> "$STATE_DIR/net-auto"
+ add_daemon net-auto # JP: was this forgotten?
+ fi
unset auto
+ else
+ true # JP: can AUTO_NETWORKS contain elements other than ...auto-CONNECTION INTERFACE...?
+ # JP: for example, what do we do with AUTO_NETWORKS=(auto-wireless wlan0 eth0)?
+ # JP: or with AUTO_NETWORKS=(eth0 auto-wireless wlan0)?
fi
done
;;
stop)
- [[ ! -e /var/run/daemons/net-auto ]] && exit 0
- for iface in $(cat /var/run/daemons/net-auto); do
- netcfg iface-down $iface
+ if ck_daemon net-auto; then
+ exit_stderr "net-auto not running"
+ fi
+
+ for iface in $(cat "$STATE_DIR/net-auto"); do # JP: note that we may have written "wlan0 wlan1" to net-auto
+ # e.g. if the user did AUTO_NETWORKS=(auto-wireless "wlan0 wlan1")
+ # and now we're unpacking and handling wlan0, wlan1 one by one
+ # that's not necessarily a problem...I'm just calling attention to it
+ /usr/bin/netcfg iface-down "$iface"
done
+ rm -f "$STATE_DIR/net-auto"
rm_daemon net-auto
;;
restart)
- $0 stop; sleep 1; $0 start
+ "$0" stop; sleep 1; "$0" start
;;
*)
- echo "usage: $0 {start|stop|restart}"
+ exit_stderr "Usage: $0 {start|stop|restart}"
esac
# vim: set ts=4 et sw=4: