create_ap

create a nat-ed wifi ap
git clone git://git.2f30.org/create_ap
Log | Files | Refs | README | LICENSE

commit 4758bcf6d984a9bcde3548927971492dfb41f370
parent 9ab97af45184602d4f386f4021d21ab15021a8e4
Author: oblique <psyberbits@gmail.com>
Date:   Sun, 17 Aug 2014 01:16:50 +0300

Merge branch 'hashken-hostapd_bug'

Diffstat:
Mcreate_ap | 19++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/create_ap b/create_ap @@ -101,14 +101,17 @@ get_new_macaddr() { ADDED_UNMANAGED=0 NETWORKMANAGER_CONF=/etc/NetworkManager/NetworkManager.conf +NM_OLDER_VERSION=1 networkmanager_is_running() { which nmcli > /dev/null 2>&1 || return 1 NM_VER=$(nmcli -v | grep -m1 -oE '[0-9]+(\.[0-9]+)*\.[0-9]+') version_cmp $NM_VER 0.9.10 if [[ $? -eq 1 ]]; then + NM_OLDER_VERSION=1 NMCLI_OUT=$(nmcli -t -f RUNNING nm) else + NM_OLDER_VERSION=0 NMCLI_OUT=$(nmcli -t -f RUNNING g) fi [[ "$NMCLI_OUT" == "running" ]] @@ -521,7 +524,21 @@ fi # start access point echo "hostapd command-line interface: hostapd_cli -p $CONFDIR/hostapd_ctrl" trap - SIGINT # reset trap -hostapd $CONFDIR/hostapd.conf || die "Failed to run hostapd, maybe a program is interfering." + +if ! hostapd $CONFDIR/hostapd.conf; then + echo -e "\nError: Failed to run hostapd, maybe a program is interfering." >&2 + if networkmanager_is_running; then + echo "If an error like 'n80211: Could not configure driver mode' was thrown" >&2 + echo "try running the following before starting create_ap:" >&2 + if [[ $NM_OLDER_VERSION -eq 1 ]]; then + echo " nmcli nm wifi off" >&2 + else + echo " nmcli r wifi off" >&2 + fi + echo " rfkill unblock wlan" >&2 + fi + die +fi cleanup exit 0