summaryrefslogtreecommitdiffstats
path: root/src-wireless/net-auto
blob: 3f74ffc384988b7f253ce529d22215da9f15efb7 (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
#!/bin/bash

. /usr/lib/network/globals

case "$1" in
    start)
        # Ensure any device renaming has occurred as intended
        for daemon in "${DAEMONS[@]}"; do
            if [ "$daemon" = "${daemon#!}" -a "$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
        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)
        [[ ! -e /var/run/daemons/net-auto ]] && exit 0
        for iface in $(cat /var/run/daemons/net-auto); do
            netcfg iface-down $iface
        done
        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: