]>
| Commit | Line | Data |
|---|---|---|
| 1 | #!/bin/sh | |
| 2 | ############################################################################### | |
| 3 | # # | |
| 4 | # IPFire.org - A linux based firewall # | |
| 5 | # Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> # | |
| 6 | # # | |
| 7 | # This program is free software: you can redistribute it and/or modify # | |
| 8 | # it under the terms of the GNU General Public License as published by # | |
| 9 | # the Free Software Foundation, either version 3 of the License, or # | |
| 10 | # (at your option) any later version. # | |
| 11 | # # | |
| 12 | # This program is distributed in the hope that it will be useful, # | |
| 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
| 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
| 15 | # GNU General Public License for more details. # | |
| 16 | # # | |
| 17 | # You should have received a copy of the GNU General Public License # | |
| 18 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
| 19 | # # | |
| 20 | ############################################################################### | |
| 21 | ||
| 22 | . /etc/sysconfig/rc | |
| 23 | . ${rc_functions} | |
| 24 | ||
| 25 | find_interface() { | |
| 26 | local address="${1}" | |
| 27 | ||
| 28 | local path | |
| 29 | for path in /sys/class/net/*; do | |
| 30 | if [ -s "${path}/address" ] && [ "$(<${path}/address)" = "${address}" ]; then | |
| 31 | basename "${path}" | |
| 32 | return 0 | |
| 33 | fi | |
| 34 | done | |
| 35 | ||
| 36 | return 1; | |
| 37 | } | |
| 38 | ||
| 39 | CHANNEL="6" | |
| 40 | COUNTRY="00" | |
| 41 | TXPOWER="auto" | |
| 42 | INTERFACE="blue0" | |
| 43 | MACMODE="0" | |
| 44 | ||
| 45 | eval $(/usr/local/bin/readhash /var/ipfire/wlanap/settings) | |
| 46 | ||
| 47 | case "${1}" in | |
| 48 | start) | |
| 49 | interface="$(find_interface "${INTERFACE}")" | |
| 50 | if [ -z "${interface}" ]; then | |
| 51 | boot_mesg "Could not find interface with address ${INTERFACE} for wireless access point" | |
| 52 | echo_failure | |
| 53 | exit 1 | |
| 54 | fi | |
| 55 | ||
| 56 | boot_mesg "Starting hostapd... " | |
| 57 | loadproc /usr/bin/hostapd -s -B /etc/hostapd.conf -i "${interface}" | |
| 58 | ;; | |
| 59 | ||
| 60 | stop) | |
| 61 | boot_mesg "Stopping hostapd..." | |
| 62 | killproc /usr/bin/hostapd | |
| 63 | evaluate_retval | |
| 64 | ;; | |
| 65 | ||
| 66 | restart) | |
| 67 | ${0} stop | |
| 68 | sleep 1 | |
| 69 | ${0} start | |
| 70 | ;; | |
| 71 | ||
| 72 | status) | |
| 73 | statusproc /usr/bin/hostapd | |
| 74 | ;; | |
| 75 | ||
| 76 | *) | |
| 77 | echo "Usage: ${0} {start|stop|restart|status}" | |
| 78 | exit 1 | |
| 79 | ;; | |
| 80 | esac |