Commit 8c873b49 authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Improved handling of exposed variables

Hooks can now tell the command to be executed by looking at $Command.
The value will be "start", "stop", or "" (undefined), depending on the
reason a profile is being sourced.
parent dbc32d47
......@@ -119,6 +119,7 @@ load_profile() {
while IFS= read -r hook; do
source "$hook"
done < <(find -L "$PROFILE_DIR/hooks" -maxdepth 1 -type f -executable -not -name '.*' -not -name '*~' -not -name $'*\n*' | sort -u)
unset hook
source "$PROFILE_DIR/$1"
if [[ -z $Interface ]]; then
exit_error "Profile '$1' does not specify an interface"
......
......@@ -85,7 +85,8 @@ cd /
if [[ $# -eq 1 && $1 == wait-online ]]; then
network_wait_online
elif [[ $# -eq 2 && $1 == @(start|stop) ]]; then
# Expose the profile name
# Expose the profile name and command
Command=$1
Profile=$2
load_profile "$Profile"
load_interface_config "$Interface"
......
......@@ -35,7 +35,7 @@ init_profiles() {
local i=0 essid profile
while IFS= read -r profile; do
essid=$(
unset INTERFACE ESSID
unset Interface ESSID
source "$PROFILE_DIR/$profile" > /dev/null
if [[ "$Interface" = "$1" && -n "$ESSID" ]]; then
printf "%s" "$ESSID"
......
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