parlay

yet another gentoo overlay
git clone https://git.parazyd.org/parlay
Log | Files | Refs | README

wpa_cli.sh (1284B)


      1 #!/bin/sh
      2 # Copyright 1999-2011 Gentoo Foundation
      3 # Written by Roy Marples <uberlord@gentoo.org>
      4 # Distributed under the terms of the GNU General Public License v2
      5 # Alternatively, this file may be distributed under the terms of the BSD License
      6 
      7 if [ -z "$1" -o -z "$2" ]; then
      8 	logger -t wpa_cli "Insufficient parameters"
      9 	exit 1
     10 fi
     11 
     12 INTERFACE="$1"
     13 ACTION="$2"
     14 
     15 # Note, the below action must NOT mark the interface down via ifconfig, ip or
     16 # similar. Addresses can be removed, changed and daemons can be stopped, but
     17 # the interface must remain up for wpa_supplicant to work.
     18 
     19 if [ -f /etc/gentoo-release ]; then
     20 	EXEC="/etc/init.d/net.${INTERFACE} --quiet"
     21 else
     22 	logger -t wpa_cli "I don't know what to do with this distro!"
     23 	exit 1
     24 fi
     25 
     26 case ${ACTION} in
     27 	CONNECTED)
     28 		EXEC="${EXEC} start"
     29 		;;
     30 	DISCONNECTED)
     31 		# Deactivated, since stopping /etc/init.d/net.wlanX
     32 		# stops the network completly.
     33 		EXEC="false ${EXEC} stop"
     34 		;;
     35 	*)
     36 		logger -t wpa_cli "Unknown action ${ACTION}"
     37 		exit 1
     38 		;;
     39 esac
     40 
     41 # ${EXEC} can use ${IN_BACKGROUND} so that it knows that the user isn't
     42 # stopping the interface and a background process - like wpa_cli - is.
     43 export IN_BACKGROUND=true
     44 
     45 logger -t wpa_cli "interface ${INTERFACE} ${ACTION}"
     46 ${EXEC} || logger -t wpa_cli "executing '${EXEC}' failed"