From 5362eb114498e63fa61f85fe20914694869694db Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 24 Jan 2025 20:39:21 +0200 Subject: [PATCH] Move firstboot flag to /etc/femto.conf --- foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/.firstboot | 1 - foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/femto.conf | 4 ++-- .../usr/local/bin/femto-boot-complete.sh | 5 +++++ .../rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 8 ++++---- .../usr/local/bin/femto-usb-config-tool.sh | 2 +- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh | 6 +++--- 6 files changed, 15 insertions(+), 11 deletions(-) delete mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/.firstboot diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/.firstboot b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/.firstboot deleted file mode 100644 index e60fd6a..0000000 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/.firstboot +++ /dev/null @@ -1 +0,0 @@ -# File to tell rc.local that this is the first boot. Will be deleted automatically. \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/femto.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/femto.conf index 7c5b5fd..c883d77 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/femto.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/femto.conf @@ -1,2 +1,2 @@ -firstboot=false -act_led=disable \ No newline at end of file +firstboot=true +act_led=enable \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh index 437d5b1..7eb26a7 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-boot-complete.sh @@ -1,4 +1,9 @@ #!/bin/bash +if grep -qE '^first_boot=true' /etc/femto.conf; then + log_message "First boot, skipping \`boot complete\` tasks." + exit 1 +fi + echo "Boot complete" femto-utils.sh -a & diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 1604065..a7b4140 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -4,7 +4,7 @@ log_message() { logger "First boot: $1" # Log to the system log } -if [ ! -e "/etc/.firstboot" ]; then +if grep -qE '^first_boot=false' /etc/femto.conf; then who | grep -q . || exit 0 @@ -20,14 +20,14 @@ Re-running this script after first boot should not cause any harm, but may not w \n\ Proceed?" 14 60 if [ $? -eq 1 ]; then #if cancel/no - exit 1 + exit 0 fi fi echo -e "\e[32m******* First boot *******\e[0m" # Disable LED to prevent boot codes from showing during this boot -sh -c "echo 34 > /sys/class/gpio/unexport" +#sh -c "echo 34 > /sys/class/gpio/unexport" # Perform filesystem resize log_message "Resizing filesystem. This can take up to 10 minutes, depending on microSD card size and speed" @@ -86,7 +86,7 @@ fi #systemctl restart meshtasticd # remove first boot flag -rm /etc/.firstboot +sed -i -E 's/^first_boot=.*/first_boot=false/' /etc/femto.conf log_message "Removing first boot flag and rebooting in 5 seconds..." sleep 5 reboot diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh index e6c1c93..5096583 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh @@ -14,7 +14,7 @@ log_message() { echo "$(date +"%Y-%m-%d %H:%M:%S") $1" >> /tmp/femtofox-config.log } -if [ -e "/etc/.firstboot" ]; then +if grep -qE '^first_boot=true' /etc/femto.conf; then log_message "First boot, skipping USB Configuration Tool." exit 0 fi diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh index 4464708..a90ee5b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh @@ -25,12 +25,12 @@ fi act_led() { if [ "$1" = "disable" ]; then echo "none" > /sys/class/leds/work/trigger - grep -qE '^act_led=' /etc/femto.conf && sudo sed -i -E 's/^act_led=.*/act_led=disable/' /etc/femto.conf || echo 'act_led=disable' | sudo tee -a /etc/femto.conf > /dev/null + grep -qE '^act_led=' /etc/femto.conf && sed -i -E 's/^act_led=.*/act_led=disable/' /etc/femto.conf || echo 'act_led=disable' | tee -a /etc/femto.conf > /dev/null echo "Disabled activity LED." exit 0 elif [ "$1" = "enable" ]; then echo "activity" > /sys/class/leds/work/trigger - grep -qE '^act_led=' /etc/femto.conf && sudo sed -i -E 's/^act_led=.*/act_led=enable/' /etc/femto.conf || echo 'act_led=enable' | sudo tee -a /etc/femto.conf > /dev/null + grep -qE '^act_led=' /etc/femto.conf && sed -i -E 's/^act_led=.*/act_led=enable/' /etc/femto.conf || echo 'act_led=enable' | tee -a /etc/femto.conf > /dev/null echo "Enabled activity LED." exit 0 elif [ "$1" = "check" ]; then @@ -68,7 +68,7 @@ system_info() { local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))" local system_uptime="$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')" local logging_enabled="$(logging "check" | sed 's/\x1b\[[0-9;]*m//g')" - local act_led="$(femto-utils.sh -l "check" | sed -r 's/\x1B\[[0-9;]*[mK]//g')" #remove color from output + local act_led="$(femto-utils.sh -a "check" | sed -r 's/\x1B\[[0-9;]*[mK]//g')" #remove color from output local kernel_active_modules="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)" local kernel_boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")"