Function to count the number of wlans
This commit is contained in:
parent
3ab2687019
commit
689c236ddb
|
@ -39,95 +39,107 @@ WIFI_NETWORKS_FILE=~/${PROJECT_NAME}-wifi.cfg
|
||||||
# repo for atheros AR9271 wifi driver
|
# repo for atheros AR9271 wifi driver
|
||||||
ATHEROS_WIFI_REPO="https://github.com/qca/open-ath9k-htc-firmware.git"
|
ATHEROS_WIFI_REPO="https://github.com/qca/open-ath9k-htc-firmware.git"
|
||||||
|
|
||||||
|
function count_wlan {
|
||||||
|
# counts the number of wlan devices
|
||||||
|
ctr=0
|
||||||
|
|
||||||
|
for i in $(seq 0 10); do
|
||||||
|
if grep -q "wlan${i}" /proc/net/dev; then
|
||||||
|
ctr=$((ctr + 1))
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo $ctr
|
||||||
|
}
|
||||||
|
|
||||||
function setup_wifi {
|
function setup_wifi {
|
||||||
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
|
if [[ $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ! $WIFI_SSID ]; then
|
if [ ! $WIFI_SSID ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ${#WIFI_SSID} -lt 2 ]; then
|
if [ ${#WIFI_SSID} -lt 2 ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if grep -Fxq "setup_wifi" $COMPLETION_FILE; then
|
if grep -Fxq "setup_wifi" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOTSPOT='no'
|
HOTSPOT='no'
|
||||||
if [[ $WIFI_HOTSPOT != 'no' ]]; then
|
if [[ $WIFI_HOTSPOT != 'no' ]]; then
|
||||||
HOTSPOT='yes'
|
HOTSPOT='yes'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $WIFI_NETWORKS_FILE ]; then
|
if [ -f $WIFI_NETWORKS_FILE ]; then
|
||||||
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
|
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE --networks $WIFI_NETWORKS_FILE
|
||||||
echo 'setup_wifi' >> $COMPLETION_FILE
|
echo 'setup_wifi' >> $COMPLETION_FILE
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $WIFI_TYPE != 'none' ]]; then
|
if [[ $WIFI_TYPE != 'none' ]]; then
|
||||||
if [ ! $WIFI_PASSPHRASE ]; then
|
if [ ! $WIFI_PASSPHRASE ]; then
|
||||||
echo $'No wifi passphrase was given'
|
echo $'No wifi passphrase was given'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
|
if [ ${#WIFI_PASSPHRASE} -lt 2 ]; then
|
||||||
echo $'Wifi passphrase was too short'
|
echo $'Wifi passphrase was too short'
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
|
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE -p $WIFI_PASSPHRASE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
|
||||||
else
|
else
|
||||||
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
|
${PROJECT_NAME}-wifi -i $WIFI_INTERFACE -s $WIFI_SSID -t $WIFI_TYPE --hotspot $HOTSPOT --networks $WIFI_NETWORKS_FILE
|
||||||
fi
|
fi
|
||||||
echo 'setup_wifi' >> $COMPLETION_FILE
|
echo 'setup_wifi' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
# ath9k_htc driver
|
# ath9k_htc driver
|
||||||
function install_atheros_wifi {
|
function install_atheros_wifi {
|
||||||
if grep -Fxq "install_atheros_wifi" $COMPLETION_FILE; then
|
if grep -Fxq "install_atheros_wifi" $COMPLETION_FILE; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ $INSTALLING_ON_BBB != "yes" ]; then
|
if [ $INSTALLING_ON_BBB != "yes" ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [[ $ENABLE_BABEL != "yes" && $ENABLE_BATMAN != "yes" && $ENABLE_CJDNS != "yes" ]]; then
|
if [[ $ENABLE_BABEL != "yes" && $ENABLE_BATMAN != "yes" && $ENABLE_CJDNS != "yes" ]]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
if [ -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
|
if [ -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# have drivers already been installed ?
|
# have drivers already been installed ?
|
||||||
if [ -f /lib/firmware/htc_9271.fw ]; then
|
if [ -f /lib/firmware/htc_9271.fw ]; then
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
apt-get -y install build-essential cmake git m4 texinfo
|
apt-get -y install build-essential cmake git m4 texinfo
|
||||||
if [ ! -d $INSTALL_DIR ]; then
|
if [ ! -d $INSTALL_DIR ]; then
|
||||||
mkdir -p $INSTALL_DIR
|
mkdir -p $INSTALL_DIR
|
||||||
fi
|
fi
|
||||||
cd $INSTALL_DIR
|
cd $INSTALL_DIR
|
||||||
if [ ! -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
|
if [ ! -d $INSTALL_DIR/open-ath9k-htc-firmware ]; then
|
||||||
function_check git_clone
|
function_check git_clone
|
||||||
git_clone $ATHEROS_WIFI_REPO $INSTALL_DIR/open-ath9k-htc-firmware
|
git_clone $ATHEROS_WIFI_REPO $INSTALL_DIR/open-ath9k-htc-firmware
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
||||||
exit 74283
|
exit 74283
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cd $INSTALL_DIR/open-ath9k-htc-firmware
|
cd $INSTALL_DIR/open-ath9k-htc-firmware
|
||||||
git checkout 1.4.0
|
git checkout 1.4.0
|
||||||
make toolchain
|
make toolchain
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
||||||
exit 24820
|
exit 24820
|
||||||
fi
|
fi
|
||||||
make firmware
|
make firmware
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
rm -rf $INSTALL_DIR/open-ath9k-htc-firmware
|
||||||
exit 63412
|
exit 63412
|
||||||
fi
|
fi
|
||||||
cp target_firmware/*.fw /lib/firmware/
|
cp target_firmware/*.fw /lib/firmware/
|
||||||
if [ ! "$?" = "0" ]; then
|
if [ ! "$?" = "0" ]; then
|
||||||
exit 74681
|
exit 74681
|
||||||
fi
|
fi
|
||||||
echo 'install_atheros_wifi' >> $COMPLETION_FILE
|
echo 'install_atheros_wifi' >> $COMPLETION_FILE
|
||||||
}
|
}
|
||||||
|
|
||||||
# NOTE: deliberately no exit 0
|
# NOTE: deliberately no exit 0
|
||||||
|
|
Loading…
Reference in New Issue