--ap and --password

This commit is contained in:
garywill 2018-08-31 18:41:06 +08:00 committed by garywill
parent 9cd59d3975
commit ad1b0e473f
1 changed files with 29 additions and 24 deletions

View File

@ -25,7 +25,7 @@ SCRIPT_UMASK=0077
umask $SCRIPT_UMASK umask $SCRIPT_UMASK
usage() { usage() {
echo "Usage: "$PROGNAME" [options] <wifi-interface> <access-point-name> [<passphrase>]" echo "Usage: "$PROGNAME" [options] "
echo echo
echo "Options:" echo "Options:"
echo " -h, --help Show this help" echo " -h, --help Show this help"
@ -36,6 +36,9 @@ usage() {
echo " -m <method> Method for Internet sharing." echo " -m <method> Method for Internet sharing."
echo " Use: 'nat' for NAT (default)" echo " Use: 'nat' for NAT (default)"
echo " 'none' for no Internet sharing (equivalent to -n)" echo " 'none' for no Internet sharing (equivalent to -n)"
echo " --ap <wifi-interface> <access-point-name>"
echo " Create Wifi access point"
echo " --password <passphrase> Wifi password"
echo " --psk Use 64 hex digits pre-shared-key instead of passphrase" echo " --psk Use 64 hex digits pre-shared-key instead of passphrase"
echo " --hidden Make the Access Point hidden (do not broadcast the SSID)" echo " --hidden Make the Access Point hidden (do not broadcast the SSID)"
echo " --mac-filter Enable MAC address filtering" echo " --mac-filter Enable MAC address filtering"
@ -76,11 +79,11 @@ usage() {
echo " interface you are getting your Internet connection." echo " interface you are getting your Internet connection."
echo echo
echo "Examples:" echo "Examples:"
echo " "$PROGNAME" wlan0 MyAccessPoint MyPassPhrase" echo " "$PROGNAME" --ap wlan0 MyAccessPoint --password MyPassPhrase"
echo " "$PROGNAME" wlan0 MyAccessPoint" echo " "$PROGNAME" --ap wlan0 MyAccessPoint"
echo " "$PROGNAME" -n wlan0 MyAccessPoint MyPassPhrase" echo " "$PROGNAME" -n --ap wlan0 MyAccessPoint --password MyPassPhrase"
echo " "$PROGNAME" --driver rtl871xdrv wlan0 MyAccessPoint MyPassPhrase" echo " "$PROGNAME" --driver rtl871xdrv --ap wlan0 MyAccessPoint --password MyPassPhrase"
echo " "$PROGNAME" --daemon wlan0 MyAccessPoint MyPassPhrase" echo " "$PROGNAME" --daemon --ap wlan0 MyAccessPoint --password MyPassPhrase"
echo " "$PROGNAME" --stop wlan0" echo " "$PROGNAME" --stop wlan0"
} }
@ -910,11 +913,12 @@ send_stop() {
ARGS=( "$@" ) ARGS=( "$@" )
GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq" -n "$PROGNAME" -- "$@") #GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","ap","password" -n "$PROGNAME" -- "$@")
[[ $? -ne 0 ]] && exit 1 #[[ $? -ne 0 ]] && exit 1
eval set -- "$GETOPT_ARGS" #eval set -- "$GETOPT_ARGS"
while :; do
while [[ -n "$1" ]]; do
case "$1" in case "$1" in
-h|--help) -h|--help)
usage usage
@ -1077,6 +1081,21 @@ while :; do
fi fi
shift shift
;; ;;
--ap)
shift
WIFI_IFACE="$1"
echo wifi_iface is $WIFI_IFACE
shift
SSID="$1"
echo ssid is $SSID
shift
;;
--password)
shift
PASSPHRASE="$1"
echo password is $PASSPHRASE
shift
;;
--) --)
shift shift
break break
@ -1085,12 +1104,6 @@ while :; do
done done
# Check if required number of positional args are present
if [[ $# -lt 1 && $FIX_UNMANAGED -eq 0 && -z "$STOP_ID" &&
$LIST_RUNNING -eq 0 && -z "$LIST_CLIENTS_ID" ]]; then
usage >&2
exit 1
fi
# Set NO_DNS, if dnsmasq is disabled # Set NO_DNS, if dnsmasq is disabled
if [[ $NO_DNSMASQ -eq 1 ]]; then if [[ $NO_DNSMASQ -eq 1 ]]; then
@ -1164,7 +1177,6 @@ if [[ $FREQ_BAND != 5 && $CHANNEL -gt 14 ]]; then
FREQ_BAND=5 FREQ_BAND=5
fi fi
WIFI_IFACE=$1
if ! is_wifi_interface ${WIFI_IFACE}; then if ! is_wifi_interface ${WIFI_IFACE}; then
echo "ERROR: '${WIFI_IFACE}' is not a WiFi interface" >&2 echo "ERROR: '${WIFI_IFACE}' is not a WiFi interface" >&2
@ -1228,13 +1240,6 @@ if [[ -n "$NEW_MACADDR" ]]; then
fi fi
fi fi
if [[ $# -ne 2 && $# -ne 3 ]]; then
usage >&2
exit 1
fi
SSID="$2"
PASSPHRASE="$3"
if [[ ${#SSID} -lt 1 || ${#SSID} -gt 32 ]]; then if [[ ${#SSID} -lt 1 || ${#SSID} -gt 32 ]]; then