create_ap

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

commit f143ddd5841b76c72360ec62ee61164969331761
parent dc6fe47389f991f9d9a914b5ec757b65d40a89ce
Author: Miroslav Koskar <miroslav@miroslavkoskar.com>
Date:   Fri Nov 15 20:07:27 +0100

Set SSID and PASSPHRASE values from standard input

- SSID is the first line
- PASSPHRASE is the second line

example: echo -e 'MyAccessPoint\nMyPassPhrase' | create_ap wlan0 eth0

Diffstat:
create_ap | 47+++++++++++++++++++++++++++++++++--------------
1 file changed, 33 insertions(+), 14 deletions(-)
diff --git a/create_ap b/create_ap @@ -25,6 +25,8 @@ usage() { echo "Examples:" echo " $(basename $0) wlan0 eth0 MyAccessPoint MyPassPhrase" echo " $(basename $0) -n wlan0 MyAccessPoint MyPassPhrase" + echo " echo -e 'MyAccessPoint\nMyPassPhrase' | $(basename $0) wlan0 eth0" + echo " echo -e 'MyAccessPoint\nMyPassPhrase' | $(basename $0) -n wlan0" } get_macaddr() { @@ -88,23 +90,40 @@ while :; do esac done -if [[ $SHARE_INTERNET -eq 1 ]]; then - if [[ $# -ne 3 && $# -ne 4 ]]; then - usage - exit 1 +if [[ $# -lt 1 ]]; then + usage + exit 1 +fi +WIFI_IFACE=$1 + +if tty -s; then + if [[ $SHARE_INTERNET -eq 1 ]]; then + if [[ $# -ne 3 && $# -ne 4 ]]; then + usage + exit 1 + fi + INTERNET_IFACE=$2 + SSID=$3 + PASSPHRASE=$4 + else + if [[ $# -ne 2 && $# -ne 3 ]]; then + usage + exit 1 + fi + SSID=$2 + PASSPHRASE=$3 fi - INTERNET_IFACE=$2 - SSID=$3 - PASSPHRASE=$4 else - if [[ $# -ne 2 && $# -ne 3 ]]; then - usage - exit 1 + if [[ $SHARE_INTERNET -eq 1 ]]; then + if [[ $# -ne 2 ]]; then + usage + exit 1 + fi + INTERNET_IFACE=$2 fi - SSID=$2 - PASSPHRASE=$3 + read SSID + read PASSPHRASE fi -WIFI_IFACE=$1 if [[ $(id -u) -ne 0 ]]; then echo "You must run it as root." @@ -133,7 +152,7 @@ if [[ -n "$PASSPHRASE" ]]; then [[ "$WPA_VERSION" == "1+2" || "$WPA_VERSION" == "2+1" ]] && WPA_VERSION=3 cat << EOF >> $CONFDIR/hostapd.conf wpa=${WPA_VERSION} -wpa_passphrase=$4 +wpa_passphrase=$PASSPHRASE wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP