Update femto-runonce.sh

This commit is contained in:
nagumii 2025-01-07 20:25:57 +02:00
parent c90fefcb44
commit a22ce7dcab

View file

@ -4,7 +4,7 @@ log_message() {
logger "First boot: $1" # Log to the system log
}
if [ ! -e "/usr/local/bin/.firstboot" ]; then
if [ ! -e "/etc/.firstboot" ]; then
# prevents weirdness over tty
export NCURSES_NO_UTF8_ACS=1
export TERM=xterm-256color
@ -21,18 +21,32 @@ Proceed?" 14 60
fi
fi
# resize filesystem to fill partition
/usr/bin/filesystem_resize.sh
# Perform filesystem resize
sudo resize2fs /dev/mmcblk1p5
sudo resize2fs /dev/mmcblk1p6
log_message "Resizing /dev/mmcblk1p7 can take up to 10 minutes, depending on microSD card size and speed."
sudo resize2fs /dev/mmcblk1p7
# allocate swap file
if [ ! -f /etc/.filesystem_swap ]; 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
log_message "Swap file allocated."
else
log_message "Swap file already allocated, skipping."
fi
# add RTC support
bash -c 'echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-3/new_device'
log_message "Added RTC support."
log_message "Added ds1307/ds3231 RTC support."
# prevent randomized mac address for eth0. If `eth0`` is already present in /etc/network/interfaces, skip
if ! grep -q "eth0" /etc/network/interfaces; then
log_message "Setting eth0 MAC address to derivative of CPU s/n."
echo "$msg"
logger "$msg"
cat <<EOF >> /etc/network/interfaces
# static mac address for onboard ethernet (castellated pins)
allow-hotplug eth0
@ -40,9 +54,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."
echo "$msg"
logger "$msg"
log_message "eth0 already exists in /etc/network/interfaces, skipping."
fi
# set meshtastic nodeid to derivative of CPU serial number (unique to this board)
@ -59,7 +71,7 @@ log_message "Enabling wifi setting in Meshtasticd."
/usr/local/bin/femto-meshtasticd-config.sh -m "--set network.wifi_enabled true" 10 "First boot"
# remove first boot flag
rm /usr/local/bin/.firstboot
rm /etc/.firstboot
log_message "Removing first boot flag and rebooting in 5 seconds..."
sleep 5
reboot