summaryrefslogtreecommitdiffstats
path: root/src/lib/auto.action
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2013-07-25 00:22:25 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2013-07-25 00:22:25 +0200
commit0f7688962fdadc7b72bdd81f719473e55608205c (patch)
tree28e19d543758bc1d224da454240ba88f995dc915 /src/lib/auto.action
parent906c6daa8a1ab95b3e169b09a925816ebce4831c (diff)
downloadnetctl-0f7688962fdadc7b72bdd81f719473e55608205c.tar.gz
netctl-0f7688962fdadc7b72bdd81f719473e55608205c.tar.xz
Make netctl-auto more hook friendly
The hooks (including any interface hook) are loaded each time a wpa event occurs. This means the auto.action script can be extended in the hooks. For this purpose, several exported variables (mainly $ACTION) can be checked for their value. The name of the active profile is not exported, but still available (just as in ordinary netctl usage) through the $Profile variable. Profiles ending in .action are disallowed (reserved for possible future use). Both ifplugd and wpa_actiond have a notion of 'action script'.
Diffstat (limited to 'src/lib/auto.action')
-rwxr-xr-xsrc/lib/auto.action27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/lib/auto.action b/src/lib/auto.action
index feebd77..3ea1373 100755
--- a/src/lib/auto.action
+++ b/src/lib/auto.action
@@ -3,37 +3,26 @@
. /usr/lib/network/globals
. "$SUBR_DIR/ip"
-interface="$1"
-ssid="$2"
-profile="$3"
-action="$4"
+export INTERFACE="$1"
+export SSID="$2"
+# Expose the profile name similar to ordinary netctl usage
+Profile="$3"
+export ACTION="$4"
-# Is it possible that we don't get a profile?!
-[[ "$profile" ]] && load_profile "$profile"
+load_profile "$Profile"
-case $action in
+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"
+ 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