aboutsummaryrefslogtreecommitdiffstats
path: root/main/wpa_supplicant/wpa_cli.sh
diff options
context:
space:
mode:
Diffstat (limited to 'main/wpa_supplicant/wpa_cli.sh')
-rw-r--r--main/wpa_supplicant/wpa_cli.sh35
1 files changed, 21 insertions, 14 deletions
diff --git a/main/wpa_supplicant/wpa_cli.sh b/main/wpa_supplicant/wpa_cli.sh
index 0a5a6cc036..dd9bc2ca46 100644
--- a/main/wpa_supplicant/wpa_cli.sh
+++ b/main/wpa_supplicant/wpa_cli.sh
@@ -1,33 +1,40 @@
#!/bin/sh
-# Distributed under the terms of the BSD License.
-# Copyright (c) 2015 Sören Tempel <soeren+alpine@soeren-tempel.net>
+# Script for using udhcpc (started by ifup) with wpa_supplicant.
+#
+# Distributed under the same license as wpa_supplicant itself.
+# Copyright (c) 2015,2018 Sören Tempel <soeren+alpine@soeren-tempel.net>
-IFUP="/sbin/ifup"
-IFDOWN="/sbin/ifdown"
-
-if [ -z "${1}" -o -z "${2}" ]; then
+if [ $# -ne 2 ]; then
logger -t wpa_cli "this script should be called from wpa_cli(8)"
exit 1
-elif ! [ -x "${IFUP}" -a -x "${IFDOWN}" ]; then
- logger -t wpa_cli "${IFUP} or ${IFDOWN} doesn't exist"
- exit 1
fi
IFNAME="${1}"
ACTION="${2}"
+SIGNAL=""
+DHCPID=""
+
+# PID file created by the busybox ifup applet for udhcpc.
+DHCPIDFILE="/var/run/udhcpc.${IFNAME}.pid"
+
+if [ ! -e "${DHCPIDFILE}" ]; then
+ logger -t wpa_cli "udhcpc isn't running for interface '${IFNAME}'"
+ exit 1
+fi
-EXEC=""
+logger -t wpa_cli "interface ${IFNAME} ${ACTION}"
case "${ACTION}" in
CONNECTED)
- EXEC="${IFUP}"
+ SIGNAL="USR1"
;;
DISCONNECTED)
- EXEC="${IFDOWN}"
+ SIGNAL="USR2"
;;
*)
logger -t wpa_cli "unknown action '${ACTION}'"
exit 1
esac
-logger -t wpa_cli "interface ${IFNAME} ${ACTION}"
-${EXEC} "${IFNAME}" || logger -t wpa_cli "executing '${EXEC}' failed"
+read -r DHCPID < "${DHCPIDFILE}"
+kill -${SIGNAL} "${DHCPID}" || logger -t wpa_cli \
+ "Couldn't send '${SIGNAL}' to '${DHCPID}'"