summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/8021x14
-rw-r--r--src/connections/ethernet2
-rw-r--r--src/connections/ethernet-iproute24
-rw-r--r--src/connections/ppp3
-rw-r--r--src/connections/wireless2
-rw-r--r--src/globals34
-rw-r--r--src/hooks/arch4
-rw-r--r--src/net-profiles10
-rw-r--r--src/net-rename3
-rw-r--r--src/netcfg73
-rw-r--r--src/netcfg-menu12
-rw-r--r--src/network167
-rw-r--r--src/wireless4
13 files changed, 178 insertions, 174 deletions
diff --git a/src/8021x b/src/8021x
index bbbbbda..5d5e211 100644
--- a/src/8021x
+++ b/src/8021x
@@ -3,7 +3,7 @@
wpa_check()
{
local timeout=0 INTERFACE="$1" TIMEOUT="${2:-15}"
-
+
while [[ $timeout -lt "$TIMEOUT" ]]; do
( # Sometimes wpa_supplicant isn't ready so silence errors for 2s only to avoid hiding real errors
if [[ $timeout -lt 2 ]]; then
@@ -11,7 +11,7 @@ wpa_check()
else
eval $(wpa_cli -i "$INTERFACE" status | fgrep "wpa_state=")
fi
- [[ "$wpa_state" = "COMPLETED" ]]
+ [[ "$wpa_state" = "COMPLETED" ]]
) && return 0
sleep 1
let timeout++
@@ -20,10 +20,10 @@ wpa_check()
# wpa_cli -i "$INTERFACE" terminate >/dev/null 2>&1 # callers sometimes called stop_wpa, which does more but seems redundant
# termination should either be handled properly here, or by callers
stop_wpa "$INTERFACE"
- return 1
+ return 1
}
-start_wpa()
+start_wpa()
{
local INTERFACE="$1" WPA_CONF="$2"
shift 2
@@ -31,7 +31,7 @@ start_wpa()
wpa_supplicant -B -P "/var/run/wpa_supplicant_${INTERFACE}.pid" -i "$INTERFACE" -c "$WPA_CONF" $WPA_OPTS
sleep 1
-
+
if [[ ! -f "/var/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
return 1
fi
@@ -39,7 +39,7 @@ start_wpa()
stop_wpa()
{
- wpa_cli -i "$1" terminate &> /dev/null
+ wpa_cli -i "$1" terminate &> /dev/null
sleep 1 # JP: need this else the file tends to disappear after [[ -f ... ]] but before cat...
# see <http://bbs.archlinux.org/viewtopic.php?pid=515667#p515667>
if [[ -f "/var/run/wpa_supplicant_$1.pid" ]]; then
@@ -47,4 +47,4 @@ stop_wpa()
fi
}
-# vim: set ts=4 et sw=4 ft=sh:
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/connections/ethernet b/src/connections/ethernet
index 5414c69..8e34327 100644
--- a/src/connections/ethernet
+++ b/src/connections/ethernet
@@ -157,5 +157,5 @@ ethernet_status() {
ethernet_$1 "$2"
exit $?
-# vim: set ts=4 et sw=4:
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/connections/ethernet-iproute b/src/connections/ethernet-iproute
index 855ddb6..9da4b37 100644
--- a/src/connections/ethernet-iproute
+++ b/src/connections/ethernet-iproute
@@ -15,7 +15,7 @@ ethernet_up() {
if ! echo "$INTERFACE" | fgrep -q ":"; then
report_iproute "Interface $INTERFACE does not exist"
fi
- fi
+ fi
report_debug ethernet_iproute_up ifup
set_interface up "$INTERFACE"
@@ -24,8 +24,8 @@ ethernet_up() {
if ip link show dev "$INTERFACE" | fgrep -q "NO-CARRIER"; then
report_iproute "No connection"
fi
-
- if checkyesno "${AUTH8021X:-no}"; then
+
+ if checkyesno "${AUTH8021X:-no}"; then
. "$SUBR_DIR/8021x"
[[ -z "$WPA_CONF" ]] && WPA_CONF="/etc/wpa_supplicant.conf"
[[ -z "$WPA_OPTS" ]] && WPA_OPTS="-Dwired"
@@ -35,25 +35,25 @@ ethernet_up() {
report_fail "wpa_supplicant did not start, possible configuration error"
return 1
fi
-
+
if ! wpa_check "$INTERFACE"; then
# ignore quirk nodown---is that appropriate? or should we just use report_iproute?
# this adds a flush call as well---is that appropriate?
set_interface forcedown "$INTERFACE"
report_fail "WPA Authentication/Association Failed"
return 1
- fi
+ fi
fi
case "$IP" in
dhcp)
- # Clear remaining pid files.
+ # Clear remaining pid files.
rm -f "/var/run/dhcpcd-$INTERFACE".{pid,cache} >/dev/null 2>&1
# If using own dns, tell dhcpcd to NOT replace resolv.conf
[[ -n "$DNS" ]] && DHCP_OPTIONS="-C resolv.conf $DHCP_OPTIONS"
-
- report_debug ethernet_iproute_up dhcpcd -qL -t "${DHCP_TIMEOUT:-10}" $DHCP_OPTIONS "$INTERFACE"
+
+ report_debug ethernet_iproute_up dhcpcd -qL -t "${DHCP_TIMEOUT:-10}" $DHCP_OPTIONS "$INTERFACE"
dhcpcd -qL -t "${DHCP_TIMEOUT:-10}" $DHCP_OPTIONS "$INTERFACE" 2>&1 | report_debug "$(cat)"
if [[ "$PIPESTATUS" -ne 0 ]]; then
report_iproute "DHCP IP lease attempt failed"
@@ -80,8 +80,8 @@ ethernet_up() {
if [[ -n "$IPCFG" ]]; then
for line in "${IPCFG[@]}"; do
-
- report_debug ethernet_iproute_up ip "$line"
+
+ report_debug ethernet_iproute_up ip "$line"
if ! ip $line; then
report_iproute "Could not configure interface ($line)."
fi
@@ -98,7 +98,7 @@ ethernet_up() {
# Generate a new resolv.conf
if [[ -n "$DNS" ]]; then
- : >/etc/resolv.conf
+ : >/etc/resolv.conf
[[ -n "$DOMAIN" ]] && echo "domain $DOMAIN" >>/etc/resolv.conf
[[ -n "$SEARCH" ]] && echo "search $SEARCH" >>/etc/resolv.conf
@@ -118,7 +118,7 @@ ethernet_down() {
dhcpcd -qx "$INTERFACE" &>/dev/null
fi
fi
-
+
report_debug ethernet_iproute_down if_down
# ignore quirk nodown---is that appropriate?
# this adds a flush call as well---is that appropriate?
diff --git a/src/connections/ppp b/src/connections/ppp
index ec985d4..4a9b218 100644
--- a/src/connections/ppp
+++ b/src/connections/ppp
@@ -22,4 +22,5 @@ ppp_down() {
ppp_$1 "$2"
exit $?
-# vim: set ts=4 et sw=4:
+
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/connections/wireless b/src/connections/wireless
index b923b0b..0e7e274 100644
--- a/src/connections/wireless
+++ b/src/connections/wireless
@@ -235,5 +235,5 @@ wireless_status() {
wireless_$1 "$2" "$3"
exit $?
-# vim: set ts=4 et sw=4:
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/globals b/src/globals
index bd60b35..126095a 100644
--- a/src/globals
+++ b/src/globals
@@ -31,15 +31,15 @@ function report_warn {
}
function report_notify {
- true
+ true
}
function report_debug {
- checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
+ checkyesno "$NETCFG_DEBUG" && echo "DEBUG: $*" >&2
}
function report_try {
- # JP: this needs -n option
+ # JP: this needs -n option
echo -n ":: $*"
REPORT_TRYING=1
}
@@ -47,7 +47,7 @@ function report_try {
function report_fail {
if [[ -n "$*" ]]; then
if [[ -n "$REPORT_TRYING" ]]; then
- # JP: this needs -n option
+ # JP: this needs -n option
echo -n "- $*"
REPORT_TRYING=
echo "[fail]"
@@ -62,9 +62,9 @@ function report_fail {
function report_success {
if [[ -n "$*" ]]; then
- # JP: this needs -n option
+ # JP: this needs -n option
echo -n "- $*"
- REPORT_TRYING=
+ REPORT_TRYING=
fi
echo "[done]"
}
@@ -107,18 +107,18 @@ checkyesno()
function load_hooks() {
- ### Load any +x files in $HOOKS_DIR and $USERHOOKS_DIR
- local hook
- for hook in $(find -L "$HOOKS_DIR/" "$USERHOOKS_DIR/$hook" -maxdepth 1 -type f -executable -printf '%P\n' | sort -u); do
- # if there's an executable hook of this name in USERHOOKS_DIR, we only load it
- if [ -x "$USERHOOKS_DIR/$hook" ]; then
- source "$USERHOOKS_DIR/$hook"
- else
- source "$HOOKS_DIR/$hook"
- fi
- done
+ ### Load any +x files in $HOOKS_DIR and $USERHOOKS_DIR
+ local hook
+ for hook in $(find -L "$HOOKS_DIR/" "$USERHOOKS_DIR/$hook" -maxdepth 1 -type f -executable -printf '%P\n' | sort -u); do
+ # if there's an executable hook of this name in USERHOOKS_DIR, we only load it
+ if [ -x "$USERHOOKS_DIR/$hook" ]; then
+ source "$USERHOOKS_DIR/$hook"
+ else
+ source "$HOOKS_DIR/$hook"
+ fi
+ done
}
load_hooks
-
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/hooks/arch b/src/hooks/arch
index 5dc7168..c5d0587 100644
--- a/src/hooks/arch
+++ b/src/hooks/arch
@@ -34,7 +34,9 @@ function report_fail {
function report_success {
if [[ -n "$*" ]]; then
stat_append "- $*"
- REPORT_TRYING=
+ REPORT_TRYING=
fi
stat_done
}
+
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/net-profiles b/src/net-profiles
index 4f1c8d6..ccb14ee 100644
--- a/src/net-profiles
+++ b/src/net-profiles
@@ -18,8 +18,8 @@ case "$1" in
done
# $NET env var is passed from the kernel boot line
- [[ -z "$NETWORKS_MENU_TIMEOUT" ]] && NETWORKS_MENU_TIMEOUT=5
-
+ [[ -z "$NETWORKS_MENU_TIMEOUT" ]] && NETWORKS_MENU_TIMEOUT=5
+
if [[ "$NET" = "menu" ]]; then
if /usr/bin/netcfg-menu "$NETWORKS_MENU_TIMEOUT"; then
mv "$STATE_DIR"/{menu,net-profiles} # JP: user may want to disconnect profile by calling net-profiles stop
@@ -32,7 +32,7 @@ case "$1" in
add_daemon net-profiles
exit 0
fi
- else
+ else
# No NET= passed at boot, go to NETWORKS=()
for network in "${NETWORKS[@]}"; do
case "$network" in
@@ -55,7 +55,7 @@ case "$1" in
;;
esac
done
- fi
+ fi
exit_err "No profile started." # JP: don't add_daemon unless we were successful (above)
;;
@@ -79,4 +79,4 @@ case "$1" in
exit_stderr "Usage: $0 {start|stop|restart}"
esac
-# vim: set ts=4 et sw=4:
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/net-rename b/src/net-rename
index d886daa..1a51ffe 100644
--- a/src/net-rename
+++ b/src/net-rename
@@ -22,4 +22,5 @@ case "$1" in
exit_stderr "Usage: $0 {start|stop|restart}"
;;
esac
-# vim: set ts=4 et sw=4:
+
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/netcfg b/src/netcfg
index 1215332..91d038e 100644
--- a/src/netcfg
+++ b/src/netcfg
@@ -13,7 +13,7 @@ usage()
{
version
echo "Usage:"
- echo " Start specified profile: netcfg profile "
+ echo " Start specified profile: netcfg profile "
echo " Other functions: netcfg argument profile"
echo "Arguments:"
echo " current Report currently running profiles"
@@ -23,38 +23,38 @@ usage()
echo "-h, help This help message"
echo "-i, iface-down Take down profile active on specified interface"
echo "-l, list List all available profiles"
- echo "-r, reconnect Disconnect and reconnect specified profile"
- echo "-u, up Start specified profile"
+ echo "-r, reconnect Disconnect and reconnect specified profile"
+ echo "-u, up Start specified profile"
echo "-v, version Output version information and exit"
echo " all-resume Resume previously suspended profiles and reconnect them"
echo " all-suspend Store a list of current running profiles and suspend them"
- exit 1
+ exit 1
}
# TODO: Re-add ROOT check and rewrite with getopts from BashFAQ
case "$1" in
- --version|-v|version)
+ --version|-v|version)
version
- exit 0;;
- --help|-h|help)
+ exit 0;;
+ --help|-h|help)
usage;;
- list|-l)
- echo "Available Profiles"
- echo "------------------"
- list_profiles
- exit 0;;
- current)
- if [[ -d "$STATE_DIR/profiles/" ]]; then
- ls "$STATE_DIR/profiles/"
- exit 0
- else
- exit_stderr "No active profiles."
- fi;;
+ list|-l)
+ echo "Available Profiles"
+ echo "------------------"
+ list_profiles
+ exit 0;;
+ current)
+ if [[ -d "$STATE_DIR/profiles/" ]]; then
+ ls "$STATE_DIR/profiles/"
+ exit 0
+ else
+ exit_stderr "No active profiles."
+ fi;;
esac
if [[ $(id -u) -gt 0 ]]; then
- exit_stderr "This script should be run as root."
+ exit_stderr "This script should be run as root."
fi
case "$1" in
@@ -63,35 +63,36 @@ case "$1" in
CHECK="YES"
profile_up "$2";;
clean)
- rm "$STATE_DIR/interfaces"/* 2> /dev/null
- rm "$STATE_DIR/profiles"/* 2> /dev/null
- rm "$STATE_DIR/suspend"/* 2> /dev/null
- rm "$STATE_DIR/last_profile" 2> /dev/null
+ rm "$STATE_DIR/interfaces"/* 2> /dev/null
+ rm "$STATE_DIR/profiles"/* 2> /dev/null
+ rm "$STATE_DIR/suspend"/* 2> /dev/null
+ rm "$STATE_DIR/last_profile" 2> /dev/null
killall wpa_supplicant 2> /dev/null
killall dhcpcd 2> /dev/null
- ;;
- -d|down)
+ ;;
+ -d|down)
profile_down "$2";;
- -i|iface-down)
+ -i|iface-down)
interface_down "$2";;
- -a|all-down)
- all_down;;
- -r|reconnect)
- profile_down "$2"
- profile_up "$2";;
+ -a|all-down)
+ all_down;;
+ -r|reconnect)
+ profile_down "$2"
+ profile_up "$2";;
all-resume)
all_resume;;
all-suspend)
all_suspend;;
- -*|--*)
+ -*|--*)
usage;;
- *)
+ *)
if [[ -n "$1" ]]; then
profile_up "$1"
else
usage
fi
- ;;
+ ;;
esac
exit $?
-# vim: set ts=2 noet:
+
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/netcfg-menu b/src/netcfg-menu
index 40f20b2..a054fe7 100644
--- a/src/netcfg-menu
+++ b/src/netcfg-menu
@@ -41,24 +41,24 @@ dialog --timeout "$TIMEOUT" --default-item "$DEFAULT" \
13 50 6 "${profiles[@]}" 2> "$ANSWER"
ret=$?
-
+
case $ret in
1) ;; # Cancel - do nothing
- 255) # timeout - use default
+ 255) # timeout - use default
profile_up "$DEFAULT" # JP: use profile_up and catch $?
ret=$?
if [[ $ret -eq 0 ]]; then echo "$DEFAULT" > "$STATE_DIR/menu"; fi
- ;;
+ ;;
0) # User selection
profile_up "$(cat "$ANSWER")"
ret=$?
if [[ $ret -eq 0 ]]; then mv "$ANSWER" "$STATE_DIR/menu"; fi
- ;;
+ ;;
*) # Shouldnt happen
exit_err "Abnormal ret code from dialog: $ret"
- ;;
+ ;;
esac
rm -f "$ANSWER" # JP: add -f
exit $ret # JP: exit with caught $?
-# vim: set ts=4 et sw=4:
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/network b/src/network
index 28250b4..f1f55cf 100644
--- a/src/network
+++ b/src/network
@@ -20,11 +20,11 @@ load_profile()
report_fail "Profile missing an interface to configure"
return 1
fi
- if [[ -f "$IFACE_DIR/$INTERFACE" ]]; then
- report_debug "Interface level configuration enabled: $IFACE_DIR/$INTERFACE"
- . "$IFACE_DIR/$INTERFACE"
- . "$PROFILE_DIR/$1" # we want profile settings to override, so need to source profile again
- fi
+ if [[ -f "$IFACE_DIR/$INTERFACE" ]]; then
+ report_debug "Interface level configuration enabled: $IFACE_DIR/$INTERFACE"
+ . "$IFACE_DIR/$INTERFACE"
+ . "$PROFILE_DIR/$1" # we want profile settings to override, so need to source profile again
+ fi
if [[ ! -f "$CONN_DIR/$CONNECTION" ]]; then
report_fail "$CONNECTION is not a valid connection, check spelling or look at examples"
return 1
@@ -38,8 +38,8 @@ load_profile()
all_down()
{
find "$STATE_DIR/profiles/" -maxdepth 1 -type f -printf '%f\n' \
- | while read prof; do
- # the pipe to while read... creates a subshell
+ | while read prof; do
+ # the pipe to while read... creates a subshell
profile_down "$prof"
done
}
@@ -48,22 +48,22 @@ all_down()
# store a list of running profiles and take them down (unless $2 is "no")
interface_suspend()
{
- report_debug interface_suspend "$@"
+ report_debug interface_suspend "$@"
[[ ! -d "$STATE_DIR" ]] && mkdir -p "$STATE_DIR"/{interfaces,profiles}
[[ ! -d "$STATE_DIR/suspend" ]] && mkdir "$STATE_DIR/suspend"
find "$STATE_DIR/profiles/" -maxdepth 1 -type f -printf '%f\n' \
- | while read prof; do
+ | while read prof; do
# the pipe to "while read" will create a subshell, so sourced variables will already be in a sandbox
# we just need to clear INTERFACE which is all we care about
unset INTERFACE
. "$STATE_DIR/profiles/$prof"
if [[ "$1" == all || "$1" == "$INTERFACE" ]]; then
report_notify "suspending interface $INTERFACE with profile $prof"
- cp "$STATE_DIR/profiles/$prof" "$STATE_DIR/suspend/"
+ cp "$STATE_DIR/profiles/$prof" "$STATE_DIR/suspend/"
if checkyesno "${2:-yes}"; then
- profile_down "$prof"
+ profile_down "$prof"
fi
fi
done
@@ -79,16 +79,16 @@ all_suspend() {
# optional arguments: interfaces not to resume (e.g., because they're disabled)
all_resume()
{
- report_debug all_resume "$@"
+ report_debug all_resume "$@"
find "$STATE_DIR/suspend/" -maxdepth 1 -type f -printf '%f\n' \
- | while read prof; do
+ | while read prof; do
# the pipe to "while read" will create a subshell, so sourced variables will already be in a sandbox
# we just need to clear INTERFACE which is all we care about
unset INTERFACE
. "$STATE_DIR/suspend/$prof"
if [[ $# -eq 0 || ! " $* " =~ " $INTERFACE " ]]; then
report_notify "resuming interface $INTERFACE with profile $prof"
- profile_up "$prof"
+ profile_up "$prof"
rm -f "$STATE_DIR/suspend/$prof" # if profile_up succeeds, it will have already removed this
fi
done
@@ -104,14 +104,14 @@ profile_up()
# exit 1 used in a subshell is effectively exiting a new process
[[ ! -d "$STATE_DIR" ]] && mkdir -p "$STATE_DIR"/{interfaces,profiles,suspend}
- local PROFILE="$1" # save PROFILE in a variable so that it's available to PRE_UP/POST_DOWN etc hooks
+ local PROFILE="$1" # save PROFILE in a variable so that it's available to PRE_UP/POST_DOWN etc hooks
load_profile "$PROFILE" || exit 1
if check_profile "$PROFILE"; then
- report_fail "$PROFILE already connected"
- exit 1
- fi
+ report_fail "$PROFILE already connected"
+ exit 1
+ fi
# NETWORKS_EXCLUSIVE, rc.conf: Profiles are globally mutually exclusive
# EXCLUSIVE, network.d/profile: Individual profile is mutually exclusive
@@ -137,26 +137,26 @@ profile_up()
;;
esac
- if ! ( eval $PRE_UP ); then # JP: sandbox the eval so variables don't bleed into current function
- report_debug profile_up "PRE_UP failed"
- report_fail
- exit 1
+ if ! ( eval $PRE_UP ); then # JP: sandbox the eval so variables don't bleed into current function
+ report_debug profile_up "PRE_UP failed"
+ report_fail
+ exit 1
fi
if ! "$CONN_DIR/$CONNECTION" up "$PROFILE" "$2"; then
- report_debug profile_up "connect failed"
+ report_debug profile_up "connect failed"
report_fail
- # "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2" # JP: should we do this to make sure?
+ # "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2" # JP: should we do this to make sure?
exit 1
fi
- if ! ( eval $POST_UP ); then # JP: sandbox the eval
- report_debug profile_up "POST_UP failed"
- report_fail
- # failing POST_UP will take interface down
- "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2"
- exit 1
- fi
+ if ! ( eval $POST_UP ); then # JP: sandbox the eval
+ report_debug profile_up "POST_UP failed"
+ report_fail
+ # failing POST_UP will take interface down
+ "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2"
+ exit 1
+ fi
set_profile up "$PROFILE"
unset EXCLUSIVE
@@ -164,7 +164,7 @@ profile_up()
# Successfully running a new profile; erase any suspended profiles on this interface
local iface="$INTERFACE"
find "$STATE_DIR/suspend/" -maxdepth 1 -type f -printf '%f\n' \
- | while read prof; do
+ | while read prof; do
# the pipe to "while read" will create a subshell, so sourced variables will already be in a sandbox
# we just need to clear INTERFACE which is all we care about
unset INTERFACE
@@ -186,7 +186,7 @@ profile_down()
(
[[ ! -d "$STATE_DIR" ]] && mkdir -p "$STATE_DIR"/{interfaces,profiles,suspend}
- local PROFILE="$1" # save PROFILE in a variable so that it's available to PRE_UP/POST_DOWN etc hooks
+ local PROFILE="$1" # save PROFILE in a variable so that it's available to PRE_UP/POST_DOWN etc hooks
load_profile "$PROFILE" || exit 1
@@ -201,24 +201,24 @@ profile_down()
exit 1
fi
- if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval
- report_debug profile_down "PRE_DOWN failed"
- # true # JP: did we want failing PRE_DOWN to leave the profile active?
- report_fail
- exit 1
- fi
+ if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval
+ report_debug profile_down "PRE_DOWN failed"
+ # true # JP: did we want failing PRE_DOWN to leave the profile active?
+ report_fail
+ exit 1
+ fi
if ! "$CONN_DIR/$CONNECTION" down "$PROFILE" "$2"; then
- report_debug profile_up "disconnect failed"
+ report_debug profile_up "disconnect failed"
report_fail
exit 1
fi
- if ! ( eval $POST_DOWN ); then # JP: sandbox the eval
- report_debug profile_down "POST_DOWN failed"
- report_fail
- exit 1
- fi
+ if ! ( eval $POST_DOWN ); then # JP: sandbox the eval
+ report_debug profile_down "POST_DOWN failed"
+ report_fail
+ exit 1
+ fi
set_profile down "$PROFILE"
report_success
@@ -228,19 +228,19 @@ profile_down()
# Check if variable is a member of an array
inarray()
{
- local item search="$1"
- shift
- for item in "$@"; do
- if [[ "$item" == "$search" ]]; then
- return 0
- fi
- done
- return 1
+ local item search="$1"
+ shift
+ for item in "$@"; do
+ if [[ "$item" == "$search" ]]; then
+ return 0
+ fi
+ done
+ return 1
}
quirk() {
- inarray "$1" "${QUIRKS[@]}"
- return $?
+ inarray "$1" "${QUIRKS[@]}"
+ return $?
}
# interface_down interface
@@ -291,7 +291,7 @@ get_iface_prof() {
# Outputs a list of all profiles
list_profiles() {
# JP: follow aliases with -L, also skip profiles that start with '.' or end with '~' or '.conf' (so profile.conf can be the wpa.conf file for profile)
- find -L "$PROFILE_DIR/" -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' -printf "%f\n"
+ find -L "$PROFILE_DIR/" -maxdepth 1 -type f -not -name '*~' -not -name '*.conf' -not -name '.*' -printf "%f\n"
}
# check_profile profile
# Return 0 if profile registered as being up
@@ -310,17 +310,17 @@ check_profile() {
set_profile() {
if [[ "$1" == "up" ]]; then
( # subshell creates sandbox for sourced variables
- . "$PROFILE_DIR/$2" # we source profile in order to obtain INTERFACE
+ . "$PROFILE_DIR/$2" # we source profile in order to obtain INTERFACE
cp "$PROFILE_DIR/$2" "$STATE_DIR/profiles/"
echo "$2" > "$STATE_DIR/last_profile"
set_iface up "$INTERFACE" "$2"
- )
+ )
elif [[ "$1" == "down" && -f "$STATE_DIR/profiles/$2" ]]; then # JP: skip if profile not already up
( # subshell
- . "$STATE_DIR/profiles/$2" # we source profile in order to obtain INTERFACE
+ . "$STATE_DIR/profiles/$2" # we source profile in order to obtain INTERFACE
rm "$STATE_DIR/profiles/$2"
set_iface down "$INTERFACE" "$2"
- )
+ )
fi
}
@@ -343,32 +343,32 @@ set_interface()
INTERFACE="$2"
case "$1" in
up|up-old)
- if ! ( eval $IFACE_UP ); then
- return 1
- fi
- if [ "$1" = old ]; then
- ifconfig "$INTERFACE" up
- else
- ip link set dev "$INTERFACE" up
- fi
+ if ! ( eval $IFACE_UP ); then
+ return 1
+ fi
+ if [ "$1" = old ]; then
+ ifconfig "$INTERFACE" up
+ else
+ ip link set dev "$INTERFACE" up
+ fi
sleep "${UP_SLEEP:-2}"
;;
down|forcedown|down-old|forcedown-old)
- # should this be placed elsewhere?
- if ! ( eval $IFACE_DOWN ); then
- return 1
- fi
- if [ "${1%-old}" != "$1" ]; then
- ## ?
- if ! quirk nodown || [ "$1" = forcedown-old ]; then
- ifconfig "$INTERFACE" down
- fi
- else
- ip addr flush dev "$INTERFACE" &>/dev/null
- if ! quirk nodown || [ "$1" = forcedown ]; then
- ip link set dev "$INTERFACE" down &>/dev/null
- fi
- fi
+ # should this be placed elsewhere?
+ if ! ( eval $IFACE_DOWN ); then
+ return 1
+ fi
+ if [ "${1%-old}" != "$1" ]; then
+ ## ?
+ if ! quirk nodown || [ "$1" = forcedown-old ]; then
+ ifconfig "$INTERFACE" down
+ fi
+ else
+ ip addr flush dev "$INTERFACE" &>/dev/null
+ if ! quirk nodown || [ "$1" = forcedown ]; then
+ ip link set dev "$INTERFACE" down &>/dev/null
+ fi
+ fi
;;
*)
return 1
@@ -376,3 +376,4 @@ set_interface()
esac
}
+# vim: ft=sh ts=4 et sw=4:
diff --git a/src/wireless b/src/wireless
index 3592d5e..b9ce12a 100644
--- a/src/wireless
+++ b/src/wireless
@@ -221,6 +221,4 @@ get_rf_state() {
esac
}
-
-# vim: set ts=4 et sw=4 ft=sh:
-
+# vim: ft=sh ts=4 et sw=4: