summaryrefslogtreecommitdiffstats
path: root/src/lib/auto.action
blob: feebd77270b95b3a1482b93497e398c9aa98a1d4 (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
#! /bin/bash

. /usr/lib/network/globals
. "$SUBR_DIR/ip"

interface="$1"
ssid="$2"
profile="$3"
action="$4"

# Is it possible that we don't get a profile?!
[[ "$profile" ]] && load_profile "$profile"

case $action in
  CONNECT)
    if [[ -z $profile ]]; then
        if [[ -x "$PROFILE_DIR/interfaces/$interface" ]]; then
            source "$PROFILE_DIR/interfaces/$interface"
        fi
        dhcpcd -qL -t "${TimeoutDHCP:-10}" $DhcpcdOptions -K "$interface"
        exit $?
    fi
    DhcpcdOptions+=" -K"
    ip_set || exit 1
    # JP: sandbox the eval
    if ! ( eval $ExecUpPost ); then
        # Failing ExecUpPost will take the connection down
        netctl-auto stop "$interface"
        exit 1
    fi
  ;;
  DISCONNECT)
    if [[ -z $profile ]]; then
        dhcpcd -k "$interface"
        exit $?
    fi
    # JP: sandbox the eval
    if ! ( eval $ExecDownPre ); then
        exit 1
    fi
    ip_unset
  ;;
  LOST|REESTABLISHED)
    # Not handled.
    exit 0
  ;;
  *)
    # ???
    exit 1
  ;;
esac


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