summaryrefslogtreecommitdiffstats
path: root/scripts/netcfg-wpa_actiond
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
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')
-rwxr-xr-xscripts/netcfg-wpa_actiond90
1 files changed, 90 insertions, 0 deletions
diff --git a/scripts/netcfg-wpa_actiond b/scripts/netcfg-wpa_actiond
new file mode 100755
index 0000000..bb144c3
--- /dev/null
+++ b/scripts/netcfg-wpa_actiond
@@ -0,0 +1,90 @@
+#! /bin/bash
+. /usr/lib/network/network
+. $SUBR_DIR/8021x
+. $SUBR_DIR/rfkill
+. /etc/rc.conf
+. /etc/conf.d/netcfg
+
+AUTOWIFI="/usr/sbin/wpa_actiond -p /run/wpa_supplicant"
+ACTION_SCRIPT="/usr/bin/netcfg-wpa_actiond-action"
+
+case $1 in
+ help)
+ echo "netcfg-wpa_actiond <interface>"
+ echo "netcfg-wpa_actiond stop <interface>"
+ exit
+ ;;
+ stop)
+ [[ -z $2 ]] && echo "Please specify an interface to stop" && exit 1
+ interface=$2
+ [[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
+ netcfg -i "$interface"
+ stop_wpa "$interface"
+ kill $(cat "/run/wpa_actiond_${2}.pid")
+ # only try to disable software rfkill switches (FS#25514)
+ if [[ "$RFKILL" == "soft" ]]; then
+ set_rf_state "$interface" disabled $RFKILL_NAME || exit $?
+ fi
+ exit
+ ;;
+ *)
+ interface=$1; shift
+ PIDFILE="/run/wpa_actiond_${interface}.pid"
+ EXTRA_AUTOWIFI_OPTIONS="$*"
+ ;;
+esac
+
+if [[ -z $interface ]]; then
+ echo "No interface specified"
+ exit 1
+fi
+
+# Load interface specific config
+[[ -f "$IFACE_DIR/$interface" ]] && source "$IFACE_DIR/$interface"
+
+if [[ -f "$CONN_DIR/interfaces/$interface" ]]; then
+ netcfg -i $interface
+fi
+
+if [[ -n "$RFKILL" ]]; then # Enable radio if necessary
+ enable_rf $interface $RFKILL $RFKILL_NAME || exit $?
+fi
+
+WPA_CONF="$(make_wpa_config_file $interface)"
+
+if [[ -n "${AUTO_PROFILES}" ]]; then
+ for prof in ${AUTO_PROFILES}; do echo $prof; done
+else
+ list_profiles
+fi | while read profile; do
+ echo "$profile"
+ (
+ load_profile "$profile"
+
+ [[ $CONNECTION != "wireless" ]] && exit 1
+ [[ $INTERFACE != $interface ]] && exit 1
+ # Exclude wpa-config, the wpa_conf is 'complete' and doesn't fit in this scheme
+ [[ -z "$SECURITY" ]] && SECURITY="none"
+ [[ $SECURITY == "wpa-config" ]] && exit 1
+
+ config=$(make_wpa_config)
+
+ echo -e "network={ \n$config \nid_str=\"$profile\" \n}" >> $WPA_CONF
+ )
+done
+
+
+[[ -z $WPA_DRIVER ]] && WPA_DRIVER="nl80211,wext"
+WPA_OPTS="-W $WPA_OPTS"
+
+# Kill any existing wpa_supplicant on this interface
+stop_wpa "$interface"
+
+if start_wpa $interface $WPA_CONF $WPA_DRIVER $WPA_OPTS; then
+ if $AUTOWIFI -i ${interface} -P ${PIDFILE} -a ${ACTION_SCRIPT} ${EXTRA_AUTOWIFI_OPTIONS}; then
+ exit 0
+ fi
+fi
+
+exit 1
+