summaryrefslogtreecommitdiffstats
path: root/scripts/netcfg-wpa_actiond-action
diff options
context:
space:
mode:
authorRémy Oudompheng <remy@archlinux.org>2011-08-20 13:13:35 +0200
committerRémy Oudompheng <remy@archlinux.org>2011-08-20 13:13:35 +0200
commit1227a80b24c943438757e933bd568ceddd00479b (patch)
treee88638495f85726377dfa6cf4279ab31c3f54534 /scripts/netcfg-wpa_actiond-action
parentec0e041a8eab919abef8e3af289c979ee1737382 (diff)
downloadnetctl-1227a80b24c943438757e933bd568ceddd00479b.tar.gz
netctl-1227a80b24c943438757e933bd568ceddd00479b.tar.xz
Reorganize files to match install location closer
Signed-off-by: Rémy Oudompheng <remy@archlinux.org>
Diffstat (limited to 'scripts/netcfg-wpa_actiond-action')
-rwxr-xr-xscripts/netcfg-wpa_actiond-action54
1 files changed, 54 insertions, 0 deletions
diff --git a/scripts/netcfg-wpa_actiond-action b/scripts/netcfg-wpa_actiond-action
new file mode 100755
index 0000000..3547fef
--- /dev/null
+++ b/scripts/netcfg-wpa_actiond-action
@@ -0,0 +1,54 @@
+#! /bin/bash
+
+interface="$1"
+ssid="$2"
+profile="$3"
+action="$4"
+
+. /usr/lib/network/network
+[[ "$profile" ]] && load_profile "$profile"
+
+case $action in
+ CONNECT)
+ if [[ -z $profile ]]; then
+ dhcpcd "$interface"
+ exit $?
+ fi
+ if ! $CONN_DIR/ethernet up "$profile"; then
+ exit 1 # what to do if fail?
+ fi
+
+ set_profile up "$profile"
+
+ if ! ( eval $POST_UP ); then # JP: sandbox the eval
+ # failing POST_UP will take interface down
+ "$CONN_DIR/$ethernet" down "$profile"
+ exit 1
+ fi
+ ;;
+ DISCONNECT)
+ if [[ -z $profile ]]; then
+ dhcpcd -k "$interface"
+ exit $?
+ fi
+ if ! ( eval $PRE_DOWN ); then # JP: sandbox the eval
+ exit 1
+ fi
+ if ! "$CONN_DIR/ethernet" down "$profile"; then
+ exit 1
+ fi
+ if ! ( eval $POST_DOWN ); then # JP: sandbox the eval
+ exit 1
+ fi
+ set_profile down "$profile"
+ ;;
+ LOST|REESTABLISHED)
+ # Not handled.
+ exit 0
+ ;;
+ *)
+ # ???
+ exit 1
+ ;;
+esac
+