Completely rewritten for command line flags

Help documentation for go.sh.

Basic usage: hostapd_manager.sh -s ssid -c chan -e pass

Command line switches are optional. The following switches are recognized.
-s  --Sets the SSID to ssid. "-s stratux"
-c  --Sets the channel to chan. "-c 1"
-e  --Turns on encryption with passphrase pass. 8-13 Printable Characters. Cannot be used with -o. "-e password!"
-o  --Turns off encryption and sets network to open. Cannot be used with -e.
-h  --Displays this help message. No further functions are performed.

Example: hostapd_manager.sh -s stratux -c 1 -e N3558D
pull/359/head
peepsnet 2016-04-01 15:00:51 -04:00
rodzic cb8a531710
commit 47bc631568
1 zmienionych plików z 231 dodań i 251 usunięć

Wyświetl plik

@ -1,289 +1,269 @@
#!/bin/bash
# Log in as root and copy this file then pass the
# desired ssid as a command line option, e.g.:
#
#
# bash hostapd_manager.sh 1 ssid chan passphrase
#
# bash hostapd_manager.sh 0 stratux-100 6 secret
#
######################################################################
#This is an example of using getopts in Bash. It also contains some
#other bits of code I find useful.
#Author: Linerd
#Website: http://tuxtweaks.com/
#Copyright 2014
#License: Creative Commons Attribution-ShareAlike 4.0
#http://creativecommons.org/licenses/by-sa/4.0/legalcode
######################################################################
#Set Script Name variable
SCRIPT=`basename ${BASH_SOURCE[0]}`
#Initialize variables to default values.
OPT_S=false
OPT_C=false
OPT_E=false
OPT_O=false
defaultPass="Squawk1200"
parm="*"
err="####"
att="+++"
#Set fonts for Help.
BOLD=$(tput bold)
STOT=$(tput smso)
UNDR=$(tput smul)
REV=$(tput rev)
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
MAGENTA=$(tput setaf 5)
WHITE=$(tput setaf 7)
NORM=$(tput sgr0)
NORMAL=$(tput sgr0)
function USAGE {
echo ""
echo "usage: $0 quiet ssid channel passphrase"
echo " quiet will the script output messages 1 = silent"
echo " ssid current or new SSID -required-"
echo " channel the channel you want the WIFI to operate on -required-"
echo " passphrase code to login to wifi. If not provided then security will be turned off"
echo ""
exit 1
#Help function
function HELP {
echo -e \\n"Help documentation for ${BOLD}${SCRIPT}.${NORM}"\\n
echo -e "${REV}Basic usage:${NORM} ${BOLD}$SCRIPT -s ssid -c chan -e pass ${NORM}"\\n
echo "Command line switches are optional. The following switches are recognized."
echo "${REV}-s${NORM} --Sets the SSID to ${BOLD}ssid${NORM}. \"-s stratux\""
echo "${REV}-c${NORM} --Sets the channel to ${BOLD}chan${NORM}. \"-c 1\""
echo "${REV}-e${NORM} --Turns on encryption with passphrase ${BOLD}pass${NORM}. 8-13 Printable Characters. Cannot be used with -o. \"-e password!\""
echo "${REV}-o${NORM} --Turns off encryption and sets network to open. Cannot be used with -e."
# echo "${REV}-q${NORM} --Run silently."
echo -e "${REV}-h${NORM} --Displays this help message. No further functions are performed."\\n
echo -e "Example: ${BOLD}$SCRIPT -s stratux -c 1 -e N3558D${NORM}"\\n
exit 1
}
clear
echo ""
echo "#### Stratux HOSTAPD Settings ####"
echo ""
#echo ${#4}
#### root user check
if [ $(whoami) != 'root' ]; then
if [ $1 != "1" ]; then
echo "${BOLD}${RED}This script must be executed as root, exiting...${WHITE}${NORMAL}"
echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}"
fi
exit
echo "${BOLD}${RED}This script must be executed as root, exiting...${WHITE}${NORMAL}"
echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}"
exit 1
fi
if [ $# -eq 0 ]; then
USAGE
exit
#Check the number of arguments. If none are passed, print help and exit.
NUMARGS=$#
if [ $NUMARGS -eq 0 ]; then
HELP
fi
#### ssid option check
####
SSID=
if [ "$2" = '' ]; then
if [ $1 != "1" ]; then
echo "${BOLD}${RED}Missing SSID option, exiting...${WHITE}${NORMAL}"
echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}"
fi
exit
else
SSID=ssid=$2
### Start getopts code ###
#Parse command line flags
#If an option should be followed by an argument, it should be followed by a ":".
#Notice there is no ":" after "oqh". The leading ":" suppresses error messages from
#getopts. This is required to get my unrecognized option code to work.
options=':s:c:e:oqh'
while getopts $options option; do
case $option in
s) #set option "s"
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
echo "${BOLD}${RED}$err No SSID for -s, exiting...${WHITE}${NORMAL}"
exit 1
else
OPT_S=$OPTARG
echo "$parm SSID Option -s used: $OPT_S"
echo "${GREEN} SSID will now be ${BOLD}${UNDR}$OPT_S${NORMAL}.${WHITE}"
fi
;;
c) #set option "c"
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
echo "${BOLD}${RED}$err Channel option(-c) used without value, exiting... ${WHITE}${NORMAL}"
exit 1
else
OPT_C=$OPTARG
echo "$parm Channel option -c used: $OPT_C"
if [[ "$OPT_C" =~ ^[0-9]+$ ]] && [ "$OPT_C" -ge 1 -a "$OPT_C" -le 13 ]; then
echo "${GREEN} Channel will now be set to ${BOLD}${UNDR}$OPT_C.${WHITE}${NORMAL}"
else
echo "${BOLD}${RED}$err Channel is not within acceptable values, exiting...${WHITE}${NORMAL}"
exit 1
fi
fi
;;
e) #set option "e"
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
echo "${BOLD}${RED}$err Encryption option(-e) used without passphrase, exiting...${WHITE}${NORMAL}"
exit 1
else
OPT_E=$OPTARG
echo "$parm Encryption option -e used:"
if [ -z `echo $OPT_E | tr -d "[:print:]"` ] && [ ${#OPT_E} -ge 8 ] && [ ${#OPT_E} -le 63 ]; then
echo "${GREEN} Passphrase will now be ${BOLD}${UNDR}$OPT_E${NORMAL}.${WHITE}${NORMAL}"
else
echo "${BOLD}${RED}$err Invalid PASSWORD: 8 - 63 printable characters, exiting...${WHITE}${NORMAL}"
exit
fi
fi
;;
o) #set option "o"
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
echo "$parm Open WiFI Option -o used."
echo "${GREEN} WiFi will be set to ${BOLD}${UNDR}OPEN${NORMAL}${GREEN} or ${BOLD}${UNDR}UNSECURE${WHITE}${NORMAL}"
OPT_O=true
else
echo "${BOLD}${RED}$err Option -o does not require arguement.${WHITE}${NORMAL}"
exit 1
fi
;;
h) #show help
HELP
;;
\?) # invalid option
echo "${BOLD}${RED}$err Invalid option -$OPTARG" >&2
exit 1
;;
:) # Missing Arg
echo "${BOLD}${RED}$err Missing option for argument -$OPTARG ${WHITE}${NORMAL}" >&2
exit 1
;;
*) # Invalid
echo "${BOLD}${RED}$err Unimplemented option -$OPTARG ${WHITE}${NORMAL}" >&2
exit 1
;;
esac
done
shift $((OPTIND-1)) #This tells getopts to move on to the next argument.
### End getopts code ###
### Main loop to process files ###
#This is where your main file processing will take place. This example is just
#printing the files and extensions to the terminal. You should place any other
#file processing tasks within the while-do loop.
if [ $OPT_O = true ] && [ $OPT_E != false ]; then
echo "${BOLD}${RED}$err Option -e and -o cannot be used simultaneously ${WHITE}${NORMAL}"
exit 1
fi
#### channel option check
####
CHAN=
if [[ "$3" =~ ^[0-9]+$ ]] && [ "$3" -ge 1 -a "$3" -le 13 ]; then
CHAN=channel=$3
else
if [ $1 != "1" ]; then
echo "${BOLD}${RED}Incorrect CHANNEL $3 not valid (number from 1 to 13), exiting...${WHITE}${NORMAL}"
echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}"
fi
exit
fi
echo ""
echo "${BOLD}No errors found. Continuning...${NORMAL}"
echo ""
#### encription option check
####
PASS=
if [ ! -z "$4" ]; then
if [ -z `echo $4 | tr -d "[:print:]"` ] && [ ${#4} -ge 8 ] && [ ${#4} -le 63 ]; then
PASS=wpa_passphrase=$4
else
if [ $1 != "1" ]; then
echo "${BOLD}${RED}Invalid PASSWORD: 8 - 63 printable characters, exiting...${WHITE}${NORMAL}"
echo "${BOLD}${RED}USAGE${WHITE}${NORMAL}"
fi
exit
fi
fi
STATUS=
HOSTAPD=/etc/hostapd/hostapd.conf
HOSTAPDEDIMAX=/etc/hostapd/hostapd-edimax.conf
# files to edit
HOSTAPD=('/etc/hostapd/hostapd.conf' '/etc/hostapd/hostapd-edimax.conf')
####
#### /etc/hostapd/hostapd.conf
#### File modification loop
####
if [ -f "$HOSTAPD" ]; then
if [ $1 != "1" ]; then
echo "${MAGENTA}Setting ${YELLOW}SSID${MAGENTA} to ${YELLOW}$2 ${MAGENTA}in $HOSTAPD...${WHITE}"
fi
if grep -q "^ssid=" ${HOSTAPD}; then
sed -i "s/^ssid=.*/${SSID}/" ${HOSTAPD}
else
echo ${SSID} >> ${HOSTAPD}
for i in "${HOSTAPD[@]}"
do
if [ -f ${i} ]; then
echo "Working on $i..."
if [ $OPT_S != false ]; then
echo "${MAGENTA}Setting ${YELLOW}SSID${MAGENTA} to ${YELLOW}$OPT_S ${MAGENTA}in $i...${WHITE}"
if grep -q "^ssid=" ${HOSTAPD[$x]}; then
sed -i "s/^ssid=.*/ssid=${OPT_S}/" ${i}
else
echo ${OPT_S} >> ${i}
fi
fi
if [ $1 != "1" ]; then
echo "${MAGENTA}Setting Channel to ${YELLOW}$3 ${MAGENTA}in $HOSTAPD...${WHITE}"
fi
if grep -q "^channel=" ${HOSTAPD}; then
sed -i "s/^channel=.*/${CHAN}/" ${HOSTAPD}
else
echo ${CHAN} >> ${HOSTAPD}
fi
if [ ! -z "$4" ]; then
if [ $1 != "1" ]; then
echo "${MAGENTA}Adding WPA encryption with passphrase: ${YELLOW}$4 ${MAGENTA}to $HOSTAPD...${WHITE}"
if [ $OPT_C != false ]; then
echo "${MAGENTA}Setting ${YELLOW}Channel${MAGENTA} to ${YELLOW}$OPT_C ${MAGENTA}in $i...${WHITE}"
if grep -q "^channel=" ${i}; then
sed -i "s/^channel=.*/channel=${OPT_C}/" ${i}
else
echo ${OPT_C} >> ${i}
fi
if grep -q "^#auth_algs=" ${HOSTAPD}; then
fi
if [ $OPT_E != false ]; then
echo "${MAGENTA}Adding WPA encryption with passphrase: ${YELLOW}$OPT_E ${MAGENTA}to $i...${WHITE}"
if grep -q "^#auth_algs=" ${i}; then
#echo "uncomenting wpa"
sed -i "s/^#auth_algs=.*/auth_algs=1/" ${HOSTAPD}
sed -i "s/^#wpa=.*/wpa=3/" ${HOSTAPD}
sed -i "s/^#wpa_passphrase=.*/wpa_passphrase=$4/" ${HOSTAPD}
sed -i "s/^#wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^#wpa_pairwise=.*/wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^#rsn_pairwise=.*/rsn_pairwise=CCMP/" ${HOSTAPD}
elif grep -q "^auth_algs=" ${HOSTAPD}; then
sed -i "s/^#auth_algs=.*/auth_algs=1/" ${i}
sed -i "s/^#wpa=.*/wpa=3/" ${i}
sed -i "s/^#wpa_passphrase=.*/wpa_passphrase=$OPT_E/" ${i}
sed -i "s/^#wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${i}
sed -i "s/^#wpa_pairwise=.*/wpa_pairwise=TKIP/" ${i}
sed -i "s/^#rsn_pairwise=.*/rsn_pairwise=CCMP/" ${i}
elif grep -q "^auth_algs=" ${i}; then
#echo "rewriting existing wpa"
sed -i "s/^auth_algs=.*/auth_algs=1/" ${HOSTAPD}
sed -i "s/^wpa=.*/wpa=3/" ${HOSTAPD}
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$4/" ${HOSTAPD}
sed -i "s/^wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^wpa_pairwise=.*/wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^rsn_pairwise=.*/rsn_pairwise=CCMP/" ${HOSTAPD}
sed -i "s/^auth_algs=.*/auth_algs=1/" ${i}
sed -i "s/^wpa=.*/wpa=3/" ${i}
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$OPT_E/" ${i}
sed -i "s/^wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${i}
sed -i "s/^wpa_pairwise=.*/wpa_pairwise=TKIP/" ${i}
sed -i "s/^rsn_pairwise=.*/rsn_pairwise=CCMP/" ${i}
else
#echo "adding wpa"
echo "" >> ${HOSTAPD}
echo "auth_algs=1" >> ${HOSTAPD}
echo "wpa=3" >> ${HOSTAPD}
echo "wpa_passphrase=$4" >> ${HOSTAPD}
echo "wpa_key_mgmt=WPA-PSK" >> ${HOSTAPD}
echo "wpa_pairwise=TKIP" >> ${HOSTAPD}
echo "rsn_pairwise=CCMP" >> ${HOSTAPD}
echo "" >> ${i}
echo "auth_algs=1" >> ${i}
echo "wpa=3" >> ${i}
echo "wpa_passphrase=$OPT_E" >> ${i}
echo "wpa_key_mgmt=WPA-PSK" >> ${i}
echo "wpa_pairwise=TKIP" >> ${i}
echo "rsn_pairwise=CCMP" >> ${i}
fi
else
if [ $1 != "1" ]; then
echo "${MAGENTA}Removing WPA encryption in $HOSTAPD...${WHITE}"
fi
if grep -q "^auth_algs=" ${HOSTAPD}; then
fi
if [ $OPT_O != false ]; then
echo "${MAGENTA}Removing WPA encryption in $i...${WHITE}"
if grep -q "^auth_algs=" ${i}; then
#echo "comenting out wpa"
sed -i "s/^auth_algs=.*/#auth_algs=1/" ${HOSTAPD}
sed -i "s/^wpa=.*/#wpa=3/" ${HOSTAPD}
sed -i "s/^wpa_passphrase=.*/#wpa_passphrase=Clearedfortakeoff/" ${HOSTAPD}
sed -i "s/^wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${HOSTAPD}
elif grep -q "^#auth_algs=" ${HOSTAPD}; then
sed -i "s/^auth_algs=.*/#auth_algs=1/" ${i}
sed -i "s/^wpa=.*/#wpa=3/" ${i}
sed -i "s/^wpa_passphrase=.*/#wpa_passphrase=$defaultPass/" ${i}
sed -i "s/^wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${i}
sed -i "s/^wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${i}
sed -i "s/^rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${i}
elif grep -q "^#auth_algs=" ${i}; then
#echo "rewriting comentied out wpa"
sed -i "s/^#auth_algs=.*/#auth_algs=1/" ${HOSTAPD}
sed -i "s/^#wpa=.*/#wpa=3/" ${HOSTAPD}
sed -i "s/^#wpa_passphrase=.*/#wpa_passphrase=Clearedfortakeoff/" ${HOSTAPD}
sed -i "s/^#wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^#wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^#rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${HOSTAPD}
sed -i "s/^#auth_algs=.*/#auth_algs=1/" ${i}
sed -i "s/^#wpa=.*/#wpa=3/" ${i}
sed -i "s/^#wpa_passphrase=.*/#wpa_passphrase=$defaultPass/" ${i}
sed -i "s/^#wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${i}
sed -i "s/^#wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${i}
sed -i "s/^#rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${i}
else
#echo "adding commented out WPA"
echo "" >> ${HOSTAPD}
echo "#auth_algs=1" >> ${HOSTAPD}
echo "#wpa=3" >> ${HOSTAPD}
echo "#wpa_passphrase=Clearedfortakeoff" >> ${HOSTAPD}
echo "#wpa_key_mgmt=WPA-PSK" >> ${HOSTAPD}
echo "#wpa_pairwise=TKIP" >> ${HOSTAPD}
echo "#rsn_pairwise=CCMP" >> ${HOSTAPD}
echo "" >> ${i}
echo "#auth_algs=1" >> ${i}
echo "#wpa=3" >> ${i}
echo "#wpa_passphrase=$defaultPass" >> ${i}
echo "#wpa_key_mgmt=WPA-PSK" >> ${i}
echo "#wpa_pairwise=TKIP" >> ${i}
echo "#rsn_pairwise=CCMP" >> ${i}
fi
fi
if [ $1 != "1" ]; then
echo "${GREEN}...done${WHITE}"
fi
STATUS="${YELLOW}Don't forget to reboot...${WHITE}"
else
if [ $1 != "1" ]; then
echo "${MAGENTA}${RED}No ${HOSTAPD} file found...${WHITE}${NORMAL}"
fi
fi
echo "${GREEN}Modified ${i}...done${WHITE}"
echo ""
else
echo "${MAGENTA}No ${i} file found...${WHITE}${NORMAL}"
echo ""
fi
done
echo "${YELLOW}$att Don't forget to reboot... $att ${WHITE}"
echo ""
echo ""
####
#### /etc/hostapd/hostapd-edimax.conf
####
if [ -f "$HOSTAPDEDIMAX" ]; then
if [ $1 != "1" ]; then
echo "${MAGENTA}Setting ${YELLOW}SSID ${MAGENTA}to ${YELLOW}$2 ${MAGENTA}in $HOSTAPD...${WHITE}"
fi
### End main loop ###
if grep -q "^ssid=" "${HOSTAPDEDIMAX}"; then
sed -i "s/^ssid=.*/${SSID}/" ${HOSTAPDEDIMAX}
else
echo ${SSID} >> ${HOSTAPDEDIMAX}
fi
if [ $1 != "1" ]; then
echo "${MAGENTA}Setting Channel to ${YELLOW}$3 ${MAGENTA}in $HOSTAPD...${WHITE}"
fi
if grep -q "^channel=" ${HOSTAPD}; then
sed -i "s/^channel=.*/${CHAN}/" ${HOSTAPD}
else
echo ${CHAN} >> ${HOSTAPD}
fi
if [ ! -z "$4" ]; then
if [ $1 != "1" ]; then
echo "${MAGENTA}Adding WPA encryption with passphrase: ${YELLOW}$4 ${MAGENTA}to $HOSTAPD...${WHITE}"
fi
if grep -q "^#auth_algs=" ${HOSTAPD}; then
#echo "uncomenting wpa"
sed -i "s/^#auth_algs=.*/auth_algs=1/" ${HOSTAPD}
sed -i "s/^#wpa=.*/wpa=3/" ${HOSTAPD}
sed -i "s/^#wpa_passphrase=.*/wpa_passphrase=$4/" ${HOSTAPD}
sed -i "s/^#wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^#wpa_pairwise=.*/wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^#rsn_pairwise=.*/rsn_pairwise=CCMP/" ${HOSTAPD}
elif grep -q "^auth_algs=" ${HOSTAPD}; then
#echo "rewriting existing wpa"
sed -i "s/^auth_algs=.*/auth_algs=1/" ${HOSTAPD}
sed -i "s/^wpa=.*/wpa=3/" ${HOSTAPD}
sed -i "s/^wpa_passphrase=.*/wpa_passphrase=$4/" ${HOSTAPD}
sed -i "s/^wpa_key_mgmt=.*/wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^wpa_pairwise=.*/wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^rsn_pairwise=.*/rsn_pairwise=CCMP/" ${HOSTAPD}
else
#echo "adding wpa"
echo "" >> ${HOSTAPD}
echo "auth_algs=1" >> ${HOSTAPD}
echo "wpa=3" >> ${HOSTAPD}
echo "wpa_passphrase=$4" >> ${HOSTAPD}
echo "wpa_key_mgmt=WPA-PSK" >> ${HOSTAPD}
echo "wpa_pairwise=TKIP" >> ${HOSTAPD}
echo "rsn_pairwise=CCMP" >> ${HOSTAPD}
fi
else
if [ $1 != "1" ]; then
echo "${MAGENTA}Removing WPA encryption in $HOSTAPD...${WHITE}"
fi
if grep -q "^auth_algs=" ${HOSTAPD}; then
#echo "comenting out wpa"
sed -i "s/^auth_algs=.*/#auth_algs=1/" ${HOSTAPD}
sed -i "s/^wpa=.*/#wpa=3/" ${HOSTAPD}
sed -i "s/^wpa_passphrase=.*/#wpa_passphrase=Clearedfortakeoff/" ${HOSTAPD}
sed -i "s/^wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${HOSTAPD}
elif grep -q "^#auth_algs=" ${HOSTAPD}; then
#echo "rewriting comentied out wpa"
sed -i "s/^#auth_algs=.*/#auth_algs=1/" ${HOSTAPD}
sed -i "s/^#wpa=.*/#wpa=3/" ${HOSTAPD}
sed -i "s/^#wpa_passphrase=.*/#wpa_passphrase=Clearedfortakeoff/" ${HOSTAPD}
sed -i "s/^#wpa_key_mgmt=.*/#wpa_key_mgmt=WPA-PSK/" ${HOSTAPD}
sed -i "s/^#wpa_pairwise=.*/#wpa_pairwise=TKIP/" ${HOSTAPD}
sed -i "s/^#rsn_pairwise=.*/#rsn_pairwise=CCMP/" ${HOSTAPD}
else
#echo "adding commented out WPA"
echo "" >> ${HOSTAPD}
echo "#auth_algs=1" >> ${HOSTAPD}
echo "#wpa=3" >> ${HOSTAPD}
echo "#wpa_passphrase=Clearedfortakeoff" >> ${HOSTAPD}
echo "#wpa_key_mgmt=WPA-PSK" >> ${HOSTAPD}
echo "#wpa_pairwise=TKIP" >> ${HOSTAPD}
echo "#rsn_pairwise=CCMP" >> ${HOSTAPD}
fi
fi
if [ $1 != "1" ]; then
echo "${GREEN}...done${WHITE}"
fi
STATUS="${YELLOW}Don't forget to reboot...${WHITE}"
else
if [ $1 != "1" ]; then
echo "${MAGENTA}${RED}No ${HOSTAPDEDIMAX} found...${WHITE}${NORMAL}"
fi
fi
if [ $1 != "1" ]; then
echo
echo $STATUS
echo
fi
exit 0