Commit 0f768896 authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

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'.
parent 906c6daa
......@@ -20,13 +20,13 @@ much quoting as possible. For a few WPA-related variables, special
quoting rules (see below) apply.
The name of the profile is the name of the file. Profile names must not
contain newlines and should not end in '.service' or '.conf'. Whenever a
profile is read, all executable scripts in '/etc/netctl/hooks/' and any
executable script in '/etc/netctl/interfaces/' with the name of the
interface for the profile are sourced. Declarations in an interface
script override declarations in a profile, which override declarations
in hooks. For each connection type, there are example profile files in
'/etc/netctl/examples/'.
contain newlines and should not end in '.action', '.conf', or
'.service'. Whenever a profile is read, all executable scripts in
'/etc/netctl/hooks/' and any executable script in
'/etc/netctl/interfaces/' with the name of the interface for the profile
are sourced. Declarations in an interface script override declarations
in a profile, which override declarations in hooks. For each connection
type, there are example profile files in '/etc/netctl/examples/'.
AVAILABLE CONNECTION TYPES
......
......@@ -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
......
......@@ -93,7 +93,7 @@ timeout_wait() {
list_profiles() {
# JP: follow aliases with -L, also skip profiles that end with '.conf' (so
# profile.conf can be the wpa.conf file for profile)
find -L "$PROFILE_DIR/" -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.conf' -not -name '*.service' -printf "%f\n"
find -L "$PROFILE_DIR/" -maxdepth 1 -type f -not -name '.*' -not -name '*~' -not -name '*.action' -not -name '*.conf' -not -name '*.service' -printf "%f\n"
}
## Sources all hooks, a profile and any interface hook
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment