summaryrefslogtreecommitdiffstats
path: root/rc.d/net-profiles
blob: 66f085187313ab077f31a7bb9c107c224092c749 (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
#!/bin/bash
#
# This script utilizes netcfg-daemon.

. /etc/rc.conf
. /etc/rc.d/functions
. /usr/lib/network/globals

case "$1" in
    start)
        if ! ck_daemon net-profiles; then
            exit_stderr "net-profiles has already been started.  Try '/etc/rc.d/net-profiles restart'"
        fi

        # Ensure any device renaming has occurred as intended
        for daemon in "${DAEMONS[@]}"; do
            if [[ "$daemon" = "net-rename" ]]; then
                if ck_daemon net-rename; then
                    /etc/rc.d/net-rename start
                fi
          fi
        done

        # $NET env var is passed from the kernel boot line
        if [[ "$NET" = "menu" ]]; then
            if /usr/bin/netcfg-menu; then
                mv "$STATE_DIR"/{menu,netcfg-daemon}        # JP: user may want to disconnect profile by calling net-profiles stop
                add_daemon net-profiles
                exit 0
            fi
        elif [[ -n "$NET" ]]; then
            if /usr/bin/netcfg check-iface "$NET"; then
                echo "$NET" > "$STATE_DIR/netcfg-daemon"        # JP: user may want to disconnect profile by calling net-profiles stop
                add_daemon net-profiles
                exit 0
            fi
        elif /usr/bin/netcfg-daemon start; then
            add_daemon net-profiles
        else
            exit_err "No profile started."
        fi
        ;;
    stop)
        if ck_daemon net-profiles; then
            exit_stderr "net-profiles is not running"
        fi
        /usr/bin/netcfg-daemon stop
        rm_daemon net-profiles
        ;;
    restart)
        "$0" stop
        sleep 1
        "$0" start
        ;;
    *)
        exit_stderr "Usage: $0 {start|stop|restart}"
esac

# vim: ft=sh ts=4 et sw=4: