From c7c627f0d91aa60d239c241210be9a16d96d3cdf Mon Sep 17 00:00:00 2001 From: Ruledo Date: Sun, 19 Jan 2025 19:17:26 -0800 Subject: [PATCH] Re-engineered rc.local Moved femto-runonce to a service Moved femto-usb-config-tool to a service re-added override for meshtasticd to execute after rc-local small fix in femto-network-config ro removed uneeded steps (same as I did in wifi config) added a step in runonce that if no user logged in and already has been been run once, exit and do not run menu. --- .../overlay/overlay-luckfox-ubuntu/etc/rc.local | 12 +++++------- .../etc/systemd/system/femto-runonce.service | 16 ++++++++++++++++ .../system/femto-usb-config-tool.service | 17 +++++++++++++++++ .../system/meshtasticd.service.d/override.conf | 3 +++ .../usr/local/bin/femto-network-config.sh | 4 ++-- .../usr/local/bin/femto-runonce.sh | 5 ++++- .../usr/local/bin/femto-usb-config-tool.sh | 0 7 files changed, 47 insertions(+), 10 deletions(-) mode change 100755 => 100644 foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh mode change 100755 => 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-usb-config-tool.sh 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 old mode 100755 new mode 100644 index 067210a..8fb738c --- 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 @@ -4,14 +4,12 @@ #/etc/init.d/S50usbdevice start #run only on first boot -if [ -e "/etc/.firstboot" ]; then - /usr/local/bin/femto-runonce.sh -fi +#if [ -e "/etc/.firstboot" ]; then +# /usr/local/bin/femto-runonce.sh +#fi luckfox-config load -systemctl restart meshtasticd #TEMPORARY bugfix - # try enable RTC echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1 @@ -25,14 +23,14 @@ echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction #(sleep 5 && cpufreq-set -u 408000 && echo "Boot complete, setting CPU frequency to 408mhz.") & # run USB automount and config tool -/usr/local/bin/femto-usb-config-tool.sh +#/usr/local/bin/femto-usb-config-tool.sh # boot complete ( echo "Disabling ACT LED..." echo "none" > /sys/class/leds/work/trigger & sleep 1 - + # blink successful boot code for i in $(seq 1 5); do echo 1 > /sys/class/gpio/gpio34/value; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service new file mode 100644 index 0000000..eb4c075 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service @@ -0,0 +1,16 @@ +[Unit] +Description=Foxbuntu First Boot +After=meshtasticd.service +Requires=meshtasticd.service +Before=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-runonce.sh +Type=oneshot +RemainAfterExit=true +StandardOutput=tty +StandardError=tty + +[Install] +WantedBy=serial-getty@ttyFIQ0.service diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service new file mode 100644 index 0000000..a675c9f --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service @@ -0,0 +1,17 @@ +[Unit] +Description=Foxbuntu USB Configuration Tool +After=femto-runonce.service meshtasticd.service +Before=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-usb-config-tool.sh +Type=oneshot +RemainAfterExit=true +StandardOutput=journal+console +StandardError=journal+console +TTYPath=/dev/console + +[Install] +WantedBy=serial-getty@ttyFIQ0.service + diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index 9afc90b..1d992e3 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,3 +1,6 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +[Unit] +After=rc-local.service +Wants=rc-local.service diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh old mode 100755 new mode 100644 index aae75e8..50140c2 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh @@ -155,7 +155,7 @@ done if [ "$updated_wifi" = true ]; then ip link set wlan0 up - systemctl restart wpa_supplicant + #systemctl restart wpa_supplicant wpa_cli -i wlan0 reconfigure # <-------- add watch for FAIL response, error out - timeout 30s dhclient -v + #timeout 30s dhclient -v fi 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 old mode 100755 new mode 100644 index 4891e8e..831f797 --- 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 @@ -5,6 +5,9 @@ log_message() { } if [ ! -e "/etc/.firstboot" ]; then + + who | grep -q . || exit 1 + # prevents weirdness over tty export NCURSES_NO_UTF8_ACS=1 export TERM=xterm-256color @@ -83,4 +86,4 @@ systemctl restart meshtasticd rm /etc/.firstboot log_message "Removing first boot flag and rebooting in 5 seconds..." sleep 5 -reboot \ No newline at end of file +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 old mode 100755 new mode 100644