This commit is contained in:
Ruledo 2025-01-16 17:29:29 -08:00
commit 95a7d5be6b
15 changed files with 234 additions and 120 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

View file

@ -34,7 +34,7 @@ DEBIAN_FRONTEND=noninteractive apt upgrade -y --option Dpkg::Options::="--force-
# Tempfix for SEGFAULT
wget https://github.com/meshtastic/firmware/releases/download/v2.5.11.8e2a3e5/meshtasticd_2.5.11.8e2a3e5_armhf.deb
DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" ./meshtasticd_2.5.11.8e2a3e5_armhf.deb
rm ./meshtasticd_2.5.11.8e2a3e5_armhf.deb
echo "Installing dependencies for meshing-around and meshtastic cli..."
#pip config set global.extra-index-url https://www.piwheels.org/simple

View file

@ -3,7 +3,7 @@
<service-group>
<name>Meshtastic</name>
<service protocol="ipv4">
<type>_http._tcp</type>
<port>80</port>
<type>_meshtastic._tcp</type>
<port>4403</port>
</service>
</service-group>

View file

@ -1,5 +0,0 @@
#!/bin/bash
export NCURSES_NO_UTF8_ACS=1
export TERM=xterm-256color
export LANG=C.UTF-8
python /opt/curses-client-for-meshtastic/main.py --host

View file

