parameters
This commit is contained in:
parent
0740e16da0
commit
7ec3f4bd18
494
lnxrouter
494
lnxrouter
|
@ -99,6 +99,254 @@ usage() {
|
|||
echo " "$PROGNAME" --stop wlan0"
|
||||
}
|
||||
|
||||
if [[ "$1" == "" ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
GATEWAY=192.168.18.1
|
||||
ROUTE_ADDRS=
|
||||
DHCP_DNS=gateway
|
||||
dnsmasq_NO_DNS=0
|
||||
NO_DNSMASQ=0
|
||||
SHOW_DNS_QUERY=0
|
||||
ETC_HOSTS=0
|
||||
ADDN_HOSTS=
|
||||
SUBNET_IFACE=
|
||||
|
||||
ISOLATE_CLIENTS=0
|
||||
SHARE_METHOD=nat
|
||||
|
||||
NEW_MACADDR=
|
||||
OLD_MACADDR=
|
||||
DAEMONIZE=0
|
||||
|
||||
HIDDEN=0
|
||||
WIFI_IFACE=
|
||||
VWIFI_IFACE=
|
||||
AP_IFACE=
|
||||
CHANNEL=default
|
||||
WPA_VERSION=1+2
|
||||
MAC_FILTER=0
|
||||
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
|
||||
IEEE80211N=0
|
||||
IEEE80211AC=0
|
||||
HT_CAPAB='[HT40+]'
|
||||
VHT_CAPAB=
|
||||
DRIVER=nl80211
|
||||
NO_VIRT=0
|
||||
COUNTRY=
|
||||
FREQ_BAND=2.4
|
||||
NO_HAVEGED=0
|
||||
HAVEGED_WATCHDOG_PID=
|
||||
HOSTAPD_DEBUG_ARGS=
|
||||
USE_PSK=0
|
||||
FIX_UNMANAGED=0
|
||||
|
||||
LIST_RUNNING=0
|
||||
STOP_ID=
|
||||
LIST_CLIENTS_ID=
|
||||
CONFDIR=
|
||||
|
||||
ARGS=( "$@" )
|
||||
|
||||
while [[ -n "$1" ]]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--version)
|
||||
echo $VERSION
|
||||
exit 0
|
||||
;;
|
||||
-n)
|
||||
shift
|
||||
SHARE_METHOD=none
|
||||
;;
|
||||
-m)
|
||||
shift
|
||||
SHARE_METHOD="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
-g)
|
||||
shift
|
||||
GATEWAY="$1"
|
||||
shift
|
||||
;;
|
||||
--mac)
|
||||
shift
|
||||
NEW_MACADDR="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
--no-dnsmasq-dns)
|
||||
shift
|
||||
dnsmasq_NO_DNS=1
|
||||
;;
|
||||
--no-dnsmasq)
|
||||
shift
|
||||
NO_DNSMASQ=1
|
||||
;;
|
||||
--dhcp-dns)
|
||||
shift
|
||||
DHCP_DNS="$1"
|
||||
shift
|
||||
;;
|
||||
--log-dns)
|
||||
shift
|
||||
SHOW_DNS_QUERY=1
|
||||
;;
|
||||
-d)
|
||||
shift
|
||||
ETC_HOSTS=1
|
||||
;;
|
||||
-e)
|
||||
shift
|
||||
ADDN_HOSTS="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
--isolate-clients)
|
||||
shift
|
||||
ISOLATE_CLIENTS=1
|
||||
;;
|
||||
|
||||
--ap)
|
||||
shift
|
||||
WIFI_IFACE="$1"
|
||||
shift
|
||||
SSID="$1"
|
||||
shift
|
||||
;;
|
||||
--password)
|
||||
shift
|
||||
PASSPHRASE="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
--hidden)
|
||||
shift
|
||||
HIDDEN=1
|
||||
;;
|
||||
--mac-filter)
|
||||
shift
|
||||
MAC_FILTER=1
|
||||
;;
|
||||
--mac-filter-accept)
|
||||
shift
|
||||
MAC_FILTER_ACCEPT="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
-c)
|
||||
shift
|
||||
CHANNEL="$1"
|
||||
shift
|
||||
;;
|
||||
-w)
|
||||
shift
|
||||
WPA_VERSION="$1"
|
||||
[[ "$WPA_VERSION" == "2+1" ]] && WPA_VERSION=1+2
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
|
||||
--ieee80211n)
|
||||
shift
|
||||
IEEE80211N=1
|
||||
;;
|
||||
--ieee80211ac)
|
||||
shift
|
||||
IEEE80211AC=1
|
||||
;;
|
||||
--ht_capab)
|
||||
shift
|
||||
HT_CAPAB="$1"
|
||||
shift
|
||||
;;
|
||||
--vht_capab)
|
||||
shift
|
||||
VHT_CAPAB="$1"
|
||||
shift
|
||||
;;
|
||||
--driver)
|
||||
shift
|
||||
DRIVER="$1"
|
||||
shift
|
||||
;;
|
||||
--no-virt)
|
||||
shift
|
||||
NO_VIRT=1
|
||||
;;
|
||||
--fix-unmanaged)
|
||||
shift
|
||||
FIX_UNMANAGED=1
|
||||
;;
|
||||
--country)
|
||||
shift
|
||||
COUNTRY="$1"
|
||||
shift
|
||||
;;
|
||||
--freq-band)
|
||||
shift
|
||||
FREQ_BAND="$1"
|
||||
shift
|
||||
;;
|
||||
--no-haveged)
|
||||
shift
|
||||
NO_HAVEGED=1
|
||||
;;
|
||||
--hostapd-debug)
|
||||
shift
|
||||
if [ "x$1" = "x1" ]; then
|
||||
HOSTAPD_DEBUG_ARGS="-d"
|
||||
elif [ "x$1" = "x2" ]; then
|
||||
HOSTAPD_DEBUG_ARGS="-dd"
|
||||
else
|
||||
printf "Error: argument for --hostapd-debug expected 1 or 2, got %s\n" "$1"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--psk)
|
||||
shift
|
||||
USE_PSK=1
|
||||
;;
|
||||
|
||||
--daemon)
|
||||
shift
|
||||
DAEMONIZE=1
|
||||
;;
|
||||
--stop)
|
||||
shift
|
||||
STOP_ID="$1"
|
||||
shift
|
||||
;;
|
||||
--list-running)
|
||||
shift
|
||||
LIST_RUNNING=1
|
||||
;;
|
||||
--list-clients)
|
||||
shift
|
||||
LIST_CLIENTS_ID="$1"
|
||||
shift
|
||||
;;
|
||||
|
||||
|
||||
|
||||
*)
|
||||
echo "Invalid parameter: $1" 1>&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
# on success it echos a non-zero unused FD
|
||||
# on error it echos 0
|
||||
get_avail_fd() {
|
||||
|
@ -595,53 +843,7 @@ networkmanager_wait_until_unmanaged() {
|
|||
}
|
||||
|
||||
|
||||
CHANNEL=default
|
||||
GATEWAY=192.168.18.1
|
||||
WPA_VERSION=1+2
|
||||
ETC_HOSTS=0
|
||||
ADDN_HOSTS=
|
||||
DHCP_DNS=gateway
|
||||
dnsmasq_NO_DNS=0
|
||||
NO_DNSMASQ=0
|
||||
HIDDEN=0
|
||||
MAC_FILTER=0
|
||||
MAC_FILTER_ACCEPT=/etc/hostapd/hostapd.accept
|
||||
ISOLATE_CLIENTS=0
|
||||
SHARE_METHOD=nat
|
||||
IEEE80211N=0
|
||||
IEEE80211AC=0
|
||||
HT_CAPAB='[HT40+]'
|
||||
VHT_CAPAB=
|
||||
DRIVER=nl80211
|
||||
NO_VIRT=0
|
||||
COUNTRY=
|
||||
FREQ_BAND=2.4
|
||||
NEW_MACADDR=
|
||||
DAEMONIZE=0
|
||||
NO_HAVEGED=0
|
||||
USE_PSK=0
|
||||
|
||||
HOSTAPD_DEBUG_ARGS=
|
||||
|
||||
FIX_UNMANAGED=0
|
||||
LIST_RUNNING=0
|
||||
STOP_ID=
|
||||
LIST_CLIENTS_ID=
|
||||
|
||||
|
||||
CONFDIR=
|
||||
WIFI_IFACE=
|
||||
VWIFI_IFACE=
|
||||
AP_IFACE=
|
||||
OLD_MACADDR=
|
||||
IP_ADDRS=
|
||||
ROUTE_ADDRS=
|
||||
|
||||
SUBNET_IFACE=
|
||||
|
||||
HAVEGED_WATCHDOG_PID=
|
||||
|
||||
SHOW_DNS_QUERY=0
|
||||
|
||||
start_nat() {
|
||||
echo Setting iptables rules to NAT
|
||||
|
@ -918,206 +1120,6 @@ send_stop() {
|
|||
}
|
||||
|
||||
|
||||
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","ap","password" -n "$PROGNAME" -- "$@")
|
||||
#[[ $? -ne 0 ]] && exit 1
|
||||
#eval set -- "$GETOPT_ARGS"
|
||||
|
||||
|
||||
while [[ -n "$1" ]]; do
|
||||
case "$1" in
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
--version)
|
||||
echo $VERSION
|
||||
exit 0
|
||||
;;
|
||||
--hidden)
|
||||
shift
|
||||
HIDDEN=1
|
||||
;;
|
||||
--mac-filter)
|
||||
shift
|
||||
MAC_FILTER=1
|
||||
;;
|
||||
--mac-filter-accept)
|
||||
shift
|
||||
MAC_FILTER_ACCEPT="$1"
|
||||
shift
|
||||
;;
|
||||
--isolate-clients)
|
||||
shift
|
||||
ISOLATE_CLIENTS=1
|
||||
;;
|
||||
-c)
|
||||
shift
|
||||
CHANNEL="$1"
|
||||
shift
|
||||
;;
|
||||
-w)
|
||||
shift
|
||||
WPA_VERSION="$1"
|
||||
[[ "$WPA_VERSION" == "2+1" ]] && WPA_VERSION=1+2
|
||||
shift
|
||||
;;
|
||||
-g)
|
||||
shift
|
||||
GATEWAY="$1"
|
||||
shift
|
||||
;;
|
||||
-d)
|
||||
shift
|
||||
ETC_HOSTS=1
|
||||
;;
|
||||
-e)
|
||||
shift
|
||||
ADDN_HOSTS="$1"
|
||||
shift
|
||||
;;
|
||||
-n)
|
||||
shift
|
||||
SHARE_METHOD=none
|
||||
;;
|
||||
-m)
|
||||
shift
|
||||
SHARE_METHOD="$1"
|
||||
shift
|
||||
;;
|
||||
--ieee80211n)
|
||||
shift
|
||||
IEEE80211N=1
|
||||
;;
|
||||
--ieee80211ac)
|
||||
shift
|
||||
IEEE80211AC=1
|
||||
;;
|
||||
--ht_capab)
|
||||
shift
|
||||
HT_CAPAB="$1"
|
||||
shift
|
||||
;;
|
||||
--vht_capab)
|
||||
shift
|
||||
VHT_CAPAB="$1"
|
||||
shift
|
||||
;;
|
||||
--driver)
|
||||
shift
|
||||
DRIVER="$1"
|
||||
shift
|
||||
;;
|
||||
--no-virt)
|
||||
shift
|
||||
NO_VIRT=1
|
||||
;;
|
||||
--fix-unmanaged)
|
||||
shift
|
||||
FIX_UNMANAGED=1
|
||||
;;
|
||||
--country)
|
||||
shift
|
||||
COUNTRY="$1"
|
||||
shift
|
||||
;;
|
||||
--freq-band)
|
||||
shift
|
||||
FREQ_BAND="$1"
|
||||
shift
|
||||
;;
|
||||
--mac)
|
||||
shift
|
||||
NEW_MACADDR="$1"
|
||||
shift
|
||||
;;
|
||||
--dhcp-dns)
|
||||
shift
|
||||
DHCP_DNS="$1"
|
||||
shift
|
||||
;;
|
||||
--daemon)
|
||||
shift
|
||||
DAEMONIZE=1
|
||||
;;
|
||||
--stop)
|
||||
shift
|
||||
STOP_ID="$1"
|
||||
shift
|
||||
;;
|
||||
--list)
|
||||
shift
|
||||
LIST_RUNNING=1
|
||||
echo -e "WARN: --list is deprecated, use --list-running instead.\n" >&2
|
||||
;;
|
||||
--list-running)
|
||||
shift
|
||||
LIST_RUNNING=1
|
||||
;;
|
||||
--list-clients)
|
||||
shift
|
||||
LIST_CLIENTS_ID="$1"
|
||||
shift
|
||||
;;
|
||||
--no-haveged)
|
||||
shift
|
||||
NO_HAVEGED=1
|
||||
;;
|
||||
--psk)
|
||||
shift
|
||||
USE_PSK=1
|
||||
;;
|
||||
--no-dnsmasq-dns)
|
||||
shift
|
||||
dnsmasq_NO_DNS=1
|
||||
;;
|
||||
--no-dnsmasq)
|
||||
shift
|
||||
NO_DNSMASQ=1
|
||||
;;
|
||||
--hostapd-debug)
|
||||
shift
|
||||
if [ "x$1" = "x1" ]; then
|
||||
HOSTAPD_DEBUG_ARGS="-d"
|
||||
elif [ "x$1" = "x2" ]; then
|
||||
HOSTAPD_DEBUG_ARGS="-dd"
|
||||
else
|
||||
printf "Error: argument for --hostapd-debug expected 1 or 2, got %s\n" "$1"
|
||||
exit 1
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
--ap)
|
||||
shift
|
||||
WIFI_IFACE="$1"
|
||||
shift
|
||||
SSID="$1"
|
||||
shift
|
||||
;;
|
||||
--password)
|
||||
shift
|
||||
PASSPHRASE="$1"
|
||||
shift
|
||||
;;
|
||||
--log-dns)
|
||||
shift
|
||||
SHOW_DNS_QUERY=1
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
die "Invalid parameter: $1"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
|
||||
|
||||
trap "cleanup_lock" EXIT
|
||||
|
||||
if ! init_lock; then
|
||||
|
|
Loading…
Reference in New Issue