change function order in wz_user

This commit is contained in:
Alfonso Gamboa 2022-07-17 21:59:42 -07:00
parent 7f3407fe78
commit a26bf4f8f8
2 changed files with 52 additions and 56 deletions

View File

@ -0,0 +1,3 @@
#!/bin/sh
nano /opt/wz_mini/wz_mini.conf

View File

@ -49,17 +49,61 @@ wait_wlan() {
while true
do
if ifconfig wlan0 | grep "HWaddr"; then
echo "wlan0 hwaddr is up"
store_mac
break
elif ifconfig wlan0 | grep "HWaddr" && [[ "$ENABLE_USB_ETH" == "true" || "$ENABLE_USB_DIRECT" == "true" ]]; then
store_mac
break
fi
echo " wlan0 not ready yet..."
else
echo "wlan0 hwaddr not ready yet..."
sleep 5
fi
done
}
wpa_check() {
##Check if wpa_supplicant has been created by iCamera
if [ -e /tmp/wpa_supplicant.conf ]; then
wait_wlan
echo "wpa_supplicant.conf ready"
else
echo "wpa_supplicant.conf not ready, wait some time for creation."
COUNT=0
ATTEMPTS=15
until [[ -e /tmp/wpa_supplicant.conf ]] || [[ $COUNT -eq $ATTEMPTS ]]; do
echo -e "$(( COUNT++ ))... \c"
sleep 5
wpa_check
done
if [[ $COUNT -eq $ATTEMPTS ]]; then
echo "time exceeded waiting for iCamera, continue potentially broken condition without network."
fi
fi
}
wlanold_check() {
#Have we renamed interfaces yet?
if [ -d /sys/class/net/wlanold ]; then
echo "wlanold exist"
eth_wlan_up
else
echo "wlanold doesn't exist"
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
rename_interface_and_setup_bonding bond0 "$BONDING_PRIMARY_INTERFACE" "$BONDING_SECONDARY_INTERFACE"
else
rename_interface $1
fi
fi
}
netloop() {
##While loop for check
while true
do
wlanold_check $1
echo "wlan0 not ready yet..."
sleep 5
done
}
rename_interface() {
##Fool iCamera by renaming the hardline interface to wlan0
echo "renaming interfaces"
@ -166,57 +210,6 @@ eth_wlan_up() {
break
}
wpa_check() {
#Check if wpa_supplicant has been created by iCamera
if [ -e /tmp/wpa_supplicant.conf ]; then
wait_wlan
echo "wpa_supplicant.conf ready"
if ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
wlanold_check $1
fi
else
echo "wpa_supplicant.conf not ready, wait some time for creation."
COUNT=0
ATTEMPTS=15
until [[ -e /tmp/wpa_supplicant.conf ]] || [[ $COUNT -eq $ATTEMPTS ]]; do
echo -e "$(( COUNT++ ))... \c"
sleep 5
done
if [[ $COUNT -eq $ATTEMPTS ]]; then
echo "time exceeded waiting for iCamera, continue potentially broken condition without network."
if ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
wlanold_check $1
fi
fi
fi
}
wlanold_check() {
#Have we renamed interfaces yet?
if [ -d /sys/class/net/wlanold ]; then
echo "wlanold exist"
eth_wlan_up
else
echo "wlanold doesn't exist"
if [[ "$BONDING_ENABLED" == "true" ]] && ([[ "$ENABLE_USB_ETH" == "true" ]] || [[ "$ENABLE_USB_DIRECT" == "true" ]]); then
rename_interface_and_setup_bonding bond0 "$BONDING_PRIMARY_INTERFACE" "$BONDING_SECONDARY_INTERFACE"
else
rename_interface $1
fi
fi
}
netloop() {
##While loop for check
while true
do
wpa_check $1
echo "wlan0 not ready yet..."
sleep 5
done
}
swap_enable() {
if [ -e /opt/wz_mini/swap ]; then
echo "Swap file exists"