diff options
author | William Harrington <kb0iic@cross-lfs.org> | 2014-04-26 20:51:13 -0500 |
---|---|---|
committer | William Harrington <kb0iic@cross-lfs.org> | 2014-04-26 20:51:13 -0500 |
commit | d428b64adcd7aa90681669315f7ff847bb2af3ea (patch) | |
tree | b80fe7868fac840476e45960edfe3a990dc23e79 /clfs/services/wpa |
Initial commit.
Diffstat (limited to 'clfs/services/wpa')
-rw-r--r-- | clfs/services/wpa | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/clfs/services/wpa b/clfs/services/wpa new file mode 100644 index 0000000..a02f0e8 --- /dev/null +++ b/clfs/services/wpa @@ -0,0 +1,89 @@ +#!/bin/bash +# Begin services/wpa + +# Origianlly based upon lfs-bootscripts-1.12 $NETWORK_DEVICES/if{down,up} +# Written by Armin K. <krejzi at email dot com> + +# Call with: IFCONFIG=<filename> /lib/services/wpa <IFACE> <up | down> + +#$LastChangedBy: krejzi $ +#$Date: 2013-03-24 16:39:14 +0100 (Sun, 24 Mar 2013) $ + +. /lib/lsb/init-functions +. $IFCONFIG + +CFGFILE=/etc/sysconfig/wpa_supplicant-${IFCONFIG##*.}.conf +PIDFILE=/run/wpa_supplicant/$1.pid +CONTROL_IFACE=/run/wpa_supplicant/$1 + +case "$2" in + up) + + if [ -e ${PIDFILE} ]; then + ps $(cat ${PIDFILE}) | grep wpa_supplicant >/dev/null + if [ "$?" = "0" ]; then + log_warning_msg "\n wpa_supplicant already running on $1." + exit 0 + else + rm ${PIDFILE} + fi + fi + + if [ ! -e ${CFGFILE} ]; then + log_info_msg "\n wpa_supplicant configuration file ${CFGFILE} not present" + log_failure_msg2 + exit 1 + fi + + log_info_msg "\n Starting wpa_supplicant on the $1 interface..." + + mkdir -p /run/wpa_supplicant + + /sbin/wpa_supplicant -q -B -Dnl80211,wext -P${PIDFILE} -C/run/wpa_supplicant -c${CFGFILE} -i$1 ${WPA_ARGS} + + if [ "$?" != "0" ]; then + log_failure_msg2 + exit 1 + fi + + log_success_msg2 + + if [ -n "${WPA_SERVICE}" ]; then + if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then + log_info_msg "\n Cannot start ${WPA_SERVICE} on $1" + log_failure_msg2 + exit 1 + fi + + IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 up + fi + ;; + + down) + if [ -n "${WPA_SERVICE}" ]; then + if [ ! -e /lib/services/${WPA_SERVICE} -a ! -x /lib/services/${WPA_SERVICE} ]; then + log_warning_msg "\n Cannot stop ${WPA_SERVICE} on $1" + else + IFCONFIG=${IFCONFIG} /lib/services/${WPA_SERVICE} $1 down + fi + fi + + log_info_msg "\n Stopping wpa_supplicant on the $1 interface..." + + if [ -e ${PIDFILE} ]; then + kill -9 $(cat ${PIDFILE}) + rm -f ${PIDFILE} ${CONTROL_IFACE} + evaluate_retval + else + log_warning_msg "\n wpa_supplicant already stopped on $1" + exit 0 + fi + ;; + + *) + echo "Usage: $0 [interface] {up|down}" + exit 1 + ;; +esac + +# End services/wpa |