aports

Custom Alpine Linux aports

git clone https://git.8pit.net/aports.git

 1#!/bin/sh
 2# Script for using udhcpc (started by ifup) with wpa_supplicant.
 3#
 4# Distributed under the same license as wpa_supplicant itself.
 5# Copyright (c) 2015,2018 Sören Tempel <soeren+alpine@soeren-tempel.net>
 6
 7if [ $# -ne 2 ]; then
 8	logger -t wpa_cli "this script should be called from wpa_cli(8)"
 9	exit 1
10fi
11
12IFNAME="${1}"
13ACTION="${2}"
14SIGNAL=""
15DHCPID=""
16
17# PID file created by the busybox ifup applet for udhcpc.
18DHCPIDFILE="/var/run/udhcpc.${IFNAME}.pid"
19
20if [ ! -e "${DHCPIDFILE}" ]; then
21	logger -t wpa_cli "udhcpc isn't running for interface '${IFNAME}'"
22	exit 1
23fi
24
25logger -t wpa_cli "interface ${IFNAME} ${ACTION}"
26case "${ACTION}" in
27	CONNECTED)
28		SIGNAL="USR1"
29		;;
30	DISCONNECTED)
31		SIGNAL="USR2"
32		;;
33	*)
34		logger -t wpa_cli "unknown action '${ACTION}'"
35		exit 1
36esac
37
38read -r DHCPID < "${DHCPIDFILE}"
39kill -${SIGNAL} "${DHCPID}" || logger -t wpa_cli \
40	"Couldn't send '${SIGNAL}' to '${DHCPID}'"