Add --fix-unmanaged option

This commit is contained in:
oblique 2014-10-09 20:52:39 +03:00
parent 9d7806882a
commit b49f48a4e2

View File

@ -39,6 +39,9 @@ usage() {
echo " --ht_capab <HT> HT capabilities (default: [HT40+])" echo " --ht_capab <HT> HT capabilities (default: [HT40+])"
echo " --driver Choose your WiFi adapter driver (default: nl80211)" echo " --driver Choose your WiFi adapter driver (default: nl80211)"
echo " --no-virt Do not create virtual interface" echo " --no-virt Do not create virtual interface"
echo " --fix-unmanaged If NetworkManager shows your interface as unmanaged after you"
echo " close create_ap, then use this option to switch your interface"
echo " back to managed"
echo echo
echo "Non-Bridging Options:" echo "Non-Bridging Options:"
echo " -g <gateway> IPv4 Gateway for the Access Point (default: 192.168.12.1)" echo " -g <gateway> IPv4 Gateway for the Access Point (default: 192.168.12.1)"
@ -344,6 +347,11 @@ networkmanager_rm_unmanaged() {
return 0 return 0
} }
networkmanager_fix_unmanaged() {
[[ -f ${NETWORKMANAGER_CONF} ]] || return
sed -e "/^unmanaged-devices=.*/d" -i ${NETWORKMANAGER_CONF}
}
networkmanager_rm_unmanaged_if_needed() { networkmanager_rm_unmanaged_if_needed() {
[[ $ADDED_UNMANAGED =~ .*\ ${1}\ .* ]] && networkmanager_rm_unmanaged $1 $2 [[ $ADDED_UNMANAGED =~ .*\ ${1}\ .* ]] && networkmanager_rm_unmanaged $1 $2
} }
@ -373,6 +381,7 @@ IEEE80211N=0
HT_CAPAB='[HT40+]' HT_CAPAB='[HT40+]'
DRIVER=nl80211 DRIVER=nl80211
NO_VIRT=0 NO_VIRT=0
FIX_UNMANAGED=0
CONFDIR= CONFDIR=
WIFI_IFACE= WIFI_IFACE=
@ -476,7 +485,7 @@ clean_exit() {
# if the user press ctrl+c then execute die() # if the user press ctrl+c then execute die()
trap "die" SIGINT trap "die" SIGINT
ARGS=$(getopt -o hc:w:g:dnm: -l "help","hidden","ieee80211n","ht_capab:","driver:","no-virt" -n $(basename $0) -- "$@") ARGS=$(getopt -o hc:w:g:dnm: -l "help","hidden","ieee80211n","ht_capab:","driver:","no-virt","fix-unmanaged" -n $(basename $0) -- "$@")
[[ $? -ne 0 ]] && exit 1 [[ $? -ne 0 ]] && exit 1
eval set -- "$ARGS" eval set -- "$ARGS"
@ -536,6 +545,10 @@ while :; do
shift shift
NO_VIRT=1 NO_VIRT=1
;; ;;
--fix-unmanaged)
shift
FIX_UNMANAGED=1
;;
--) --)
shift shift
break break
@ -543,7 +556,7 @@ while :; do
esac esac
done done
if [[ $# -lt 1 ]]; then if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 ]]; then
usage >&2 usage >&2
exit 1 exit 1
fi fi
@ -553,6 +566,11 @@ if [[ $(id -u) -ne 0 ]]; then
exit 1 exit 1
fi fi
if [[ $FIX_UNMANAGED -eq 1 ]]; then
networkmanager_fix_unmanaged
exit 0
fi
WIFI_IFACE=$1 WIFI_IFACE=$1
if ! is_wifi_interface ${WIFI_IFACE}; then if ! is_wifi_interface ${WIFI_IFACE}; then