]> git.ipfire.org Git - ipfire-2.x.git/blame_incremental - src/initscripts/packages/hostapd
hostapd: Find device by MAC address
[ipfire-2.x.git] / src / initscripts / packages / hostapd
... / ...
CommitLineData
1#!/bin/sh
2. /etc/sysconfig/rc
3. ${rc_functions}
4
5find_interface() {
6 local address="${1}"
7
8 local path
9 for path in /sys/class/net/*; do
10 if [ -s "${path}/address" ] && [ "$(<${path}/address)" = "${address}" ]; then
11 basename "${path}"
12 return 0
13 fi
14 done
15
16 return 1;
17}
18
19CHANNEL="6"
20COUNTRY="00"
21TXPOWER="auto"
22INTERFACE="blue0"
23MACMODE="0"
24
25eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings)
26
27case "${1}" in
28 start)
29 interface="$(find_interface "${INTERFACE}")"
30 if [ -z "${interface}" ]; then
31 boot_mesg "Could not find interface with address ${INTERFACE} for wireless access point"
32 echo_failure
33 exit 1
34 fi
35
36 boot_mesg "Starting hostapd... "
37 loadproc /usr/bin/hostapd -B /etc/hostapd.conf -i "${interface}"
38 ;;
39
40 stop)
41 boot_mesg "Stopping hostapd..."
42 killproc /usr/bin/hostapd
43 evaluate_retval
44 ;;
45
46 restart)
47 ${0} stop
48 sleep 1
49 ${0} start
50 ;;
51
52 status)
53 statusproc /usr/bin/hostapd
54 ;;
55
56 *)
57 echo "Usage: ${0} {start|stop|restart|status}"
58 exit 1
59 ;;
60esac