@ -132,7 +132,7 @@ networking_settings() {
done
}
# Pinout menu
# pinout menu
femto_pinouts() {
while true; do
local option=""
@ -160,22 +160,100 @@ femto_pinouts() {
done
}
# Function to handle misc settings
# enable/disable system logging
logging() {
enable_logging() {
chattr -i /var/log
msg="Enabling system logging by making /var/log writable."
logger $msg
echo $msg
return 0
}
disable_logging() {
msg="Disabling system logging by making /var/log immutable."
logger $msg
echo $msg
chattr +i /var/log
return 0
}
check_logging() {
lsattr -d /var/log | grep -q 'i' && echo -e "\033[0;31mdisabled\033[0m" || echo -e "\033[0;34menabled\033[0m"
}
if [ "$1" = "true" ]; then
disable_logging
elif [ "$1" = "false" ]; then
enable_logging
elif [ "$1" = "check" ]; then
check_logging
elif [ -z "$1" ]; then
while true; do
choice=$(dialog --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(check_logging)")" 12 50 2 \
1 "Enable (default)" \
2 "Disable" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command
if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
fi
case $choice in
1) enable_logging ;;
2) disable_logging ;;
esac
done
else
echo "$1 is not a valid argument for -L. Options are \"true\" and \"false\"."
fi
}
system_info() {
local cpu_architecture="armv7l (armhf 32bit)"
local cpu_model="Rockchip rv1103 (rev$(awk '/CPU revision/ {print $4}' /proc/cpuinfo))"
local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)"
local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}') - $(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz"
local microsd_size="$(df -h / | awk 'NR==2 {printf "%s (%.0f%% free)", $4, (100 - $5+0)}')"
local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')"
local swap="$(free -m | awk 'NR==3{printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}')"
local mounted_drives="$([ "$(for dir in /mnt/*/; do echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "Mounted drives: $(for dir in /mnt/*; do echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')")"
local os_version="Foxbuntu v$(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release)$(output=$(grep -o 'patch=[1-9][0-9]*' /etc/foxbuntu-release | cut -d= -f2) && [ -n "$output" ] && echo ".$output")$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release) ($(lsb_release -d | awk -F'\t' '{print $2}') $(lsb_release -c | awk -F'\t' '{print $2}'))"
info="\
Femtofox\n\
Core: Luckfox Pico Mini\n\
CPU:\n\
Architecture: $cpu_architecture\n\
Model: $cpu_model\n\
Serial # $cpu_serial\n\
Cores: 1\n\
Speed: $cpu_speed\n\
Storage:\n\
microSD size: $microsd_size\n\
Memory: $memory\n\
Swap: $swap\n\
$mounted_drives\n\
\n\
Uptime:$(uptime -p | awk '{$1=""; print $0}' | sed -e 's/ day\b/d/g' -e 's/ hour\b/h/g' -e 's/ hours\b/h/g' -e 's/ minute\b/m/g' -e 's/ minutes\b/m/g' | sed 's/,//g')\n\
Operating System: $os_version\n\
$(replace_colors "$(femto-network-config.sh -e)")\
"
echo -e "$info"
}
# utilities
utilities() {
local title="Utilities"
while true; do
local option=""
option=$(dialog --cancel-label "Back" --menu "$title" 17 40 4 \
1 "Set system timezone" \
option=$(dialog --cancel-label "Back" --menu "$title" 18 40 4 \
1 "Set system time" \
2 "Kernel modules" \
3 "Re-run first-boot script" \
4 "Run USB configuration tool" \
5 "Run OEM luckfox-config" \
6 "Process viewer/manager" \
7 "Reboot" \
8 "Shutdown" \
7 "Disable/enable logging" \
8 "Reboot" \
9 "Shutdown" \
"" "" \
9 "Back to Main Menu" 3>&1 1>&2 2>&3)
10 "Back to Main Menu" 3>&1 1>&2 2>&3)
exit_status=$? # This line checks the exit status of the dialog command
if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
@ -183,7 +261,7 @@ utilities() {
fi
case $option in
1) femto-set-timezone.sh ;; # set timezone)
1) femto-set-time.sh ;; # set timezone)
2) # Kernel modules)
dialog --title "$title" --msgbox "Kernel modules are loadable pieces of code that extend a Linux kernel's functionality without requiring a reboot. Common examples include device drivers, file systems, or system calls.\n\nThis tool will allow you to add pre-compiled modules to the Foxbuntu kernel.\n\nModules currently autostarting at boot: $(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")\n\nCurrently active modules: $(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ')" 18 65
femto-kernel-modules.sh
@ -198,14 +276,15 @@ utilities() {
;;
5) luckfox-config ;;
6) htop ;;
7)
7) logging ;;
8) # reboot)
dialog --title "$title" --yesno "Reboot now?\n\nTip: Reboot can also be triggered by long-pressing the BOOT button on the luckfox." 10 45
if [ $? -eq 0 ]; then #unless cancel/no
dialog --infobox "Rebooting..." 5 45
reboot
fi
;;
8)
9) # shutdown)
dialog --title "$title" --yesno "Shut down now?\n\nTo power system back on, disconnect/reconnect power.\n\nThe system shutdown command prevents damage to the filesystem from power interrupts, but does not stop power consumption.\n\nTip: You can also shut down the Femtofox by pressing the BOOT button for 5 seconds or by running \`sudo halt\`." 14 60
if [ $? -eq 0 ]; then #unless cancel/no
dialog --infobox "Shutting down...\n\nPower consumption will not stop." 5 45
@ -213,7 +292,7 @@ utilities() {
halt
fi
;;
9) return ;;
10) return ;;
esac
done
}
@ -473,14 +552,17 @@ help_menu() {
}
# Parse options
while getopts ":hlw" opt; do
case ${opt} in
h)
echo -e "If script is run without arguments, the main femto-config UI will load.\n\
help="If script is run without arguments, femto-config menu will load.\n\
Options are:\n\
-h This message\n\
-l Set LoRa radio model menu\n\
-w Set Wi-Fi config menu"
-h This message\n\
-l Set LoRa radio cpu_model menu\n\
-w Set Wi-Fi config menu\n\
-L \"true\" Set system logging true/false/check
-i Get system info"
while getopts ":hlwL:i" opt; do
case ${opt} in
h) # Option -h (help)
echo -e $help
;;
l) # Option -l (set lora radio)
set_lora_radio
@ -488,6 +570,18 @@ Options are:\n\
w) # Option -w (Wi-Fi config)
wifi_config
;;
L) # Option -L (Logging)
logging $OPTARG
;;
i) system_info ;;
\?) # Unknown option)
echo -e "Unknown argument $1.\n$help"
;;
:) # Missing argument for option)
echo "Option -$OPTARG requires a setting."
echo -e "$help"
exit 1
;;
esac
done
if [ -n "$1" ]; then

View file

@ -19,7 +19,7 @@ title="Install Wizard"
wizard() {
femto-set-timezone.sh
femto-set-time.sh
new_hostname=$(dialog --title "$title" --cancel-label "Skip" --inputbox "Enter hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then #unless cancel/no

View file

@ -77,7 +77,7 @@ while getopts ":hx:Ts:p:c:ewn:tr" opt; do
;;
e) # Option -e (ethernet settings)
status=$(ip link show eth0 | grep -o 'state [A-Za-z]*' | awk '{print $2}')
echo -e "Ethernet status: $([ "$status" == "UP" ] && echo -e "\033[4m\033[0;32mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")"
echo -e "Ethernet status: $([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")"
if [ "$status" == "UP" ]; then
echo "\nIPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\
IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')"

View file

@ -0,0 +1,90 @@
#!/bin/bash
export NCURSES_NO_UTF8_ACS=1 # prevents weirdness over tty
if [[ $EUID -ne 0 ]]; then
echo -e "This script must be run as root. Try \`sudo femto-set-timezone\`."
exit 1
fi
arg_count=$#
help=$(cat <<EOF
If no argument is specified, a menu system will be used. Options are:
-h This message
-t "TIMEZONE" Set timezone
EOF
)
log_message() {
logger $1
if [ $arg_count -eq 0 ]; then
dialog --msgbox "$1" 12 50
else
echo $1
fi
}
set_timezone() {
if timedatectl set-timezone "$1"; then
log_message "\nTime zone set to $1 (UTC$(date +%z)) successfully."
else
log_message "\nFailed to set the time zone to $1."
exit 1
fi
}
while getopts ":t:h" opt; do
case ${opt} in
t) # Option -t (timezone)
set_timezone "$OPTARG"
;;
h) # Option -h (help)
echo -e "$help"
;;
esac
done
# Fetch available time zones
echo "Loading timezones..."
timezones=$(timedatectl list-timezones)
# Build the options array
options=()
while IFS= read -r timezone; do
options+=("$timezone" "x")
done <<< "$timezones"
# Convert options array to string
options_str=$(printf '%s\n' "${options[@]}")
# Show timezone selection menu with preselection of current timezone
selected_timezone=$(dialog --title "Select Timezone" \
--default-item "$(cat /etc/timezone)" \
--menu "Current timezone: $(cat /etc/timezone) (UTC$(date +%z))" 20 60 10 \
$(printf "%s " "${options[@]}") 3>&1 1>&2 2>&3)
exit_status=$?
if [[ $exit_status -eq 0 && -n "$selected_timezone" ]]; then
# Set the selected time zone
set_timezone $selected_timezone
else
exit 1
fi
DATE=$(echo "$(dialog --title "Select Date" --calendar "Choose a date:\nCurrent date: $(date "+%B %d, %Y")\nPress [TAB] to select." 0 0 $(date +%d) $(date +%m) $(date +%Y) 3>&1 1>&2 2>&3)" | awk -F/ '{printf "%04d-%02d-%02d", $3, $2, $1}')
if [ $? -eq 1 ]; then #if cancel/no
exit 1
fi
TIME=$(dialog --title "Set Time" --timebox "Select time:\nCurrent time: $(date +%H:%M:%S)\nPress [TAB] to select." 0 0 3>&1 1>&2 2>&3) # Dialog timebox for time
if [ $? -eq 1 ]; then #if cancel/no
exit 1
fi
if date -s "$DATE $TIME"; then # set time
if hwclock --systohc; then
rtc="New time successfully saved to RTC."
else
rtc="Unable to communicate with RTC module. An RTC module can save system time between reboots/power outages."
fi
log_message "System time updated to:\n$(date)\n\n$rtc\nTime & date are also set automatically from internet."
else
log_message "Failed to set system time."
exit 1
fi

View file

@ -1,69 +0,0 @@
#!/bin/bash
export NCURSES_NO_UTF8_ACS=1 # prevents weirdness over tty
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. Try \`sudo femto-set-timezone\`."
exit 1
fi
arg_count=$#
help=$(cat <<EOF
If no argument is specified, a menu system will be used. Options are:
-h This message
-t "TIMEZONE" Set timezone
EOF
)
set_timezone() {
if timedatectl set-timezone "$1"; then
msg="Time zone set to $1 successfully."
status=0
else
msg="Failed to set the time zone to $1. Please try again." 8 40
status=1
fi
if [ $arg_count -eq 0 ]; then
dialog --msgbox "$msg" 8 40
else
echo $msg
logger $msg
fi
exit $status
}
while getopts ":t:h" opt; do
case ${opt} in
t) # Option -t (timezone)
set_timezone "$OPTARG"
;;
h) # Option -h (help)
echo -e "$help"
;;
esac
done
# Fetch available time zones
timezones=$(timedatectl list-timezones)
if [[ -z "$timezones" ]]; then
dialog --msgbox "\nFailed to retrieve time zones. Ensure 'timedatectl' is installed and functional." 8 40
return
fi
# Build options for dialog menu
while IFS= read -r timezone; do
options+=("$timezone" "x")
done <<< "$timezones"
# Convert options array to string
options_str=$(printf '%s\n' "${options[@]}")
# Show timezone selection menu
selected_timezone=$(dialog --title "Select Time Zone" --cancel-label "Skip" --menu "Choose a time zone:" 20 60 10 $(printf "%s " "${options[@]}") 3>&1 1>&2 2>&3)
exit_status=$?
if [[ $exit_status -eq 0 && -n "$selected_timezone" ]]; then
# Set the selected time zone
set_timezone $selected_timezone
fi

View file

@ -68,9 +68,9 @@ package_intro() {
$(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\
$(if $package_dir/$1.sh -O | grep -q 'D'; then echo "\n$($package_dir/$1.sh -D)"; fi)\n\
\n\
$(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\
$(if output=$($package_dir/$1.sh -L); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn"; fi)\
$(if output=$($package_dir/$1.sh -C); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn"; fi)\
$(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo " \Zunot installed\Zn")\n\
$(if output=$($package_dir/$1.sh -L); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn\n"; fi)\
$(if output=$($package_dir/$1.sh -C); [ -n "$output" ]; then echo "Conflicts with: \Zu$output\Zn\n"; fi)\
An internet connection is required for installation.\n\
$(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0
package_menu $1 # after user hits "OK", move on to package menu
@ -121,7 +121,7 @@ title="$title"
option=""
option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \
1 "The Comms Channel BBS, TC²BBS" \
2 "Curses Client for Meshtastic" \
2 "Contact (Meshtastic client)" \
3 "Meshing Around by Spud" \
4 "Mosquitto MQTT Broker" \
5 "Mosquitto MQTT Client" \
@ -135,7 +135,7 @@ title="$title"
case $option in
1) package_intro "tc2_bbs" ;;
2) package_intro "curses_client" ;;
2) package_intro "contact_client" ;;
3) package_intro "meshing_around" ;;
4) package_intro "mosquitto_mqtt_broker" ;;
5) package_intro "mosquitto_mqtt_client" ;;
@ -150,4 +150,4 @@ exit 0
# 5 "GPS and Telemetry" \
# 4) mosquitto ;;
# 5) gpsd ;;
# 5) gpsd ;;

View file

@ -204,7 +204,7 @@ if [ -f "$mount_point/femtofox-config.txt" ]; then
if [[ -n "$timezone" ]]; then # set timezone
timezone=$(echo "$timezone" | sed 's/\\//g')
log_message "Updating system timezone to $timezone."
femto-set-timezone.sh -t "$timezone"
femto-set-time.sh -t "$timezone"
found_config="true"
fi

View file

@ -44,14 +44,14 @@ EOF
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
name="Curses Client for Meshtastic" # software name
name="Contact" # software name
author="pdxlocations" # software author - OPTIONAL
description="Command line client using the curses library, powered by Meshtastic.org.\nAfter install, run \`curses\` to launch." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/pdxlocations/curses-client-for-meshtastic/" # software URL. Can contain multiple URLs - OPTIONAL
description="A Text-Based Console UI for Meshtastic Nodes.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/pdxlocations/contact/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiuglNADUOLIto" # script options in use by software package. For example, for a package with no service, exclude `edsr`
launch="python /opt/curses-client-for-meshtastic/main.py --host" # command to launch software, if applicable
launch="python /opt/contact/main.py --host" # command to launch software, if applicable
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="/opt/curses-client-for-meshtastic" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
location="/opt/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
conflicts="" # comma delineated plain-text list of packages with which this package conflicts. Blank if none. Use the name as it appears in the $name field of the other package. Extra plaintext is allowed, such as "packageA, packageB, any other software that uses the Meshtastic CLI"
@ -64,20 +64,20 @@ fi
# install script
install() {
if ! git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic; then
if ! git clone https://github.com/pdxlocations/contact.git /opt/contact; then
echo "user_message: Git clone failed. Is internet connected?"
exit 1
fi
chown -R femto $location #give ownership of installation directory to $user
git config --global --add safe.directory $location # prevents git error when updating
echo "Creating \`curses\` shortcut."
echo "Creating \`contact\` shortcut."
echo -e "#!/bin/bash\n\
export NCURSES_NO_UTF8_ACS=1\n\
export TERM=xterm-256color\n\
export LANG=C.UTF-8\n\
$launch" | sudo tee /usr/local/bin/curses > /dev/null
chmod +x /usr/local/bin/curses
echo "user_message: To launch, run \`curses\`."
$launch" | sudo tee /usr/local/bin/contact > /dev/null
chmod +x /usr/local/bin/contact
echo "user_message: To launch, run \`contact\`."
exit 0 # should be `exit 1` if the installation failed
}
@ -85,7 +85,7 @@ $launch" | sudo tee /usr/local/bin/curses > /dev/null
# uninstall script
uninstall() {
rm -rf $location
rm /usr/local/bin/curses
rm /usr/local/bin/contact
echo "user_message: All files removed."
exit 0 # should be `exit 1` if the installation failed
}

View file

@ -48,7 +48,6 @@ EOF
# Messages to the user (such as configuration instructions, explanatory error messages, etc) should be given as: `echo "user_message: text"`
# Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed
name="Meshing Around" # software name
author="Spud" # software author - OPTIONAL
description="Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features. Connectivity and utility through text-based message delivery. Whether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered." # software description - OPTIONAL (but strongly recommended!)
@ -66,7 +65,7 @@ install() {
exit 1
fi
if [ "$interactive" = "true" ]; then #interactive install
eval "$location/install.sh"
"$location/install.sh" | tee /dev/tty
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
exit 0
else

View file

@ -67,8 +67,8 @@ monitor_changes() {
while true; do
PID=$(ps -C meshtasticd -o pid= | tr -d ' ')
if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID"; then
#if sudo lsof /dev/spidev0.0 | grep -q "meshtasticd"; then
#if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID"; then
if [[ -n "$PID" ]] && sudo lsof /dev/spidev0.0 | grep -q "$PID" && [[ -d /sys/class/net/wlan0 ]]; then
local current_mobile_state current_wlan_state
current_mobile_state=$(get_mobile_wifi_state)
current_wlan_state=$(cat /sys/class/net/wlan0/operstate)

View file

@ -20,4 +20,9 @@ To install Foxbuntu, you'll need the following:
8. The Femtofox will perform its first boot. This can take up to 5 minutes (subsequent boots ~40 seconds). When boot is complete, the USR LED will blink 5 times, 1/2 a second each. At this point, Meshtastic should be running and if you plug in a wifi adapter it should work.
9. To connect to your Femtofox via SSH, open [PuTTY](https://www.putty.org/) or your favorite SSH client and connect to your Femtofox via `femtofox.local` or its IP (check your router).
* Username: `femto`
* Password: `fox`
* Password: `femto`
You will be prompted to change this on first login.
<!--stackedit_data:
eyJoaXN0b3J5IjpbMTM3NzgzMjcyNF19
-->