mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-26 19:02:00 -04:00
parent
523f78f43e
commit
186858fe50
4 changed files with 37 additions and 48 deletions
|
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
|
||||
# not really needed after first boot
|
||||
/usr/bin/filesystem_resize.sh
|
||||
|
||||
# supposedly needed for usb storage, but works anyway
|
||||
#/etc/init.d/S50usbdevice start
|
||||
|
||||
|
|
|
|||
|
|
@ -29,20 +29,8 @@ systemctl start meshtasticd
|
|||
msg="First boot: Enabling wifi setting in Meshtasticd."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
for retries in $(seq 1 10); do
|
||||
output=$(meshtastic --host --set network.wifi_enabled true 2>&1)
|
||||
echo "$output"
|
||||
if echo "$output" | grep -qiE "Abort|invalid|Error"; then
|
||||
if [ "$retries" -lt 10 ]; then
|
||||
msg="First boot: Meshtastic update failed, retrying ($(($retries + 1))/10)..."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
/usr/local/bin/updatemeshtastic.sh "--set lora.region US" 10 "First boot"
|
||||
/usr/local/bin/updatemeshtastic.sh "--set network.wifi_enabled true" 10 "First boot"
|
||||
|
||||
rm /usr/local/bin/.firstboot
|
||||
msg="First boot: Removing first boot flag and rebooting..."
|
||||
|
|
|
|||
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/bash
|
||||
|
||||
command="$1"
|
||||
attempts=$2
|
||||
ref="$3: "
|
||||
for retries in $(seq 1 $attempts); do
|
||||
|
||||
output=$(meshtastic --host 127.0.0.1 $command >&2) #>&2 lets meshtastic's output display on screen
|
||||
|
||||
if echo "$output" | grep -qiE "Abort|invalid|Error|refused"; then
|
||||
if [ "$retries" -lt $attempts ]; then
|
||||
msg="${ref:+$ref }Meshtastic update failed, retrying ($(($retries + 1))/$attempts)..."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
exit 0 #success
|
||||
break
|
||||
fi
|
||||
done
|
||||
exit 1 #failed
|
||||
|
|
@ -227,45 +227,21 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then
|
|||
log_message "wpa_supplicant.conf updated and wifi restarted. Enabling Meshtastic wifi setting."
|
||||
sudo dhclient 2>&1 | sudo tee -a /tmp/femtofox-config.log
|
||||
|
||||
for retries in $(seq 1 3); do
|
||||
meshtastic --host --set network.wifi_enabled true 2>&1 | sudo tee -a /tmp/femtofox-config.log
|
||||
if tail -n 1 "/tmp/femtofox-config.log" | grep -qiE "Abort|invalid|Error"; then
|
||||
if [ "$retries" -lt 3 ]; then
|
||||
log_message "Meshtastic update failed, retrying ($(($retries + 1))/3)..."
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
if tail -n 1 "/tmp/femtofox-config.log" | grep -qiE "Abort|invalid|Error"; then
|
||||
log_message "Failed to update Meshtastic wifi setting to 'enabled' after 3 attempts."
|
||||
for _ in $(seq 1 2); do # do meshtastic error boot code
|
||||
blink "1" && sleep 0.25 && blink "1" && sleep 0.25
|
||||
blink "0.25" && sleep 0.25 && blink "0.25" && sleep 0.25
|
||||
done
|
||||
/usr/local/bin/updatemeshtastic.sh "--set network.wifi_enabled true" 3 "USB config" #| sudo tee -a /tmp/femtofox-config.log
|
||||
if [ $? -eq 1 ]; then
|
||||
log_message "Update of Meshtastic FAILED."
|
||||
else
|
||||
log_message "Updated Meshtastic successfully."
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$update_meshtastic" != "" ]; then
|
||||
log_message "Connecting to Meshtastic radio and submitting $update_meshtastic"
|
||||
for retries in $(seq 1 3); do
|
||||
meshtastic --host $update_meshtastic 2>&1 | sudo tee -a /tmp/femtofox-config.log
|
||||
if tail -n 1 "/tmp/femtofox-config.log" | grep -qiE "Abort|invalid|Error"; then
|
||||
if [ "$retries" -lt 3 ]; then
|
||||
log_message "Meshtastic update failed, retrying ($(($retries + 1))/3)..."
|
||||
sleep 2 # Add a small delay before retrying
|
||||
fi
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
if tail -n 1 "/tmp/femtofox-config.log" | grep -qiE "Abort|invalid|Error"; then
|
||||
log_message "Failed to update Meshtastic after 3 attempts."
|
||||
for _ in $(seq 1 2); do # do meshtastic error boot code
|
||||
blink "1" && sleep 0.25 && blink "1" && sleep 0.25
|
||||
blink "0.25" && sleep 0.25 && blink "0.25" && sleep 0.25
|
||||
done
|
||||
/usr/local/bin/updatemeshtastic.sh "$update_meshtastic" 3 "USB config" #| sudo tee -a /tmp/femtofox-config.log
|
||||
if [ $? -eq 1 ]; then
|
||||
log_message "Update of Meshtastic FAILED."
|
||||
else
|
||||
log_message "Updated Meshtastic successfully."
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue