kopia lustrzana https://github.com/cyoung/stratux
Merge pull request #529 from peepsnet/master
Move user configurable options out of hostapd.conf and hostapd-edimax.conf to hostapd.user and build temp hoatapd.conf on the fly with stratux-wifi.shpull/549/head
commit
de93c79a07
|
@ -15,3 +15,39 @@ if [ -e /root/update*stratux*v*.sh ] ; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
##### Script for setting up new file structure for hostapd settings
|
||||||
|
##### Look for hostapd.user and if found do nothing.
|
||||||
|
##### If not assume because of previous version and convert to new file structure
|
||||||
|
DAEMON_USER_PREF=/etc/hostapd/hostapd.user
|
||||||
|
if [ ! -f $DAEMON_USER_PREF ]; then
|
||||||
|
DAEMON_CONF=/etc/hostapd/hostapd.conf
|
||||||
|
DAEMON_CONF_EDIMAX=/etc/hostapd/hostapd-edimax.conf
|
||||||
|
HOSTAPD_VALUES=('ssid=' 'channel=' 'auth_algs=' 'wpa=' 'wpa_passphrase=' 'wpa_key_mgmt=' 'wpa_pairwise=' 'rsn_pairwise=')
|
||||||
|
HOSTAPD_VALUES_RM=('#auth_algs=' '#wpa=' '#wpa_passphrase=' '#wpa_key_mgmt=' '#wpa_pairwise=' '#rsn_pairwise=')
|
||||||
|
|
||||||
|
for i in "${HOSTAPD_VALUES[@]}"
|
||||||
|
do
|
||||||
|
if grep -q "^$i" $DAEMON_CONF
|
||||||
|
then
|
||||||
|
grep "^$i" $DAEMON_CONF >> $DAEMON_USER_PREF
|
||||||
|
sed -i '/^'"$i"'/d' $DAEMON_CONF
|
||||||
|
sed -i '/^'"$i"'/d' $DAEMON_CONF_EDIMAX
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
for i in "${HOSTAPD_VALUES_RM[@]}"
|
||||||
|
do
|
||||||
|
if grep -q "^$i" $DAEMON_CONF
|
||||||
|
then
|
||||||
|
sed -i '/^'"$i"'/d' $DAEMON_CONF
|
||||||
|
sed -i '/^'"$i"'/d' $DAEMON_CONF_EDIMAX
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
sleep 1 #make sure there is time to get the file written before checking for it again
|
||||||
|
# If once the code above runs and there is still no hostapd.user file then something is wrong and we will just create the file with basic settings.
|
||||||
|
# Any more then this they somebody was messing with things and its not our fault things are this bad
|
||||||
|
if [ ! -f $DAEMON_USER_PREF ]; then
|
||||||
|
echo "ssid=stratux" >> $DAEMON_USER_PREF
|
||||||
|
echo "channel=1" >> $DAEMON_USER_PREF
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
##### End hostapd settings structure script
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
interface=wlan0
|
interface=wlan0
|
||||||
driver=rtl871xdrv
|
driver=rtl871xdrv
|
||||||
ssid=stratux
|
|
||||||
hw_mode=g
|
hw_mode=g
|
||||||
channel=1
|
|
||||||
wme_enabled=1
|
wme_enabled=1
|
||||||
ieee80211n=1
|
ieee80211n=1
|
||||||
ignore_broadcast_ssid=0
|
ignore_broadcast_ssid=0
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
interface=wlan0
|
interface=wlan0
|
||||||
ssid=stratux
|
|
||||||
hw_mode=g
|
hw_mode=g
|
||||||
channel=1
|
|
||||||
wmm_enabled=1
|
wmm_enabled=1
|
||||||
ieee80211n=1
|
ieee80211n=1
|
||||||
ignore_broadcast_ssid=0
|
ignore_broadcast_ssid=0
|
||||||
|
|
|
@ -69,7 +69,7 @@ fi
|
||||||
#If an option should be followed by an argument, it should be followed by a ":".
|
#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
|
#Notice there is no ":" after "oqh". The leading ":" suppresses error messages from
|
||||||
#getopts. This is required to get my unrecognized option code to work.
|
#getopts. This is required to get my unrecognized option code to work.
|
||||||
options=':s:c:e:oqh'
|
options=':s:c:eoqh'
|
||||||
while getopts $options option; do
|
while getopts $options option; do
|
||||||
case $option in
|
case $option in
|
||||||
s) #set option "s"
|
s) #set option "s"
|
||||||
|
@ -90,7 +90,7 @@ while getopts $options option; do
|
||||||
OPT_C=$OPTARG
|
OPT_C=$OPTARG
|
||||||
echo "$parm Channel option -c used: $OPT_C"
|
echo "$parm Channel option -c used: $OPT_C"
|
||||||
if [[ "$OPT_C" =~ ^[0-9]+$ ]] && [ "$OPT_C" -ge 1 -a "$OPT_C" -le 13 ]; then
|
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}"
|
echo "${GREEN} Channel will now be set to ${BOLD}${UNDR}$OPT_C${WHITE}${NORMAL}."
|
||||||
else
|
else
|
||||||
echo "${BOLD}${RED}$err Channel is not within acceptable values, exiting...${WHITE}${NORMAL}"
|
echo "${BOLD}${RED}$err Channel is not within acceptable values, exiting...${WHITE}${NORMAL}"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -99,8 +99,8 @@ while getopts $options option; do
|
||||||
;;
|
;;
|
||||||
e) #set option "e"
|
e) #set option "e"
|
||||||
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
|
if [[ -z "${OPTARG}" || "${OPTARG}" == *[[:space:]]* || "${OPTARG}" == -* ]]; then
|
||||||
echo "${BOLD}${RED}$err Encryption option(-e) used without passphrase, exiting...${WHITE}${NORMAL}"
|
echo "${BOLD}${RED}$err Encryption option(-e) used without passphrase, Passphrase will be set to ${BOLD}$defaultPass${NORMAL}...${WHITE}${NORMAL}"
|
||||||
exit 1
|
OPT_E=$defaultPass
|
||||||
else
|
else
|
||||||
OPT_E=$OPTARG
|
OPT_E=$OPTARG
|
||||||
echo "$parm Encryption option -e used:"
|
echo "$parm Encryption option -e used:"
|
||||||
|
@ -126,7 +126,7 @@ while getopts $options option; do
|
||||||
HELP
|
HELP
|
||||||
;;
|
;;
|
||||||
\?) # invalid option
|
\?) # invalid option
|
||||||
echo "${BOLD}${RED}$err Invalid option -$OPTARG" >&2
|
echo "${BOLD}${RED}$err Invalid option -$OPTARG ${WHITE}${NORMAL}" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
:) # Missing Arg
|
:) # Missing Arg
|
||||||
|
@ -161,7 +161,7 @@ echo "${BOLD}No errors found. Continuning...${NORMAL}"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
# files to edit
|
# files to edit
|
||||||
HOSTAPD=('/etc/hostapd/hostapd.conf' '/etc/hostapd/hostapd-edimax.conf')
|
HOSTAPD=('/etc/hostapd/hostapd.user')
|
||||||
|
|
||||||
####
|
####
|
||||||
#### File modification loop
|
#### File modification loop
|
||||||
|
@ -254,9 +254,31 @@ do
|
||||||
echo ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "${YELLOW}$att Don't forget to reboot... $att ${WHITE}"
|
echo "${RED}${BOLD} $att At this time the script will restart your WiFi services.${WHITE}${NORMAL}"
|
||||||
|
echo "If you are connected to Stratux through the ${BOLD}192.168.10.1${NORMAL} interface then you will be disconnected"
|
||||||
|
echo "Please wait 1 min and look for the new SSID on your wireless device."
|
||||||
|
sleep 3
|
||||||
|
echo "${YELLOW}$att Restarting Stratux WiFi Services... $att ${WHITE}"
|
||||||
|
echo "Killing hostapd..."
|
||||||
|
/usr/bin/killall -9 hostapd hostapd-edimax
|
||||||
|
echo "Killed..."
|
||||||
|
echo ""
|
||||||
|
echo "Killing DHCP Server..."
|
||||||
|
echo ""
|
||||||
|
/usr/sbin/service isc-dhcp-server stop
|
||||||
|
sleep 0.5
|
||||||
|
echo "Killed..."
|
||||||
|
echo ""
|
||||||
|
echo "ifdown wlan0..."
|
||||||
|
ifdown wlan0
|
||||||
|
sleep 0.5
|
||||||
|
echo "ifup wlan0..."
|
||||||
|
echo "Calling Stratux WiFI Start Script(stratux-wifi.sh)..."
|
||||||
|
ifup wlan0
|
||||||
|
sleep 0.5
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
|
echo "All systems should be up and running and you should see your new SSID!"
|
||||||
|
|
||||||
### End main loop ###
|
### End main loop ###
|
||||||
|
|
||||||
|
|
|
@ -1,29 +1,36 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
# Preliminaries. Kill off old services.
|
# Preliminaries. Kill off old services.
|
||||||
/usr/bin/killall -9 hostapd hostapd-edimax
|
/usr/bin/killall -9 hostapd hostapd-edimax
|
||||||
/usr/sbin/service isc-dhcp-server stop
|
/usr/sbin/service isc-dhcp-server stop
|
||||||
|
|
||||||
|
#Assume PI3 settings
|
||||||
|
DAEMON_CONF=/etc/hostapd/hostapd.conf
|
||||||
|
DAEMON_SBIN=/usr/sbin/hostapd
|
||||||
|
|
||||||
|
#User settings for hostapd.conf and hostapd-edimax.conf
|
||||||
|
DAEMON_USER_PREF=/etc/hostapd/hostapd.user
|
||||||
|
|
||||||
|
DAEMON_TMP=/tmp/hostapd.conf
|
||||||
|
|
||||||
# Detect RPi version.
|
# Detect RPi version.
|
||||||
# Per http://elinux.org/RPi_HardwareHistory
|
# Per http://elinux.org/RPi_HardwareHistory
|
||||||
|
|
||||||
DAEMON_CONF=/etc/hostapd/hostapd.conf
|
|
||||||
DAEMON_SBIN=/usr/sbin/hostapd
|
|
||||||
EW7811Un=$(lsusb | grep EW-7811Un)
|
EW7811Un=$(lsusb | grep EW-7811Un)
|
||||||
RPI_REV=`cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'`
|
RPI_REV=`cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}' | sed 's/^1000//'`
|
||||||
if [ "$RPI_REV" = "a01041" ] || [ "$RPI_REV" = "a21041" ] || [ "$RPI_REV" = "900092" ] || [ "$RPI_REV" = "900093" ] && [ "$EW7811Un" != '' ]; then
|
if [ "$RPI_REV" = "a01041" ] || [ "$RPI_REV" = "a21041" ] || [ "$RPI_REV" = "900092" ] || [ "$RPI_REV" = "900093" ] && [ "$EW7811Un" != '' ]; then
|
||||||
# This is a RPi2B or RPi0 with Edimax USB Wifi dongle.
|
# This is a RPi2B or RPi0 with Edimax USB Wifi dongle.
|
||||||
DAEMON_CONF=/etc/hostapd/hostapd-edimax.conf
|
DAEMON_CONF=/etc/hostapd/hostapd-edimax.conf
|
||||||
DAEMON_SBIN=/usr/sbin/hostapd-edimax
|
DAEMON_SBIN=/etc/hostapd/hostapd-edimax
|
||||||
else
|
|
||||||
DAEMON_CONF=/etc/hostapd/hostapd.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#Make a new hostapd or hostapd-edimax conf file based on logic above
|
||||||
|
cp -f ${DAEMON_CONF} ${DAEMON_TMP}
|
||||||
|
|
||||||
${DAEMON_SBIN} -B ${DAEMON_CONF}
|
#inject user settings from file to tmp conf
|
||||||
|
cat ${DAEMON_USER_PREF} >> ${DAEMON_TMP}
|
||||||
|
|
||||||
sleep 5
|
${DAEMON_SBIN} -B ${DAEMON_TMP}
|
||||||
|
|
||||||
|
sleep 3
|
||||||
|
|
||||||
/usr/sbin/service isc-dhcp-server start
|
/usr/sbin/service isc-dhcp-server start
|
||||||
|
|
|
@ -23,6 +23,7 @@ cp __root__stratux-pre-start.sh work/bin/
|
||||||
cp dump1090/dump1090 work/bin/
|
cp dump1090/dump1090 work/bin/
|
||||||
cp -r web work/bin/
|
cp -r web work/bin/
|
||||||
cp image/hostapd.conf work/bin/
|
cp image/hostapd.conf work/bin/
|
||||||
|
cp image/hostapd-edimax.conf work/bin/
|
||||||
cp image/config.txt work/bin/
|
cp image/config.txt work/bin/
|
||||||
cp image/rtl-sdr-blacklist.conf work/bin/
|
cp image/rtl-sdr-blacklist.conf work/bin/
|
||||||
cp image/bashrc.txt work/bin/
|
cp image/bashrc.txt work/bin/
|
||||||
|
|
Ładowanie…
Reference in New Issue