create_ap

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

commit ed7d3f36f936862da3f511288cec83b163af48a2
parent 709652041ffd6eeec67c98412a577f08b603298b
Author: oblique <psyberbits@gmail.com>
Date:   Mon Jul 28 19:24:02 +0300

Use 'nmcli' to determine if NetworkManager switched adapter to unmanaged

Fix #29

Diffstat:
create_ap | 22+++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/create_ap b/create_ap @@ -80,8 +80,18 @@ get_new_macaddr() { ADDED_UNMANAGED=0 NETWORKMANAGER_CONF=/etc/NetworkManager/NetworkManager.conf +networkmanager_is_running() { + which nmcli > /dev/null 2>&1 || return 1 + nmcli nm | grep -E '^running' > /dev/null 2>&1 +} + +networkmanager_iface_is_unmanaged() { + nmcli dev status | grep -E "$1.+unmanaged" > /dev/null 2>&1 +} + networkmanager_add_unmanaged() { - [[ ! -d ${NETWORKMANAGER_CONF%/*} ]] && return + networkmanager_is_running || return + [[ -d ${NETWORKMANAGER_CONF%/*} ]] || mkdir -p ${NETWORKMANAGER_CONF%/*} [[ -f ${NETWORKMANAGER_CONF} ]] || touch ${NETWORKMANAGER_CONF} if [[ -z "$2" ]]; then MAC=$(get_macaddr "$1") @@ -99,7 +109,10 @@ networkmanager_add_unmanaged() { sed -e "s/^${UNMANAGED}/${NEW_UNMANAGED}/" -i ${NETWORKMANAGER_CONF} fi ADDED_UNMANAGED=1 - sleep 2 + while ! networkmanager_iface_is_unmanaged "$1"; do + sleep 1 + done + sleep 1 echo "DONE" } @@ -118,7 +131,10 @@ networkmanager_rm_unmanaged() { NEW_UNMANAGED=$(echo ${UNMANAGED} | sed -e "s/;mac:${MAC}//") sed -e "s/^${UNMANAGED}/${NEW_UNMANAGED}/" -i ${NETWORKMANAGER_CONF} fi - sleep 2 + while networkmanager_iface_is_unmanaged "$1"; do + sleep 1 + done + sleep 1 } CHANNEL=1