Improve runonce text.

This commit is contained in:
nagumii 2025-01-28 18:09:43 +02:00
parent a5696fc1fc
commit 0f83ec0555
2 changed files with 14 additions and 19 deletions

View file

@ -13,11 +13,18 @@ if ! grep -qE '^first_boot=true' /etc/femto.conf; then # if not the first boot
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 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 will:\n\
* Resize filesystem to fit the SD card\n\
* Allocate the swap file\n\
* Add terminal type to user femto's .bashrc\n\
* Set the eth0 MAC to be derivative of CPU serial number\n\
\n\
Finally, the Femtofox will reboot.\n\
\n\
Re-running this script after first boot should not cause any harm, but may not work as expected.\n\
\n\
Proceed?" 15 60
Proceed?" 19 60
if [ $? -eq 1 ]; then #if cancel/no
exit 0
fi
@ -35,9 +42,6 @@ echo -e "\e[32m******* First boot *******\e[0m"
done
) &
# Disable LED to prevent boot codes from showing during this boot
#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"
sudo resize2fs /dev/mmcblk1p5
@ -51,7 +55,6 @@ if [ ! -f /swapfile ]; then # check if swap file already exists
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 # no longer used
log_message "Swap file allocated."
else
log_message "Swap file already allocated, skipping."
@ -62,8 +65,9 @@ fi
#log_message "Added ds1307/ds3231 RTC support."
# prevent randomized mac address for eth0. If `eth0`` is already present in /etc/network/interfaces, skip
mac="$(awk '/Serial/ {print $3}' /proc/cpuinfo | tail -c 11 | sed 's/^\(.*\)/a2\1/' | sed 's/\(..\)/\1:/g;s/:$//')"
if ! grep -q "eth0" /etc/network/interfaces; then
log_message "Setting eth0 MAC address to derivative of CPU s/n."
log_message "Setting eth0 MAC address to $mac (derivative of CPU s/n)"
cat <<EOF >> /etc/network/interfaces
# static mac address for onboard ethernet (castellated pins)
allow-hotplug eth0
@ -71,7 +75,7 @@ iface eth0 inet dhcp
hwaddress ether $(awk '/Serial/ {print $3}' /proc/cpuinfo | tail -c 11 | sed 's/^\(.*\)/a2\1/' | sed 's/\(..\)/\1:/g;s/:$//')
EOF
else
log_message "eth0 already exists in /etc/network/interfaces, skipping."
log_message "eth0 already exists in /etc/network/interfaces, skipping"
fi
# Add term stuff to .bashrc
@ -85,17 +89,8 @@ else
echo "TERM, LANG and NCURSES_NO_UTF8_ACS already present in .bashrc, skipping"
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=$((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
# remove first boot flag
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
reboot

View file

@ -91,7 +91,7 @@ package_menu() {
$(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \
$(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \
$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Get service status x"; fi) \
"" "" \
" " "" \
"Back to software manager" "" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command