From fae26cc1787909d4a57a1d39d240c021c64ed691 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 17:39:19 +0200 Subject: [PATCH] Move meshtasticd -h argument to service override --- environment-setup/femtofox.chroot | 2 ++ .../overlay-luckfox-ubuntu/etc/rc.local | 26 +++++++++---------- .../system/femto-boot-complete.service | 14 ++++++++++ .../meshtasticd.service.d/override.conf | 3 +++ .../usr/local/bin/femto-runonce.sh | 22 +++++++--------- 5 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 96a5153..e45fae5 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -53,8 +53,10 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." systemctl enable button +systemctl enable meshtasticd systemctl enable femto-runonce.service systemctl enable femto-usb-config-tool.service +systemctl enable femto-boot-complete.service systemctl enable wifi-mesh-control systemctl disable NetworkManager 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 8fb738c..4e7b166 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 @@ -26,18 +26,18 @@ echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction #/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; - sleep 0.5; - echo 0 > /sys/class/gpio/gpio34/value; - sleep 0.5; - done -) & +#( +# 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; +# sleep 0.5; +# echo 0 > /sys/class/gpio/gpio34/value; +# sleep 0.5; +# done +#) & exit 0 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service new file mode 100644 index 0000000..ae450b3 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-boot-complete.service @@ -0,0 +1,14 @@ +[Unit] +Description=Boot Complete +After=serial-getty@ttyFIQ0.service +DefaultDependencies=no + +[Service] +ExecStart=/usr/local/bin/femto-boot-complete.sh +Type=oneshot +Restart=no +StandardOutput=journal+console +StandardError=journal+console + +[Install] +WantedBy=default.target \ No newline at end of file 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 1d992e3..3ef95db 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,6 +1,9 @@ [Service] ExecStartPost=/bin/sh -c 'renice -n -20 -p $(pgrep meshtasticd)' +ExecStart= +ExecStart=/bin/sh -c '/usr/sbin/meshtasticd -h $(sed -n "/Serial/ s/^.*: \(.*\)$/\U\1/p" /proc/cpuinfo | bc | tail -c 9)' [Unit] After=rc-local.service Wants=rc-local.service +After=network-online.target \ No newline at end of file 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 c713aac..a62552a 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 @@ -14,7 +14,7 @@ if [ ! -e "/etc/.firstboot" ]; then export LANG=C.UTF-8 dialog --title "Femtofox run once utility" --yesno "\ This does not appear to be this system's first boot.\n\ -Re-running this script will restore RTC support, set the Meshtastic nodeid and eth0 MAC address to be derivative of the CPU serial number, set the Meshtastic wifi status to \`enabled\` and then reboot.\n\ +Re-running this script will resize the filesystem to fit the SD card, allocate a swap file, add RTC support, add terminal type to .bashrc, set the eth0 MAC address to be derivative of the CPU serial number and then reboot.\n\ \n\ Re-running this script after first boot should not cause any harm, but may not work as expected.\n\ \n\ @@ -31,13 +31,13 @@ fi sudo resize2fs /dev/mmcblk1p7 # allocate swap file -if [ ! -f /etc/.filesystem_swap ]; then # check if swap file already exists +if [ ! -f /swapfile ]; then # check if swap file already exists sudo fallocate -l 1G /swapfile sudo chmod 600 /swapfile sudo mkswap /swapfile > /dev/null sudo swapon /swapfile > /dev/null echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab > /dev/null - touch /etc/.filesystem_swap +# touch /etc/.filesystem_swap # no longer used log_message "Swap file allocated." else log_message "Swap file already allocated, skipping." @@ -64,9 +64,7 @@ fi lines="export NCURSES_NO_UTF8_ACS=1 export TERM=xterm-256color export LANG=C.UTF-8" - -# Check if the lines are already in .bashrc -if ! grep -Fxq "$lines" /home/femto/.bashrc; then +if ! grep -Fxq "$lines" /home/femto/.bashrc; then # Check if the lines are already in .bashrc echo "$lines" >> /home/femto/.bashrc echo "Added TERM, LANG and NCURSES_NO_UTF8_ACS to .bashrc" else @@ -74,13 +72,13 @@ else fi # set meshtastic nodeid to derivative of CPU serial number (unique to this board) -seed=$(sed -n '/Serial/ s/^.*: \(.*\)$/\U\1/p' /proc/cpuinfo | bc | tail -c 9) +#seed=$(sed -n '/Serial/ s/^.*: \(.*\)$/\U\1/p' /proc/cpuinfo | bc | tail -c 9) #seed=$((0x$(awk '/Serial/ {print $3}' /proc/cpuinfo) & 0x3B9AC9FF)) #alternate method for generating seed - not in use -sed -i "s|^ExecStart=/usr/sbin/meshtasticd.*|ExecStart=/usr/sbin/meshtasticd -h $seed|" /usr/lib/systemd/system/meshtasticd.service -log_message "Using Luckfox CPU S/N to generate nodeid for Meshtastic." -systemctl daemon-reload -systemctl enable meshtasticd -systemctl restart meshtasticd +#sed -i "s|^ExecStart=/usr/sbin/meshtasticd.*|ExecStart=/usr/sbin/meshtasticd -h $seed|" /usr/lib/systemd/system/meshtasticd.service +#log_message "Using Luckfox CPU S/N to generate nodeid for Meshtastic." +#systemctl daemon-reload +#systemctl enable meshtasticd +#systemctl restart meshtasticd # remove first boot flag rm /etc/.firstboot