blob: 98bb91dca6d6861908c0a49da573c7a449cbf217 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
#!/bin/bash
. /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#!}" && "$daemon" = net-rename ]]; then
if ck_daemon net-rename; then
/etc/rc.d/net-rename start
fi
fi
done
# TODO: check if any way of using 'stacks' in bash
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)
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
;;
*)
exit_stderr "Usage: $0 {start|stop|restart}"
esac
# vim: set ts=4 et sw=4:
|