summaryrefslogtreecommitdiffstats
path: root/contrib/net-auto
blob: add67112b4ab55f259441b2a885d06f1d275aa04 (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
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions

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

        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
        ;;
    stop)
        /usr/bin/netcfg2 -a
        rm_daemon net-auto
        ;;
    restart)
        $0 stop; sleep 1; $0 start
        ;;
    *)
        echo "usage: $0 {start|stop|restart}"  
esac

# vim: set ts=4 et sw=4: