diff --git a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local index 4585344..671cc72 100755 --- a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local +++ b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local @@ -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 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/runonce.sh index 6ffb2ee..3a02e99 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/runonce.sh @@ -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..." diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/updatemeshtastic.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/updatemeshtastic.sh new file mode 100644 index 0000000..978407d --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/updatemeshtastic.sh @@ -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 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/usbconfig.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/usbconfig.sh index b6dfdaf..51d07f6 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/usbconfig.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/usbconfig.sh @@ -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