mirror of
https://github.com/femtofox/femtofox.git
synced 2026-10-26 19:02:00 -04:00
If runonce.sh is run multiple times, it won't bork anything.
This commit is contained in:
parent
5c14c6a4a1
commit
b15522cd1d
1 changed files with 23 additions and 21 deletions
|
|
@ -1,47 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
log_message() {
|
||||
echo "USB config: $1" # Echo to the screen
|
||||
logger "USB config: $1" # Log to the system log
|
||||
}
|
||||
|
||||
# resize filesystem to fill partition
|
||||
/usr/bin/filesystem_resize.sh
|
||||
|
||||
# add RTC support
|
||||
bash <<EOF
|
||||
echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-3/new_device
|
||||
EOF
|
||||
msg="First boot: Added RTC support."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
bash -c 'echo ds1307 0x68 > /sys/class/i2c-adapter/i2c-3/new_device'
|
||||
log_message "First boot: Added RTC support."
|
||||
|
||||
# prevent randomized mac address for eth0
|
||||
msg="First boot: Setting eth0 MAC address to derivative of CPU s/n."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
cat <<EOF >> /etc/network/interfaces
|
||||
# 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 "First boot: 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
|
||||
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 "First boot: eth0 already exists in /etc/network/interfaces."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
fi
|
||||
|
||||
# set meshtastic nodeid to derivative of CPU serial number (unique to this board). Check at boot in case of upgrade overwriting this.
|
||||
# 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
|
||||
msg="First boot: Using Luckfox CPU S/N to generate nodeid for Meshtastic."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
log_message "First boot: Using Luckfox CPU S/N to generate nodeid for Meshtastic."
|
||||
systemctl daemon-reload
|
||||
systemctl enable meshtasticd
|
||||
systemctl start meshtasticd
|
||||
|
||||
# enable wifi in meshtastic settings. Because this is very important, we'll try 10 times.
|
||||
msg="First boot: Enabling wifi setting in Meshtasticd."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
log_message "First boot: Enabling wifi setting in Meshtasticd."
|
||||
/usr/local/bin/updatemeshtastic.sh "--set network.wifi_enabled true" 10 "First boot"
|
||||
|
||||
# remove first boot flag
|
||||
rm /usr/local/bin/.firstboot
|
||||
msg="First boot: Removing first boot flag and rebooting..."
|
||||
echo "$msg"
|
||||
logger "$msg"
|
||||
log_message "First boot: Removing first boot flag and rebooting in 5 seconds..."
|
||||
sleep 5
|
||||
reboot
|
||||
Loading…
Add table
Add a link
Reference in a new issue