Commit 1a35b9ff authored by Jouke Witteveen's avatar Jouke Witteveen
Browse files

Centralize profile exposing through the Profile variable

This also allows hooks to alter the profile to be loaded.
parent 04d39b25
......@@ -6,11 +6,9 @@
export INTERFACE="$1"
export SSID="$2"
# Expose the profile name similar to ordinary netctl usage
Profile="$3"
export ACTION="$4"
load_profile "$Profile"
load_profile "$3"
load_interface_config "$INTERFACE"
case $ACTION in
......
......@@ -113,19 +113,21 @@ list_profiles() {
# $1: profile name
load_profile() {
local hook
if [[ -z $1 || ! -r "$PROFILE_DIR/$1" ]]; then
exit_error "Profile '$1' does not exist or is not readable"
# Expose the profile name
Profile=$1
if [[ -z $Profile || ! -r "$PROFILE_DIR/$Profile" ]]; then
exit_error "Profile '$Profile' does not exist or is not readable"
fi
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"
source "$PROFILE_DIR/$Profile"
if [[ -z $Interface ]]; then
exit_error "Profile '$1' does not specify an interface"
exit_error "Profile '$Profile' does not specify an interface"
fi
if [[ ! -r "${Connection:+$SUBR_DIR/connections/$Connection}" ]]; then
exit_error "Profile '$1' does not specify a valid connection"
exit_error "Profile '$Profile' does not specify a valid connection"
fi
source "$SUBR_DIR/connections/$Connection"
}
......
......@@ -85,10 +85,9 @@ cd /
if [[ $# -eq 1 && $1 == wait-online ]]; then
network_wait_online
elif [[ $# -eq 2 && $1 == @(start|stop) ]]; then
# Expose the profile name and command
# Expose the command
Command=$1
Profile=$2
load_profile "$Profile"
load_profile "$2"
load_interface_config "$Interface"
"network_$1"
else
......
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