auto.action 847 Bytes
Newer Older
James Rayner's avatar
James Rayner committed
1
2
#! /bin/bash

3
. /usr/lib/netctl/globals
4
5
. "$SUBR_DIR/ip"

6
export INTERFACE="$1"
7
8
export ACTION="$2"
PROFILE_FILE="$STATE_DIR/netctl-auto-$INTERFACE.profile"
James Rayner's avatar
James Rayner committed
9

10
case $ACTION in
11
12
  CONNECTED)
    load_profile "$WPA_ID_STR"
13
    DhcpcdOptions+=" -K -L"
14
    ip_set || exit 1
15
16
    mkdir -p "$(dirname "$PROFILE_FILE")"
    printf '%s' "$Profile" > "$PROFILE_FILE"
Jouke Witteveen's avatar
Jouke Witteveen committed
17
    # Sandbox the eval
18
    if ! ( do_debug eval "$ExecUpPost" ); then
19
        # Failing ExecUpPost will take the connection down
20
        netctl-auto stop "$INTERFACE"
James Rayner's avatar
James Rayner committed
21
        exit 1
22
    fi
Jouke Witteveen's avatar
Jouke Witteveen committed
23
  ;;
24
25
26
27
28
29
30
31
32
  DISCONNECTED)
    if [[ -s "$PROFILE_FILE" ]]; then
        load_profile "$(< "$PROFILE_FILE")"
        rm -f "$PROFILE_FILE"
        # Sandbox the eval
        if ! ( do_debug eval "$ExecDownPre" ); then
            exit 1
        fi
        ip_unset
33
    fi
Jouke Witteveen's avatar
Jouke Witteveen committed
34
  ;;
James Rayner's avatar
James Rayner committed
35
36
esac

37
38

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