mirror of
https://github.com/femtofox/femtofox.git
synced 2026-11-30 03:47:12 -05:00
Merge pull request #226 from femtofox/OSC
Run once and usb tool moved from rc.local to services.
This commit is contained in:
commit
d1beafba43
11 changed files with 124 additions and 36 deletions
|
|
@ -53,7 +53,12 @@ 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
|
||||
systemctl disable NetworkManager-dispatcher
|
||||
systemctl disable NetworkManager-wait-online
|
||||
|
|
|
|||
|
|
@ -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,21 +23,21 @@ 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;
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Foxbuntu First Boot
|
||||
After=meshtasticd.service
|
||||
Before=serial-getty@ttyFIQ0.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/femto-runonce.sh
|
||||
Type=oneshot
|
||||
Restart=no
|
||||
StandardOutput=journal+console
|
||||
StandardError=journal+console
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
[Unit]
|
||||
Description=Foxbuntu USB Configuration Tool
|
||||
After=meshtasticd.service
|
||||
Before=serial-getty@ttyFIQ0.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/femto-usb-config-tool.sh
|
||||
Type=oneshot
|
||||
Restart=no
|
||||
StandardOutput=journal+console
|
||||
StandardError=journal+console
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
|
||||
|
|
@ -1,3 +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)'
|
||||
Nice=-20
|
||||
|
||||
[Unit]
|
||||
After=rc-local.service
|
||||
Wants=rc-local.service
|
||||
After=network-online.target
|
||||
|
|
|
|||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/bash
|
||||
echo "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
|
||||
exit 0
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -5,13 +5,16 @@ log_message() {
|
|||
}
|
||||
|
||||
if [ ! -e "/etc/.firstboot" ]; then
|
||||
|
||||
who | grep -q . || exit 0
|
||||
|
||||
# prevents weirdness over tty
|
||||
export NCURSES_NO_UTF8_ACS=1
|
||||
export TERM=xterm-256color
|
||||
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\
|
||||
|
|
@ -21,6 +24,9 @@ Proceed?" 14 60
|
|||
fi
|
||||
fi
|
||||
|
||||
# Disable LED to prevent boot codes from showing during this boot
|
||||
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
|
||||
|
|
@ -28,13 +34,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."
|
||||
|
|
@ -61,9 +67,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
|
||||
|
|
@ -71,16 +75,16 @@ 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
|
||||
log_message "Removing first boot flag and rebooting in 5 seconds..."
|
||||
sleep 5
|
||||
reboot
|
||||
reboot
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ -e "/etc/.firstboot" ]; then
|
||||
echo "First boot, skipping USB Configuration Tool."
|
||||
logger "First boot, skipping USB Configuration Tool."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mount_point="/mnt/usb" # Set the mount point
|
||||
|
||||
# Function to log to screen, syslog and logfile to be saved to usb drive
|
||||
|
|
@ -8,6 +15,12 @@ log_message() {
|
|||
echo "$(date +"%Y-%m-%d %H:%M:%S") $1" >> /tmp/femtofox-config.log
|
||||
}
|
||||
|
||||
if [ -e "/etc/.firstboot" ]; then
|
||||
echo "First boot, skipping USB Configuration Tool."
|
||||
logger "First boot, skipping USB Configuration Tool."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
exit_script() {
|
||||
if [ ! -z "$usb_path" ]; then #if usb path is populated
|
||||
if ! df -T /mnt/usb 2>/dev/null | grep -qw 'ntfs'; then
|
||||
|
|
@ -146,7 +159,8 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then
|
|||
if [[ -n "$wifi_psk" ]]; then
|
||||
# Update the psk in the network block
|
||||
wifi_command="$wifi_command -p \"$wifi_psk\""
|
||||
log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to \`$wifi_psk\`."
|
||||
#log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to \`$wifi_psk\`."
|
||||
log_message "Updating Wi-Fi PSK in wpa_supplicant.conf to *HIDDEN*."
|
||||
found_config="true"
|
||||
update_wifi="true"
|
||||
fi
|
||||
|
|
|
|||
0
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh
Normal file → Executable file
0
foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/wifi-mesh-control.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue