From a5696fc1fcc28be5c49a4eb6fa3df7e36d2981d2 Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 28 Jan 2025 12:43:31 +0200 Subject: [PATCH 01/24] improve menu UX --- .../usr/local/bin/femto-config | 98 ++++++++++--------- .../usr/local/bin/femto-kernel-modules.sh | 5 +- .../usr/local/bin/femto-runonce.sh | 2 +- .../usr/local/bin/femto-software.sh | 14 +-- 4 files changed, 61 insertions(+), 58 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index d687bb0..df1844b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -48,10 +48,11 @@ wifi_config() { [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" cmd="$cmd -r" if [ -z "$wifi_ssid" ]; then - dialog --no-collapse --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 8 40 + dialog --no-collapse --title "$title2" --msgbox "\nSSID is required to configure Wi-Fi." 7 40 return fi - eval $cmd + echo "Configuring wifi..." + eval $cmd &>/dev/null dialog --no-collapse --title "$title2" --msgbox "Wi-Fi Settings Saved:\nSSID: $wifi_ssid\nPassword: (hidden)\nCountry: $wifi_country\nMeshtastic Wi-Fi setting set to ON" 9 40 if [ "$1" = "-w" ]; then exit 0 @@ -62,10 +63,11 @@ wifi_config() { networking_settings() { local title="Networking" local title2="Wi-Fi (wlan0) Settings" + ip=$(hostname -I | sed 's/ / /g'); ip=${ip:+$(printf "IPv4 address:\n%s" "$ip")} wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" + choice="" # zero the choice before loading the submenu while true; do - local option="" - option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 16 40 4 \ + networking_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$networking_choice" --title "$title" --menu "$ip" $([ -z "$ip" ] && echo 16 || echo 18) 40 4 \ 1 "Turn Wi-Fi on/off" \ 2 "View Wi-Fi settings" \ 3 "Change Wi-Fi settings" \ @@ -73,7 +75,7 @@ networking_settings() { 5 "Restart networking" \ 6 "Set hostname" \ 7 "Test internet connection" \ - "" "" \ + " " "" \ 8 "Back to main menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -81,16 +83,16 @@ networking_settings() { break fi - case $option in + case $networking_choice in 1) # Turn Wi-Fi on/off) if ! ip link show wlan0 &>/dev/null; then dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40 else while true; do - choice=$(dialog --no-collapse --cancel-label "Back" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \ + choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \ 1 "Turn Wi-Fi on" \ 2 "Turn Wi-Fi off" \ - "" "" \ + " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -143,8 +145,7 @@ networking_settings() { utilities() { local title="Utilities" while true; do - local option="" - option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 21 50 4 \ + utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --menu "$title" 21 50 4 \ 1 "View system info" \ 2 "Set system time" \ 3 "Kernel modules" \ @@ -156,7 +157,7 @@ utilities() { 9 "Disable/enable activity LED" \ 10 "Reboot" \ 11 "Shutdown" \ - "" "" \ + " " "" \ 12 "Back to main menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -164,10 +165,11 @@ utilities() { break fi - case $option in + case $utilities_choice in 1) + choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --menu "System info" 17 40 5 \ + choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 17 40 5 \ 1 "CPU" \ 2 "Operating system" \ 3 "Storage & memory" \ @@ -175,14 +177,13 @@ utilities() { 5 "Networking" \ 6 "Meshtastic node info" \ 7 "Complete system info" \ - "" "" \ + " " "" \ 8 "Back to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog break elif [ $exit_status -eq 2 ]; then # Help ("extra") button - dialog --no-collapse --colors --title "System info help" --msgbox "To get system info in terminal (where it can be copied), enter \`\Zusudo femto-utils.sh -i\Zn\`." 7 50 + dialog --no-collapse --colors --title "System info help" --msgbox "To get system info in terminal (where it can be copied), enter \`\Zusudo femto-utils.sh -i\Zn\`.\n\nWhen getting Peripherals & Devices (or Complete System Info) without an i2c device connected, it is normal to see error messages on serial console.\n" 0 0 else case $choice in 1) # CPU) @@ -234,11 +235,12 @@ utilities() { 6) luckfox-config ;; 7) htop ;; 8) # logging) + choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \ + choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \ 1 "Enable (default)" \ 2 "Disable" \ - "" "" \ + " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -252,11 +254,12 @@ utilities() { done ;; 9) # logging) + choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --colors --title "Logging" --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \ + choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \ 1 "Enable (default)" \ 2 "Disable" \ - "" "" \ + " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -290,11 +293,11 @@ utilities() { #set lora radio set_lora_radio() { + choice="" # zero the choice before loading the submenu while true; do echo "Checking LoRa radio..." - local option="" #Display filename, if exists: $(files=$(ls /etc/meshtasticd/config.d/* 2>/dev/null) && [ -n "$files" ] && echo "\n\nConfiguration files in use:\n$files" | paste -sd, -)) - option=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \ + choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \ "Ebyte e22-900m30s" "(SX1262_TCXO)" \ "Ebyte e22-900m22s" "(SX1262_TCXO)"\ "Ebyte e80-900m22s" "(SX1262_XTAL)"\ @@ -303,7 +306,7 @@ set_lora_radio() { "Waveshare sx126x-xxxm" "(SX1262_XTAL)"\ "AI Thinker ra-01sh" "(SX1262_XTAL)"\ "None" "(simulated radio)"\ - "" "" \ + " " "" \ "Skip" "" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -312,7 +315,7 @@ set_lora_radio() { fi local radio="" - case $option in + case $choice in "Ebyte e22-900m30s") radio="sx1262_tcxo" ;; @@ -352,9 +355,8 @@ set_lora_radio() { meshtastic_settings() { local title="Meshtastic Settings" while true; do - echo "Checking Meshtasticd service state..." - local option="" - option=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 19 50 4 \ + echo "Checking Meshtasticd service state..." + meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 19 50 4 \ 1 "View node info" \ 2 "View configuration URL & QR code" \ 3 "Set new configuration URL" \ @@ -364,7 +366,7 @@ meshtastic_settings() { 7 "Manage Meshtasticd service" \ 8 "Upgrade/install Meshtasticd" \ 9 "Uninstall Meshtasticd" \ - "" "" \ + " " "" \ 10 "Back to main menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -372,7 +374,7 @@ meshtastic_settings() { break fi - case $option in + case $meshtastic_choice in 1) # view node info) loading "Getting node info..." dialog --no-collapse --colors --title "Node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 @@ -396,16 +398,17 @@ meshtastic_settings() { set_lora_radio ;; 5) # remote admin) + choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --cancel-label "Back" --title "Meshtastic Security Settings" --menu "" 16 40 5 \ + choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --menu "" 16 40 5 \ 1 "View/change public key" \ 2 "View/change private key" \ - "" "" \ + " " "" \ 3 "View admin keys" \ 4 "Set admin key" \ 5 "Clear admin keys" \ 6 "Legacy admin channel" \ - "" "" \ + " " "" \ 7 "Return to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -463,12 +466,13 @@ meshtastic_settings() { fi ;; 6) # legacy admin) + choice="" # zero the choice before loading the submenu while true; do loading "Getting current legacy admin state..." - choice=$(dialog --no-collapse --colors --title "Legacy Admin" --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \ + choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \ 1 "Enable" \ 2 "Disable (default)" \ - "" "" \ + " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -507,10 +511,11 @@ meshtastic_settings() { fi ;; 7) #manage meshtasticd service) + choice="" # zero the choice before loading the submenu while true; do echo "Checking Meshtasticd service state..." local service_state="$(replace_colors "$(femto-meshtasticd-config.sh -S)")" - choice=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtasticd Service" --menu "Meshtasticd service is $service_state$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 17 52 5 \ + choice=$(dialog --no-collapse --colors --cancel-label "Back" --title "Meshtasticd Service" --default-item "$choice" --menu "Meshtasticd service is $service_state$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Using simulated radio\Zn')" 17 52 5 \ "View detailed service status" "x" \ " " " " \ $(if echo "$service_state" | grep -q 'enabled'; then echo "Start/restart service x"; fi) \ @@ -586,8 +591,7 @@ meshtastic_settings() { help_menu() { while true; do local title="Help / About" - local option="" - option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 7 \ + help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --menu "$title" 0 0 7 \ 1 "About Femtofox" \ 2 "Display pinout" \ 3 "Femtofox licensing info - short" \ @@ -595,7 +599,7 @@ help_menu() { 5 "Meshtastic licensing info" \ 6 "About Luckfox" \ 7 "About Ubuntu" \ - "" "" \ + " " "" \ 8 "Back to main menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -603,19 +607,19 @@ help_menu() { break fi - case $option in + case $help_choice in 1) #About Femtofox) - dialog --no-collapse --title "About Femtofox" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65 + dialog --no-collapse --title "About Femtofox" --default-item "$choice" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65 ;; 2) #Display pinout) + choice="" # zero the choice before loading the submenu while true; do - local option="" - option=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \ + choice=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \ 1 "Femtofox Pro/CE" \ 2 "Femtofox Zero" \ 3 "Femtofox Tiny" \ 4 "Luckfox Pico Mini" \ - "" "" \ + " " "" \ 5 "Back to Help Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -624,7 +628,7 @@ help_menu() { break fi - case $option in + case $choice in 1) dialog --no-collapse --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;; 2) dialog --no-collapse --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 34 48 ;; 3) dialog --no-collapse --title "Femtofox Tiny" --msgbox "$(femto-pinout.sh -t)" 38 70 ;; @@ -686,14 +690,14 @@ fi # Main menu while true; do - choice=$(dialog --no-collapse --cancel-label "Exit" --menu "Femtofox Config" 16 40 5 \ + main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --menu "Femtofox Config" 16 40 5 \ 1 "Settings wizard" \ 2 "Networking" \ 3 "Meshtastic" \ 4 "Software manager" \ 5 "Utilities" \ 6 "Help" \ - "" "" \ + " " "" \ 7 "Exit" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -702,7 +706,7 @@ while true; do break fi - case $choice in + case $main_menu_choice in 1) femto-install-wizard.sh ;; 2) networking_settings ;; 3) meshtastic_settings ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-kernel-modules.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-kernel-modules.sh index 4069523..50df6dc 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-kernel-modules.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-kernel-modules.sh @@ -60,7 +60,7 @@ done while true; do # Create the menu options - option=$(dialog --cancel-label "Back" --title "Kernel Modules" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3) + option=$(dialog --cancel-label "Back" --title "Kernel Modules" --default-item "$selected_module" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3) exit_status=$? # Check the exit status of the dialog command @@ -70,13 +70,12 @@ while true; do # Get the module name from the selection selected_module=$option - # Get the full modinfo for the module and process it for dialog modinfo_output=$(modinfo $selected_module | sed ':a;N;$!ba;s/\n/\\n/g') # add \n to module info # Check if the module is currently enabled if lsmod | grep -q "^$selected_module "; then - dialog --colors --title "Disable Module" --yesno "The module '$selected_module' is currently \Z2\Zuenabled\Zn.\n\nDo you want to disable it?\n\nFull module info:\n$modinfo_output\n\nNote: Unused dependencies will be removed automatically." 25 0 + dialog --colors --title "Disable Module" --yesno "The module '$selected_module' is currently \Z4\Zuenabled\Zn.\n\nDo you want to disable it?\n\nFull module info:\n$modinfo_output\n\nNote: Unused dependencies will be removed automatically." 25 0 if [ $? -eq 0 ]; then dialog --msgbox "$(module_switch $selected_module disable)" 7 60 fi diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 23617d3..006066b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -17,7 +17,7 @@ Re-running this script will resize the filesystem to fit the SD card, allocate a \n\ Re-running this script after first boot should not cause any harm, but may not work as expected.\n\ \n\ -Proceed?" 14 60 +Proceed?" 15 60 if [ $? -eq 1 ]; then #if cancel/no exit 0 fi diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 4ed1a53..1321245 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -17,9 +17,9 @@ install() { #output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --no-collapse --colors --title "$title" --beep --msgbox "\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } @@ -77,10 +77,11 @@ $(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, vis } package_menu() { + choice="" while true; do echo "Loading package menu..." # for each line, check if it's supported by the package, display it if the current install state of the package is appropriate (example: don't display "install" if the package is already installed, don't display "stop service" for a package with no services) - choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 17 45 5 \ + choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 17 45 5 \ $(if $package_dir/$1.sh -O | grep -q 'l' && $package_dir/$1.sh -I; then echo "Run software x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'i' && ! $package_dir/$1.sh -I; then echo "Install x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'u' && $package_dir/$1.sh -I; then echo "Uninstall x"; fi) \ @@ -118,14 +119,13 @@ package_menu() { while true; do title="$title" - option="" - option=$(dialog --no-collapse --cancel-label "Back" --menu "$title" 0 0 6 \ + software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" 0 0 6 \ 1 "The Comms Channel BBS, TC²BBS" \ 2 "Contact (Meshtastic client)" \ 3 "Meshing Around by Spud" \ 4 "Mosquitto MQTT Broker" \ 5 "Mosquitto MQTT Client" \ - "" ""\ + " " ""\ 6 "Back to Main Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -133,7 +133,7 @@ title="$title" break fi - case $option in + case $software_option in 1) package_intro "tc2_bbs" ;; 2) package_intro "contact_client" ;; 3) package_intro "meshing_around" ;; From 0f83ec05556d1dea8b6b2529fa8be6cd61fcb248 Mon Sep 17 00:00:00 2001 From: nagumii Date: Tue, 28 Jan 2025 18:09:43 +0200 Subject: [PATCH 02/24] Improve runonce text. --- .../usr/local/bin/femto-runonce.sh | 31 ++++++++----------- .../usr/local/bin/femto-software.sh | 2 +- 2 files changed, 14 insertions(+), 19 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 006066b..195bcd6 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -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 <> /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 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 1321245..a77c052 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -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 From 6534d4a3a01d304e735c11269f2bbe209a0c5313 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 15:12:53 +0200 Subject: [PATCH 03/24] Add Samba file sharing support, and improve software menu Software menu is now entirely dynamically generated from the contents of /usr/local/bin/packages. To add a new software package, simply create a package file in that directory. --- environment-setup/femtofox.chroot | 3 +- .../usr/local/bin/femto-software.sh | 48 +++--- .../usr/local/bin/packages/contact_client.sh | 2 +- .../usr/local/bin/packages/meshing_around.sh | 2 +- .../bin/packages/mosquitto_mqtt_broker.sh | 2 +- .../bin/packages/mosquitto_mqtt_client.sh | 2 +- .../local/bin/packages/package_template.sh | 4 +- .../usr/local/bin/packages/samba.sh | 146 ++++++++++++++++++ .../usr/local/bin/packages/tc2_bbs.sh | 2 +- 9 files changed, 183 insertions(+), 28 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index e45fae5..4b18cc7 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -27,7 +27,7 @@ ln -sf /usr/share/zoneinfo/UTC /etc/localtime echo "Installing packages..." apt update -DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled +DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled samba if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi DEBIAN_FRONTEND=noninteractive apt upgrade -y --option Dpkg::Options::="--force-confold" @@ -59,6 +59,7 @@ systemctl enable femto-usb-config-tool.service systemctl enable femto-boot-complete.service systemctl enable wifi-mesh-control +systemctl disable smbd nmbd # samba services, can be enabled via menu systemctl disable NetworkManager systemctl disable NetworkManager-dispatcher systemctl disable NetworkManager-wait-online diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index a77c052..f30cfb4 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -116,31 +116,39 @@ package_menu() { done } - +# generate menu from filenames in /usr/local/bin/packages while true; do -title="$title" - software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" 0 0 6 \ - 1 "The Comms Channel BBS, TC²BBS" \ - 2 "Contact (Meshtastic client)" \ - 3 "Meshing Around by Spud" \ - 4 "Mosquitto MQTT Broker" \ - 5 "Mosquitto MQTT Client" \ - " " ""\ - 6 "Back to Main Menu" 3>&1 1>&2 2>&3) - + menu_entries=() + index=1 + for file in /usr/local/bin/packages/*.sh; do + filename=$(basename "$file" .sh) + [[ "$filename" == "package_template" ]] && continue # skip package_template.sh + menu_entries+=("$index" "$(/usr/local/bin/packages/"$filename".sh -N)") + ((index++)) + done + + menu_entries+=(" " "") # add blank line and "Back to Main Menu" entry + menu_entries+=("$index" "Back to main menu") + software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" $((9 + index)) 50 $((index + 1)) "${menu_entries[@]}" 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 $software_option in - 1) package_intro "tc2_bbs" ;; - 2) package_intro "contact_client" ;; - 3) package_intro "meshing_around" ;; - 4) package_intro "mosquitto_mqtt_broker" ;; - 5) package_intro "mosquitto_mqtt_client" ;; - 6) break ;; - esac + + case_block=" case \$software_option in" + index=1 + for file in /usr/local/bin/packages/*.sh; do + filename=$(basename "$file" .sh) + [[ "$filename" == "package_template" ]] && continue # skip package_template.sh + case_block+=" + $index) package_intro \"$filename\" ;;" + ((index++)) + done + + case_block+=" + $index) break ;; + esac" #add return to main menu option + eval "$case_block" # Execute the generated case statement done exit 0 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh index 4e18dd0..082f891 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh @@ -48,7 +48,7 @@ name="Contact" # software name author="pdxlocations" # software author - 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` +options="xiuglNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` 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/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh index 06528da..9d86eac 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh @@ -52,7 +52,7 @@ 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!) URL="https://github.com/SpudGunMan/meshing-around" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="mesh_bot pong_bot mesh_bot_reporting" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2" location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh index e8a264d..a58edf1 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh @@ -53,7 +53,7 @@ name="Mosquitto MQTT Broker" # software name author="Eclipse Foundation" # software author - OPTIONAL description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!) URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedslNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="mosquitto" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh index 834d85c..23b77c0 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh @@ -53,7 +53,7 @@ name="Mosquitto MQTT Client" # software name author="Eclipse Foundation" # software author - OPTIONAL description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!) URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedslNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index 19a5dcd..8af9bc6 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -47,13 +47,13 @@ EOF # Successful operations should `exit 0`, fails should `exit 1` # 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 - +hxiugedsrlNADUOSLCI name="name" # software name author="author" # software author - OPTIONAL description="description" # software description - OPTIONAL (but strongly recommended!) URL="URL" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="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/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh new file mode 100644 index 0000000..dbd2353 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -0,0 +1,146 @@ +#!/bin/bash +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Try \`sudo\`." + exit 1 +fi +if [ $# -eq 0 ]; then + echo "No arguments provided." + echo -e "$help" + exit 1 +fi + +args="$@" # arguments to this script +interaction="true" +help=$(cat <&1 | tee /dev/tty # allows output to be shown onscreen + DEBIAN_FRONTEND=noninteractive apt-get install samba -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + echo "user_message: System comes with a configuration file to share /home/femto. See \`/etc/samba/smb.conf\`." + exit 0 # should be `exit 1` if operation failed +} + + +# uninstall script +uninstall() { + DEBIAN_FRONTEND=noninteractive apt remove -y samba 2>&1 | tee /dev/tty + echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge samba -y\` and \`sudo apt autoremove -y\`." + exit 0 # should be `exit 1` if operation failed +} + + +#upgrade script +upgrade() { + echo "apt update can take a long while..." + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + DEBIAN_FRONTEND=noninteractive apt upgrade -y samba 2>&1 | tee /dev/tty + exit 0 # should be `exit 1` if operation failed +} + +# Check if already installed. `exit 0` if yes, `exit 1` if no +check() { +if dpkg -l | grep -q samba; then + exit 0 +else + exit 1 +fi +} + +while getopts ":h$options" opt; do + case ${opt} in + h) # Option -h (help) + echo -e "$help" + ;; + x) # Option -x (no user interaction available) + interaction="false" + ;; + i) # Option -i (install) + install + ;; + u) # Option -u (uninstall) + uninstall + ;; + g) # Option -g (upgrade) + upgrade + ;; + e) # Option -e (Enable service, if applicable) + systemctl enable $service_name + ;; + d) # Option -d (Disable service, if applicable) + systemctl disable $service_name + ;; + s) # Option -s (Stop service) + systemctl stop $service_name + ;; + r) # Option -r (Start/Restart) + systemctl restart $service_name + ;; + l) # Option -l (Run software) + echo "Launching $name..." + sudo -u ${SUDO_USER:-$(whoami)} $launch + ;; + N) echo -e $name ;; + A) echo -e $author ;; + D) echo $description ;; + U) echo -e $URL ;; + O) echo -e $options ;; + S) # Option -S (Get service status) + systemctl status $service_name + ;; + L) echo -e $location ;; + C) echo -e $conflicts ;; + I) # Option -I (Check if already installed) + check + ;; + esac +done + +exit 0 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh index 66af6c2..74e9244 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh @@ -53,7 +53,7 @@ name="TC2-BBS" # software name author="The Comms Channel" # software author - OPTIONAL description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!) URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrlNADUOSLCIto" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="python /opt/TC2-BBS-mesh/server.py" # command to launch software, if applicable service_name="mesh-bbs" # 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/TC2-BBS-mesh" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` From a1e1009fb31f1149b7e291bc754ad2eaa4eb1816 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 17:42:16 +0200 Subject: [PATCH 04/24] Add samba to chroot --- environment-setup/femtofox.chroot | 13 +++---------- .../usr/local/bin/femto-runonce.sh | 2 +- .../usr/local/bin/femto-software.sh | 3 +-- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 4b18cc7..6e7676a 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -9,23 +9,19 @@ echo "tmpfs /run tmpfs rw,nodev,nosuid,size=32M 0 0" | tee -a /etc/fstab #echo "deb [arch=all signed-by=/etc/apt/keyrings/meshtastic-deb.asc] https://meshtastic.github.io/deb stable main" | tee /etc/apt/sources.list.d/meshtastic-deb.list >/dev/null echo "Removing netdevice rules..." - ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules echo "Setting up kernel modules..." - touch /lib/modules/5.10.160/modules.order touch /lib/modules/5.10.160/modules.builtin depmod -a 5.10.160 if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi echo "Setting localtime to UTC..." - rm /etc/localtime ln -sf /usr/share/zoneinfo/UTC /etc/localtime echo "Installing packages..." - apt update DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" linux-firmware wireless-tools git python3.10-venv libgpiod-dev libyaml-cpp-dev libbluetooth-dev openssl libssl-dev libulfius-dev liborcania-dev evtest screen avahi-daemon protobuf-compiler telnet fonts-noto-color-emoji ninja-build chrony qrencode software-properties-common python-is-python3 python3.10-venv lsof spi-tools python3-luma.oled samba if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi @@ -41,17 +37,17 @@ echo "Installing dependencies for meshing-around and meshtastic cli..." pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi -echo "Setting MOTD..." +echo "Adding Samba configuration..." # add it manually so we're always using the most up to date smb.conf file template from the package +echo -e "\n[home]\npath = /home/femto\nbrowsable = yes\nwritable = yes\nread only = no\ncreate mask = 0775\ndirectory mask = 0775\nvalid users = femto" | sudo tee -a /etc/samba/smb.conf > /dev/null && sudo systemctl restart smbd +echo "Setting MOTD..." mv /etc/update-motd.d/10-help-text /etc/update-motd.d/10-help-text.bak mv /etc/update-motd.d/60-unminimize /etc/update-motd.d/60-unminimize.bak echo "Setting hostname to femtofox..." - echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." - systemctl enable button systemctl enable meshtasticd systemctl enable femto-runonce.service @@ -78,7 +74,6 @@ systemctl disable veritysetup.target systemctl disable systemd-pstore.service echo "Adding femto and pico users/groups..." - groupmod -n femto pico usermod -l femto pico usermod -aG sudo,input femto @@ -86,7 +81,6 @@ echo "femto ALL=(ALL:ALL) ALL" | tee /etc/sudoers.d/femto > /dev/null chmod 440 /etc/sudoers.d/femto # this seems messy, user:group should be set cleanly and not corrected after? OSC: somethings were owned my pico from factory - find / -group pico -exec chgrp femto {} \; 2>/dev/null find / -user pico -exec chown femto {} \; 2>/dev/null usermod -d /home/femto -m femto @@ -97,6 +91,5 @@ usermod -a -G tty femto usermod -a -G dialout femto echo "Cleaning up chroot..." - apt clean && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* && rm -rf /var/tmp/* && find /var/log -type f -exec truncate -s 0 {} + && : > /root/.bash_history && history -c exit diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index 195bcd6..be7cbe1 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -72,7 +72,7 @@ if ! grep -q "eth0" /etc/network/interfaces; then # 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/:$//') +hwaddress ether $mac EOF else log_message "eth0 already exists in /etc/network/interfaces, skipping" diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index f30cfb4..30a4da9 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -11,7 +11,6 @@ install() { echo "Installing $($package_dir/$1.sh -N)..." # Run the installation script, capturing the output and displaying it in real time output=$($package_dir/$1.sh -i) - echo $output install_status=$? # Capture the exit status of the eval command user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present #output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output @@ -37,7 +36,7 @@ uninstall() { dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks else dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks - fi + fi } upgrade() { From 93f086d66c49b8fd0a2406aa3d1a49025f1fcc8c Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 18:13:46 +0200 Subject: [PATCH 05/24] +x --- .../out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh old mode 100644 new mode 100755 From c8e5fbd8db579746f027e5d7732496a3e265fe9a Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 18:51:25 +0200 Subject: [PATCH 06/24] Final commit for Samba? One can hope. --- environment-setup/femtofox.chroot | 2 +- .../usr/local/bin/femto-software.sh | 20 +++++++++---------- .../usr/local/bin/packages/contact_client.sh | 2 ++ .../usr/local/bin/packages/tc2_bbs.sh | 2 ++ 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 6e7676a..1d86242 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -38,7 +38,7 @@ pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beauti if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi echo "Adding Samba configuration..." # add it manually so we're always using the most up to date smb.conf file template from the package -echo -e "\n[home]\npath = /home/femto\nbrowsable = yes\nwritable = yes\nread only = no\ncreate mask = 0775\ndirectory mask = 0775\nvalid users = femto" | sudo tee -a /etc/samba/smb.conf > /dev/null && sudo systemctl restart smbd +echo "\n[home]\npath = /home/femto\nbrowsable = yes\nwritable = yes\nread only = no\ncreate mask = 0775\ndirectory mask = 0775\nvalid users = femto" | sudo tee -a /etc/samba/smb.conf > /dev/null && sudo systemctl restart smbd echo "Setting MOTD..." mv /etc/update-motd.d/10-help-text /etc/update-motd.d/10-help-text.bak diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 30a4da9..bd96cdc 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -13,7 +13,7 @@ install() { output=$($package_dir/$1.sh -i) install_status=$? # Capture the exit status of the eval command user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present - #output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output + output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful dialog --no-collapse --colors --title "$title" --beep --msgbox "\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks @@ -23,7 +23,7 @@ install() { } uninstall() { - dialog --no-collapse --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 + dialog --no-collapse --title "$title" --yesno "\nUninstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -31,7 +31,7 @@ uninstall() { output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty") install_status=$? # Capture the exit status of the eval command user_message=$(echo "$output" | awk '/user_message: / {found=1; split($0, arr, "user_message: "); print arr[2]; next} found {print}' | sed '/^$/q') # grab the user_message, if present - #output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output + output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e "$output")" 0 0 # if there's a user_message, display it with two preceeding line breaks else @@ -40,7 +40,7 @@ uninstall() { } upgrade() { - dialog --no-collapse --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40 + dialog --no-collapse --title "$title" --yesno "\nUpgrade $($package_dir/$1.sh -N)\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -67,7 +67,7 @@ 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\ +$(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\ @@ -105,11 +105,11 @@ package_menu() { "Install") install $1 ;; "Uninstall") uninstall $1 ;; "Upgrade") upgrade $1 ;; - "Enable service") eval "$package_dir/$1.sh -e" ;; - "Disable service") eval "$package_dir/$1.sh -d" ;; - "Stop service") eval "$package_dir/$1.sh -s" ;; - "Start/restart service") eval "$package_dir/$1.sh -r" ;; - "Get service status") dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; + "Enable service") echo "Enabling service..." && eval "$package_dir/$1.sh -e" ;; + "Disable service") echo "Disabling service..." && eval "$package_dir/$1.sh -d" ;; + "Stop service") echo "Stopping service..." && eval "$package_dir/$1.sh -s" ;; + "Start/restart service") echo "Starting/restarting service..." && eval "$package_dir/$1.sh -r" ;; + "Get service status") echo "Getting service status..." && dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; "Back to software manager") break ;; esac done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh index 082f891..00a3bc9 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh @@ -85,7 +85,9 @@ $launch" | sudo tee /usr/local/bin/contact > /dev/null # uninstall script uninstall() { rm -rf $location + echo "Removed \`$location\`." rm /usr/local/bin/contact + echo "Removed \`contact\` shortcut." echo "user_message: All files removed." exit 0 # should be `exit 1` if the installation failed } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh index 74e9244..f9f906c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh @@ -93,7 +93,9 @@ uninstall() { systemctl stop $service_name rm /etc/systemd/system/$service_name.service systemctl daemon-reload + echo "Disabled and removed \`$service_name\` service." rm -rf $location + echo "Removed \`$location\`." echo "user_message: Service removed, all files deleted." exit 0 } From 90a58d9f8de94c9e2c1f3197ff56e362a0952717 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 19:08:02 +0200 Subject: [PATCH 07/24] Add a bit of extra echo to runonce --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index be7cbe1..f38e0e7 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -47,6 +47,7 @@ done sudo resize2fs /dev/mmcblk1p5 sudo resize2fs /dev/mmcblk1p6 sudo resize2fs /dev/mmcblk1p7 + log_message "Resizing filesystem complete" # allocate swap file if [ ! -f /swapfile ]; then # check if swap file already exists From e2d6cb8ac7b317cb79271472c620c81906da8584 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 20:01:02 +0200 Subject: [PATCH 08/24] This time it's GOTTA be the last one, right? ...right? --- .../usr/local/bin/femto-software.sh | 4 ++-- .../local/bin/packages/mosquitto_mqtt_broker.sh | 9 +++++---- .../local/bin/packages/mosquitto_mqtt_client.sh | 3 ++- .../usr/local/bin/packages/package_template.sh | 3 ++- .../usr/local/bin/packages/samba.sh | 17 ++++++++++------- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index bd96cdc..7d2f008 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -105,8 +105,8 @@ package_menu() { "Install") install $1 ;; "Uninstall") uninstall $1 ;; "Upgrade") upgrade $1 ;; - "Enable service") echo "Enabling service..." && eval "$package_dir/$1.sh -e" ;; - "Disable service") echo "Disabling service..." && eval "$package_dir/$1.sh -d" ;; + "Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;; + "Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;; "Stop service") echo "Stopping service..." && eval "$package_dir/$1.sh -s" ;; "Start/restart service") echo "Starting/restarting service..." && eval "$package_dir/$1.sh -r" ;; "Get service status") echo "Getting service status..." && dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh index a58edf1..89b4600 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh @@ -56,6 +56,7 @@ URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIO options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="mosquitto" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2" +package_name="mosquitto" # apt package name, if applicable location="" # 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" @@ -63,7 +64,7 @@ conflicts="" # comma delineated plain-text list of packages with which this pa install() { echo "apt update can take a long while..." DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt-get install mosquitto -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty # allows output to be shown onscreen echo "user_message: Installation requires more setup. For a guide, see https://docs.vultr.com/how-to-install-mosquitto-mqtt-broker-on-ubuntu-24-04" exit 0 # should be `exit 1` if operation failed } @@ -71,7 +72,7 @@ install() { # uninstall script uninstall() { - DEBIAN_FRONTEND=noninteractive apt remove -y mosquitto 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty /usr/local/bin/mosquitto_mqtt_broker.sh -s # stop service /usr/local/bin/mosquitto_mqtt_broker.sh -d # disable service echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge mosquitto -y\` and \`sudo apt autoremove -y\`." @@ -83,13 +84,13 @@ uninstall() { upgrade() { echo "apt update can take a long while..." DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt upgrade -y mosquitto 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty exit 0 # should be `exit 1` if operation failed } # Check if already installed. `exit 0` if yes, `exit 1` if no check() { -if dpkg -l | grep -q mosquitto; then +if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then exit 0 else exit 1 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh index 23b77c0..f51b883 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh @@ -57,6 +57,7 @@ options="xiugedsrNADUOSCI" # script options in use by software package. For ex launch="" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` +package_name="mosquitto-clients" # apt package name, if applicable 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" # install script @@ -87,7 +88,7 @@ upgrade() { # Check if already installed. `exit 0` if yes, `exit 1` if no check() { -if dpkg -l | grep -q mosquitto-clients; then +if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then exit 0 else exit 1 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index 8af9bc6..debf87c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -56,6 +56,7 @@ URL="URL" # software URL. Can contain multiple URLs - OPTIONAL options="xiugedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="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" +package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` conflicts="package name, other package name" # 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" @@ -91,7 +92,7 @@ check() { fi # this works for apt packages - if [ dpkg -l | grep -q package-name ] ; then + if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then exit 0 else exit 1 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh index dbd2353..60eb4cd 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -51,28 +51,31 @@ EOF name="Samba File Sharing" # software name author="Software Freedom Conservancy" # software author - OPTIONAL -description="Samba is a free software re-implementation of the SMB networking protocol, and was originally developed by Andrew Tridgell. Samba provides file and print services for various Microsoft Windows clients[5] and can integrate with a Microsoft Windows Server domain, either as a Domain Controller (DC) or as a domain member. As of version 4, it supports Active Directory and Microsoft Windows NT domains." # software description - OPTIONAL (but strongly recommended!) +description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients." # software description - OPTIONAL (but strongly recommended!) URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="smbd nmbd" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` +package_name="samba" # apt package name, if applicable 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" # install script install() { echo "apt update can take a long while..." DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt-get install samba -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - echo "user_message: System comes with a configuration file to share /home/femto. See \`/etc/samba/smb.conf\`." + DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + echo -e "user_message: IMPORTANT: To complete installation, run \`sudo smbpasswd femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares." exit 0 # should be `exit 1` if operation failed } # uninstall script uninstall() { - DEBIAN_FRONTEND=noninteractive apt remove -y samba 2>&1 | tee /dev/tty - echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge samba -y\` and \`sudo apt autoremove -y\`." + DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty + echo "Removing unused dependencies..." + DEBIAN_FRONTEND=noninteractive apt autoremove -y $package_name 2>&1 | tee /dev/tty + echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge $package_name -y\` and \`sudo apt autoremove -y\`." exit 0 # should be `exit 1` if operation failed } @@ -81,13 +84,13 @@ uninstall() { upgrade() { echo "apt update can take a long while..." DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt upgrade -y samba 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty exit 0 # should be `exit 1` if operation failed } # Check if already installed. `exit 0` if yes, `exit 1` if no check() { -if dpkg -l | grep -q samba; then +if dpkg-query -W -f='${Status}' $package_name 2>/dev/null | grep -q "install ok installed"; then exit 0 else exit 1 From cfe2e19e408a9f67e3dfaba9e28e3256062bb275 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 20:38:16 +0200 Subject: [PATCH 09/24] Fix activation command helptext --- .../out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh index 60eb4cd..ec40932 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -51,7 +51,7 @@ EOF name="Samba File Sharing" # software name author="Software Freedom Conservancy" # software author - OPTIONAL -description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients." # software description - OPTIONAL (but strongly recommended!) +description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients." # software description - OPTIONAL (but strongly recommended!) URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable @@ -65,7 +65,7 @@ install() { echo "apt update can take a long while..." DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - echo -e "user_message: IMPORTANT: To complete installation, run \`sudo smbpasswd femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares." + echo -e "user_message: IMPORTANT: To complete installation, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares." exit 0 # should be `exit 1` if operation failed } From 464551d0bb3cb4c8d33903ece4d801e2f8966b73 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 29 Jan 2025 22:17:32 +0200 Subject: [PATCH 10/24] Switch smb.conf to git source --- environment-setup/femtofox.chroot | 3 - .../rootfs_uclibc_rv1106/etc/samba/smb.conf | 253 ++++++++++++++++++ 2 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 1d86242..dde7ebd 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -37,9 +37,6 @@ echo "Installing dependencies for meshing-around and meshtastic cli..." pip3 install requests pyephem pytap2 meshtastic pypubsub geopy maidenhead beautifulsoup4 dadjokes schedule wikipedia googlesearch-python if [[ $? -eq 2 ]]; then echo "Error, step failed..."; fi -echo "Adding Samba configuration..." # add it manually so we're always using the most up to date smb.conf file template from the package -echo "\n[home]\npath = /home/femto\nbrowsable = yes\nwritable = yes\nread only = no\ncreate mask = 0775\ndirectory mask = 0775\nvalid users = femto" | sudo tee -a /etc/samba/smb.conf > /dev/null && sudo systemctl restart smbd - echo "Setting MOTD..." mv /etc/update-motd.d/10-help-text /etc/update-motd.d/10-help-text.bak mv /etc/update-motd.d/60-unminimize /etc/update-motd.d/60-unminimize.bak diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf new file mode 100644 index 0000000..4fa791a --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/samba/smb.conf @@ -0,0 +1,253 @@ +# +# Sample configuration file for the Samba suite for Debian GNU/Linux. +# +# +# This is the main Samba configuration file. You should read the +# smb.conf(5) manual page in order to understand the options listed +# here. Samba has a huge number of configurable options most of which +# are not shown in this example +# +# Some options that are often worth tuning have been included as +# commented-out examples in this file. +# - When such options are commented with ";", the proposed setting +# differs from the default Samba behaviour +# - When commented with "#", the proposed setting is the default +# behaviour of Samba but the option is considered important +# enough to be mentioned here +# +# NOTE: Whenever you modify this file you should run the command +# "testparm" to check that you have not made any basic syntactic +# errors. + +#======================= Global Settings ======================= + +[global] + +## Browsing/Identification ### + +# Change this to the workgroup/NT-domain name your Samba server will part of + workgroup = WORKGROUP + +# server string is the equivalent of the NT Description field + server string = %h server (Samba, Ubuntu) + +#### Networking #### + +# The specific set of interfaces / networks to bind to +# This can be either the interface name or an IP address/netmask; +# interface names are normally preferred +; interfaces = 127.0.0.0/8 eth0 + +# Only bind to the named interfaces and/or networks; you must use the +# 'interfaces' option above to use this. +# It is recommended that you enable this feature if your Samba machine is +# not protected by a firewall or is a firewall itself. However, this +# option cannot handle dynamic or non-broadcast interfaces correctly. +; bind interfaces only = yes + + + +#### Debugging/Accounting #### + +# This tells Samba to use a separate log file for each machine +# that connects + log file = /var/log/samba/log.%m + +# Cap the size of the individual log files (in KiB). + max log size = 1000 + +# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}. +# Append syslog@1 if you want important messages to be sent to syslog too. + logging = file + +# For more verbose logging: +; log level = 3 + +# Do something sensible when Samba crashes: mail the admin a backtrace + panic action = /usr/share/samba/panic-action %d + + +####### Authentication ####### + +# Server role. Defines in which mode Samba will operate. Possible +# values are "standalone server", "member server", "classic primary +# domain controller", "classic backup domain controller", "active +# directory domain controller". +# +# Most people will want "standalone server" or "member server". +# Running as "active directory domain controller" will require first +# running "samba-tool domain provision" to wipe databases and create a +# new domain. + server role = standalone server + + obey pam restrictions = yes + +# This boolean parameter controls whether Samba attempts to sync the Unix +# password with the SMB password when the encrypted SMB password in the +# passdb is changed. + unix password sync = yes + +# For Unix password sync to work on a Debian GNU/Linux system, the following +# parameters must be set (thanks to Ian Kahan < for +# sending the correct chat script for the passwd program in Debian Sarge). + passwd program = /usr/bin/passwd %u + passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* . + +# This boolean controls whether PAM will be used for password changes +# when requested by an SMB client instead of the program listed in +# 'passwd program'. The default is 'no'. + pam password change = yes + +# This option controls how unsuccessful authentication attempts are mapped +# to anonymous connections + map to guest = bad user + +########## Domains ########### + +# +# The following settings only takes effect if 'server role = classic +# primary domain controller', 'server role = classic backup domain controller' +# or 'domain logons' is set +# + +# It specifies the location of the user's +# profile directory from the client point of view) The following +# required a [profiles] share to be setup on the samba server (see +# below) +; logon path = \\%N\profiles\%U +# Another common choice is storing the profile in the user's home directory +# (this is Samba's default) +# logon path = \\%N\%U\profile + +# The following setting only takes effect if 'domain logons' is set +# It specifies the location of a user's home directory (from the client +# point of view) +; logon drive = H: +# logon home = \\%N\%U + +# The following setting only takes effect if 'domain logons' is set +# It specifies the script to run during logon. The script must be stored +# in the [netlogon] share +# NOTE: Must be store in 'DOS' file format convention +; logon script = logon.cmd + +# This allows Unix users to be created on the domain controller via the SAMR +# RPC pipe. The example command creates a user account with a disabled Unix +# password; please adapt to your needs +; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u + +# This allows machine accounts to be created on the domain controller via the +# SAMR RPC pipe. +# The following assumes a "machines" group exists on the system +; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u + +# This allows Unix groups to be created on the domain controller via the SAMR +# RPC pipe. +; add group script = /usr/sbin/addgroup --force-badname %g + +############ Misc ############ + +# Using the following line enables you to customise your configuration +# on a per machine basis. The %m gets replaced with the netbios name +# of the machine that is connecting +; include = /home/samba/etc/smb.conf.%m + +# Some defaults for winbind (make sure you're not using the ranges +# for something else.) +; idmap config * : backend = tdb +; idmap config * : range = 3000-7999 +; idmap config YOURDOMAINHERE : backend = tdb +; idmap config YOURDOMAINHERE : range = 100000-999999 +; template shell = /bin/bash + +# Setup usershare options to enable non-root users to share folders +# with the net usershare command. + +# Maximum number of usershare. 0 means that usershare is disabled. +# usershare max shares = 100 + +# Allow users who've been granted usershare privileges to create +# public shares, not just authenticated ones + usershare allow guests = yes + +#======================= Share Definitions ======================= + +# Un-comment the following (and tweak the other settings below to suit) +# to enable the default home directory shares. This will share each +# user's home directory as \\server\username +;[homes] +; comment = Home Directories +; browseable = no + +# By default, the home directories are exported read-only. Change the +# next parameter to 'no' if you want to be able to write to them. +; read only = yes + +# File creation mask is set to 0700 for security reasons. If you want to +# create files with group=rw permissions, set next parameter to 0775. +; create mask = 0700 + +# Directory creation mask is set to 0700 for security reasons. If you want to +# create dirs. with group=rw permissions, set next parameter to 0775. +; directory mask = 0700 + +# By default, \\server\username shares can be connected to by anyone +# with access to the samba server. +# Un-comment the following parameter to make sure that only "username" +# can connect to \\server\username +# This might need tweaking when using external authentication schemes +; valid users = %S + +# Un-comment the following and create the netlogon directory for Domain Logons +# (you need to configure Samba to act as a domain controller too.) +;[netlogon] +; comment = Network Logon Service +; path = /home/samba/netlogon +; guest ok = yes +; read only = yes + +# Un-comment the following and create the profiles directory to store +# users profiles (see the "logon path" option above) +# (you need to configure Samba to act as a domain controller too.) +# The path below should be writable by all users so that their +# profile directory may be created the first time they log on +;[profiles] +; comment = Users profiles +; path = /home/samba/profiles +; guest ok = no +; browseable = no +; create mask = 0600 +; directory mask = 0700 + +[printers] + comment = All Printers + browseable = no + path = /var/spool/samba + printable = yes + guest ok = no + read only = yes + create mask = 0700 + +# Windows clients look for this share name as a source of downloadable +# printer drivers +[print$] + comment = Printer Drivers + path = /var/lib/samba/printers + browseable = yes + read only = yes + guest ok = no +# Uncomment to allow remote administration of Windows print drivers. +# You may need to replace 'lpadmin' with the name of the group your +# admin users are members of. +# Please note that you also need to set appropriate Unix permissions +# to the drivers directory for these users to have write rights in it +; write list = root, @lpadmin + +[home] +path = /home/femto +browseable = yes +writable = yes +read only = no +create mask = 0775 +directory mask = 0775 +valid users = femto \ No newline at end of file From 8c5b94da52e17e51bec0dfde420bf25993b1f05e Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 30 Jan 2025 00:09:42 +0200 Subject: [PATCH 11/24] Complete samba support. Pretty please? --- .../usr/local/bin/femto-runonce.sh | 17 +++++++++-------- .../local/bin/packages/mosquitto_mqtt_broker.sh | 8 ++++---- .../local/bin/packages/mosquitto_mqtt_client.sh | 8 ++++---- .../usr/local/bin/packages/package_template.sh | 3 ++- .../usr/local/bin/packages/samba.sh | 12 ++++++------ 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index f38e0e7..db38faa 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -44,21 +44,22 @@ done # 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 - sudo resize2fs /dev/mmcblk1p6 - sudo resize2fs /dev/mmcblk1p7 + resize2fs /dev/mmcblk1p5 + resize2fs /dev/mmcblk1p6 + resize2fs /dev/mmcblk1p7 log_message "Resizing filesystem complete" # allocate swap file 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 + log_message "Allocating swap file" + fallocate -l 1G /swapfile + chmod 600 /swapfile + mkswap /swapfile > /dev/null + swapon /swapfile > /dev/null echo '/swapfile none swap sw 0 0' | tee -a /etc/fstab > /dev/null log_message "Swap file allocated." else - log_message "Swap file already allocated, skipping." + log_message "Swap file already allocated, skipping" fi # add RTC support - looks unneeded? diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh index 89b4600..a901fc7 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh @@ -63,8 +63,8 @@ conflicts="" # comma delineated plain-text list of packages with which this pa # install script install() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; } echo "user_message: Installation requires more setup. For a guide, see https://docs.vultr.com/how-to-install-mosquitto-mqtt-broker-on-ubuntu-24-04" exit 0 # should be `exit 1` if operation failed } @@ -83,8 +83,8 @@ uninstall() { #upgrade script upgrade() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; } exit 0 # should be `exit 1` if operation failed } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh index f51b883..46fbed4 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh @@ -63,8 +63,8 @@ conflicts="" # comma delineated plain-text list of packages with which this pa # install script install() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt-get install mosquitto-clients -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; } echo "user_message: Installation requires more setup. For a guide, see https://docs.vultr.com/how-to-install-mosquitto-mqtt-broker-on-ubuntu-24-04" exit 0 # should be `exit 1` if operation failed } @@ -81,8 +81,8 @@ uninstall() { #upgrade script upgrade() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt upgrade -y mosquitto-clients 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; } exit 0 # should be `exit 1` if operation failed } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index debf87c..6ef49bd 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -63,7 +63,8 @@ conflicts="package name, other package name" # comma delineated plain-text lis # install script install() { # for apt packages, this method allows onscreen output during install: - # DEBIAN_FRONTEND=noninteractive sudo apt-get install mosquitto -y 2>&1 | tee /dev/tty # allows output to be shown onscreen + # DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty || { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + # DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty || { echo "user_message: apt install failed. Is internet connected?"; exit 1; } echo "user_message: Exit message to user, displayed prominently in post-install" exit 0 # should be `exit 1` if operation failed } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh index ec40932..1addff3 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -51,7 +51,7 @@ EOF name="Samba File Sharing" # software name author="Software Freedom Conservancy" # software author - OPTIONAL -description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients." # software description - OPTIONAL (but strongly recommended!) +description="Femtofox comes with Samba preinstalled but disabled. To enable file sharing, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nSamba is an open-source implementation of the SMB/CIFS protocol that enables file and printer sharing between Linux/Unix and Windows systems. It allows Linux machines to act as file servers, domain controllers, or Active Directory members, making them accessible from Windows and other SMB-compatible clients.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." # software description - OPTIONAL (but strongly recommended!) URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable @@ -63,9 +63,9 @@ conflicts="" # comma delineated plain-text list of packages with which this pa # install script install() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - echo -e "user_message: IMPORTANT: To complete installation, run \`sudo smbpasswd -a femto\` to set a Samba password, and enable the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares." + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; } + echo -e "user_message: IMPORTANT: To complete installation, enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and restart the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." exit 0 # should be `exit 1` if operation failed } @@ -83,8 +83,8 @@ uninstall() { #upgrade script upgrade() { echo "apt update can take a long while..." - DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty # allows output to be shown onscreen - DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty + DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + DEBIAN_FRONTEND=noninteractive apt upgrade -y $package_name 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt upgrade failed. Is internet connected?"; exit 1; } exit 0 # should be `exit 1` if operation failed } From 03dddff7164428f049287d703faac88c3941ae7c Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 30 Jan 2025 11:29:07 +0200 Subject: [PATCH 12/24] Updated run once messages --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh index db38faa..04367ea 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh @@ -43,7 +43,7 @@ done ) & # Perform filesystem resize - log_message "Resizing filesystem. This can take up to 10 minutes, depending on microSD card size and speed" + log_message "Resizing filesystem. This can take several minutes, depending on microSD card size and speed" resize2fs /dev/mmcblk1p5 resize2fs /dev/mmcblk1p6 resize2fs /dev/mmcblk1p7 @@ -51,7 +51,7 @@ done # allocate swap file if [ ! -f /swapfile ]; then # check if swap file already exists - log_message "Allocating swap file" + log_message "Allocating swap file. This can take up to 10 minutes, depending on microSD card speed" fallocate -l 1G /swapfile chmod 600 /swapfile mkswap /swapfile > /dev/null From 8521180d783effc3f68158557eb6d56a1c72c66c Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 30 Jan 2025 13:51:18 +0200 Subject: [PATCH 13/24] allow samba (and meshing around) initialization from menu --- .../usr/local/bin/femto-software.sh | 20 +++++++++-- .../usr/local/bin/packages/meshing_around.sh | 17 +++++++--- .../local/bin/packages/package_template.sh | 14 +++++--- .../usr/local/bin/packages/samba.sh | 34 ++++++++++++++----- 4 files changed, 66 insertions(+), 19 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 7d2f008..425229d 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -39,6 +39,21 @@ uninstall() { fi } +initialize() { + dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that frequently require user interaction and so can only be run from terminal.\n\nProceed?" 13 50 + if [ $? -eq 1 ]; then #if cancel/no + return 1 + fi + clear + echo "Initializing $($package_dir/$1.sh -N)..." + eval "$package_dir/$1.sh -a" + if [ $? -eq 0 ]; then # if the installation was successful + dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) successful!" 8 50 # if there's a user_message, display it with two preceeding line breaks + else + dialog --no-collapse --colors --title "$title" --beep --msgbox "\nInitialization of $($package_dir/$1.sh -N) FAILED!" 8 50 # if there's a user_message, display it with two preceeding line breaks + fi +} + upgrade() { dialog --no-collapse --title "$title" --yesno "\nUpgrade $($package_dir/$1.sh -N)\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no @@ -54,7 +69,6 @@ upgrade() { else dialog --no-collapse --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks fi - } @@ -80,10 +94,11 @@ package_menu() { while true; do echo "Loading package menu..." # for each line, check if it's supported by the package, display it if the current install state of the package is appropriate (example: don't display "install" if the package is already installed, don't display "stop service" for a package with no services) - choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 17 45 5 \ + choice=$(dialog --no-collapse --title "$title" --cancel-label "Back" --default-item "$choice" --menu "$($package_dir/$1.sh -N)" 18 45 5 \ $(if $package_dir/$1.sh -O | grep -q 'l' && $package_dir/$1.sh -I; then echo "Run software x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'i' && ! $package_dir/$1.sh -I; then echo "Install x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'u' && $package_dir/$1.sh -I; then echo "Uninstall x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'a' && $package_dir/$1.sh -I; then echo "Initialize x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'g' && $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'e' && $package_dir/$1.sh -I; then echo "Enable service x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'd' && $package_dir/$1.sh -I; then echo "Disable service x"; fi) \ @@ -104,6 +119,7 @@ package_menu() { "Run software") eval "$package_dir/$1.sh -l" ;; "Install") install $1 ;; "Uninstall") uninstall $1 ;; + "Initialize") initialize $1 ;; "Upgrade") upgrade $1 ;; "Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;; "Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh index 9d86eac..bf45a13 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh @@ -19,6 +19,7 @@ Arguments: Actions: -i Install -u Uninstall +-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal -g Upgrade -e Enable service, if applicable -d Disable service, if applicable @@ -52,7 +53,7 @@ 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!) URL="https://github.com/SpudGunMan/meshing-around" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiuagedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="mesh_bot pong_bot mesh_bot_reporting" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2" location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` @@ -65,16 +66,13 @@ install() { exit 1 fi if [ "$interactive" = "true" ]; then #interactive install - "$location/install.sh" | tee /dev/tty - echo "user_message: To change settings, run \`sudo nano $location/config.ini\`" - exit 0 + interactive_init else echo "user_message: IMPORTANT: To complete installation, run \`sudo $location/install.sh\`\nTo change settings, run \`sudo nano $location/config.ini\`" exit 0 fi } - # uninstall script uninstall() { # stop, disable and remove the service, reload systemctl daemon, remove the installation directory and quit @@ -96,6 +94,12 @@ uninstall() { exit 0 } +# code that must be run to initialize the installation prior to use, but can only be run from terminal +interactive_init() { + "$location/install.sh" | tee /dev/tty + echo "user_message: To change settings, run \`sudo nano $location/config.ini\`" + exit 0 +} #upgrade script upgrade() { @@ -129,6 +133,9 @@ while getopts ":h$options" opt; do i) # Option -i (install) install ;; + a) # Option -a (interactive initialization) + interactive_init + ;; u) # Option -u (uninstall) uninstall ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index 6ef49bd..30fe0e3 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -10,7 +10,7 @@ if [ $# -eq 0 ]; then fi args="$@" # arguments to this script -interaction="true" +interactive="true" help=$(cat <&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } - DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; } - echo -e "user_message: IMPORTANT: To complete installation, enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and restart the Samba service.\nTo connect to network share, enter \`\\\\\\\\femtofox\` from Windows, \`smb://$(hostname)\` from MacOS and \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." - exit 0 # should be `exit 1` if operation failed + # DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; } + # DEBIAN_FRONTEND=noninteractive apt-get install $package_name -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt install failed. Is internet connected?"; exit 1; } + if [ "$interactive" = "true" ]; then # interactive install + interactive_init + else # noninteractive installation (such as web-UI) + echo -e "user_message: IMPORTANT: $init_instructions\n\n$user_message" + exit 0 # should be `exit 1` if operation failed + fi } - # uninstall script uninstall() { DEBIAN_FRONTEND=noninteractive apt remove -y $package_name 2>&1 | tee /dev/tty @@ -79,6 +85,15 @@ uninstall() { exit 0 # should be `exit 1` if operation failed } +# code that must be run to initialize the installation prior to use, but can only be run from terminal +interactive_init() { + $(basename "$0" -e) + echo -e "\nSet user \`Femto\` login password:" + smbpasswd -a femto + $(basename "$0" -r) + echo -e "user_message: Samba initialized, and service enabled and started. $user_message" + exit 0 +} #upgrade script upgrade() { @@ -108,6 +123,9 @@ while getopts ":h$options" opt; do i) # Option -i (install) install ;; + a) # Option -a (interactive initialization) + interactive_init + ;; u) # Option -u (uninstall) uninstall ;; From 7bac1c22d68dd977dfc718440110cc81ec5b9756 Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 30 Jan 2025 14:17:43 +0200 Subject: [PATCH 14/24] Complete samba? --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh | 2 +- .../rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 425229d..4ca5354 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -40,7 +40,7 @@ uninstall() { } initialize() { - dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that frequently require user interaction and so can only be run from terminal.\n\nProceed?" 13 50 + dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nProceed?" 13 50 if [ $? -eq 1 ]; then #if cancel/no return 1 fi diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh index a22fc03..d085851 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -49,7 +49,7 @@ 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 -user_message="To connect to network share, enter \`\\\\\\\\femtofox\\home\` from Windows, \`smb://$(hostname)\\home\` from MacOS or \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." +user_message="To connect to network share, enter \`\\\\femtofox\\home\` from Windows, \`smb://$(hostname)\\home\` from MacOS or \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu, or enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and then restart the Samba service." name="Samba File Sharing" # software name @@ -87,10 +87,10 @@ uninstall() { # code that must be run to initialize the installation prior to use, but can only be run from terminal interactive_init() { - $(basename "$0" -e) echo -e "\nSet user \`Femto\` login password:" smbpasswd -a femto - $(basename "$0" -r) + /usr/local/bin/packages/samba.sh -e + /usr/local/bin/packages/samba.sh -r echo -e "user_message: Samba initialized, and service enabled and started. $user_message" exit 0 } From 44ef16e14fa05965cb0beb39b24183420f63bf93 Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 30 Jan 2025 14:21:01 +0200 Subject: [PATCH 15/24] increment foxbuntu version --- foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release index f0d747a..6ff82f2 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/foxbuntu-release @@ -1,6 +1,6 @@ major=0 -minor=97 -patch=5 +minor=98 +patch=0 hotfix= # major, minor and patch must be numbers and populated. hotfix must be letters and can be blank. From 62e1d7f8494c430d842c3c4d255cbfa62fd1b04e Mon Sep 17 00:00:00 2001 From: Ruledo Date: Thu, 30 Jan 2025 22:53:26 -0800 Subject: [PATCH 16/24] Disabled unattened-upgrades and apt periodic updates Disabled service and changed apt setting. --- environment-setup/femtofox.chroot | 1 + .../out/rootfs_uclibc_rv1106/etc/apt/apt.conf.d/20auto-upgrades | 2 ++ 2 files changed, 3 insertions(+) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/apt/apt.conf.d/20auto-upgrades diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index dde7ebd..514ca2f 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -52,6 +52,7 @@ systemctl enable femto-usb-config-tool.service systemctl enable femto-boot-complete.service systemctl enable wifi-mesh-control +systemctl disable unattended-upgrades systemctl disable smbd nmbd # samba services, can be enabled via menu systemctl disable NetworkManager systemctl disable NetworkManager-dispatcher diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/apt/apt.conf.d/20auto-upgrades b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/apt/apt.conf.d/20auto-upgrades new file mode 100644 index 0000000..42589c7 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/apt/apt.conf.d/20auto-upgrades @@ -0,0 +1,2 @@ +APT::Periodic::Update-Package-Lists "0"; +APT::Periodic::Unattended-Upgrade "0"; From 2b6b6f6847c01f057e60fac9d4928c65d6cd5668 Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 31 Jan 2025 15:10:58 +0200 Subject: [PATCH 17/24] Try remove `luckfox-config load` --- .../overlay-luckfox-ubuntu/etc/rc.local | 2 +- .../usr/local/bin/femto-software.sh | 17 +++++--------- .../usr/local/bin/packages/contact_client.sh | 4 ++-- .../local/bin/packages/package_template.sh | 22 +++++++++---------- .../usr/local/bin/packages/tc2_bbs.sh | 2 +- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local index 4e7b166..33b65da 100755 --- a/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local +++ b/foxbuntu/project/cfg/BoardConfig_IPC/overlay/overlay-luckfox-ubuntu/etc/rc.local @@ -8,7 +8,7 @@ # /usr/local/bin/femto-runonce.sh #fi -luckfox-config load +#luckfox-config load # try enable RTC echo 'ds1307 0x68' | sudo tee /sys/class/i2c-adapter/i2c-3/new_device > /dev/null 2>&1 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index 4ca5354..ac97796 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -4,7 +4,7 @@ title="Software Manager" package_dir="/usr/local/bin/packages" install() { - dialog --no-collapse --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 + dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -23,7 +23,7 @@ install() { } uninstall() { - dialog --no-collapse --title "$title" --yesno "\nUninstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 + dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nReinstallation will require internet connectivity.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -55,7 +55,7 @@ initialize() { } upgrade() { - dialog --no-collapse --title "$title" --yesno "\nUpgrade $($package_dir/$1.sh -N)\n\nProceed?" 10 40 + dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -116,7 +116,7 @@ package_menu() { # execute the actual commands case $choice in - "Run software") eval "$package_dir/$1.sh -l" ;; + "Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$package_dir/$1.sh -l" ;; "Install") install $1 ;; "Uninstall") uninstall $1 ;; "Initialize") initialize $1 ;; @@ -166,11 +166,4 @@ while true; do eval "$case_block" # Execute the generated case statement done -exit 0 - - - # 4 "Mosquitto MQTT broker" \ - # 5 "GPS and Telemetry" \ - - # 4) mosquitto ;; - # 5) gpsd ;; +exit 0 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh index 00a3bc9..10f8aa3 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/contact_client.sh @@ -46,9 +46,9 @@ EOF name="Contact" # software name author="pdxlocations" # software author - OPTIONAL -description="A Text-Based Console UI for Meshtastic Nodes.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!) +description="A Text-Based Console UI for Meshtastic Nodes. Formerly called Curse Client.\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="xiuglNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiuglNADUOLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS` 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/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index 30fe0e3..c4c94f6 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -49,16 +49,16 @@ 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="name" # software name -author="author" # software author - OPTIONAL -description="description" # software description - OPTIONAL (but strongly recommended!) -URL="URL" # software URL. Can contain multiple URLs - OPTIONAL -options="xiuagedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` -launch="" # command to launch software, if applicable -service_name="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" -package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't -location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` -conflicts="package name, other package name" # 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" +name="name" # software name +author="author" # software author - OPTIONAL +description="description" # software description - OPTIONAL (but strongly recommended!) +URL="URL" # software URL. Can contain multiple URLs - OPTIONAL +options="hxiuagedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS` +launch="/opt/package/run.sh" # command to launch software, if applicable +service_name="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" +package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't +location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` +conflicts="package1, package2" # 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" # install script install() { @@ -103,7 +103,7 @@ check() { fi } -while getopts ":h$options" opt; do +while getopts ":$options" opt; do case ${opt} in h) # Option -h (help) echo -e "$help" diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh index f9f906c..30f7160 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh @@ -49,7 +49,7 @@ EOF # Everything following `user_message: ` will be displayed prominently to the user, so it must the last thing echoed -name="TC2-BBS" # software name +name="TC²-BBS" # software name author="The Comms Channel" # software author - OPTIONAL description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!) URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL From 1a1133d7b173c49ca925bd0450481484b54e2de9 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 00:59:13 +0200 Subject: [PATCH 18/24] Begin refactor of method data is supplied by scripts and displayed by menus --- .../out/rootfs_uclibc_rv1106/root/.dialogrc | 27 ++++ .../usr/local/bin/femto-config | 147 +++++++----------- .../usr/local/bin/femto-meshtasticd-config.sh | 62 +++++--- .../usr/local/bin/femto-software.sh | 30 +--- .../usr/local/bin/femto-utils.sh | 4 +- 5 files changed, 133 insertions(+), 137 deletions(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc new file mode 100644 index 0000000..9783b2c --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc @@ -0,0 +1,27 @@ +# +# Run-time configuration file for dialog +# +# Automatically generated by "dialog --create-rc " +# +# +# Types of values: +# +# Number - +# String - "string" +# Boolean - +# Attribute - (foreground,background,highlight?,underline?,reverse?) + +# Up arrow color +uarrow_color = (GREEN,WHITE,ON) + +# Down arrow color +darrow_color = uarrow_color + +# Active form text color +form_active_text_color = button_active_color + +# Form text color +form_text_color = (WHITE,CYAN,ON) + +# Readonly form item color +form_item_readonly_color = (BLUE,WHITE,ON) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index df1844b..023d12a 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -37,13 +37,40 @@ loading() { dialog --no-collapse --infobox "$1" 5 45 } +# function to pull data from various femto scripts and convert it to the contents of a read only dialog --form +ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width` + unset output_array #debug code, delete me + declare -a output_array + # Read the output from femto-meshtasticd-config.sh and store it in the array + while IFS=':' read -r key value; do + # Trim leading/trailing spaces from key and value + key=$(echo "$key" | xargs) + value=$(echo "$value" | xargs) + output_array+=("$key=$value") # Use indexed array to preserve order + done < <(eval $1) + form_contents="" + i=1 + for pair in "${output_array[@]}"; do + key=$(cut -d'=' -f1 <<< "$pair") + value=$(cut -d'=' -f2- <<< "$pair") + form_contents+="\"$key\" $i 1 \"$value\" $i $2 $3 -1 " + ((i++)) + done + echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g' +} + wifi_config() { - local wifi_ssid="" - local wifi_psk="" - local wifi_country="" - wifi_ssid=$(dialog --no-collapse --title "$title2" --inputbox "Enter Wi-Fi SSID:" 8 40 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current SSID - wifi_psk=$(dialog --no-collapse --title "$title2" --inputbox "Enter Wi-Fi Password:" 8 40 3>&1 1>&2 2>&3) - wifi_country=$(dialog --no-collapse --title "$title2" --inputbox "Enter Country Code (US, DE...):" 8 40 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3>&1 1>&2 2>&3) # display current country + local title2="Wi-Fi (wlan0) Settings" + local config=$(dialog --no-collapse --title "$title2" --form "↑ ↓ to navigate, [ESC] to cancel." 10 45 0 \ + "SSID:" 1 1 "$(grep -oP '^ *ssid="\K[^"]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 1 15 24 32\ + "Password:" 2 1 "" 2 15 24 64\ + "Country Code:" 3 1 "$(grep -oP '^ *country=\K[^ ]+' /etc/wpa_supplicant/wpa_supplicant.conf)" 3 15 24 2\ + 3>&1 1>&2 2>&3) + # Parse the output + wifi_ssid=$(echo "$config" | sed -n '1p') + wifi_psk=$(echo "$config" | sed -n '2p') + wifi_country=$(echo "$config" | sed -n '3p') + cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" cmd="$cmd -r" @@ -63,11 +90,11 @@ wifi_config() { networking_settings() { local title="Networking" local title2="Wi-Fi (wlan0) Settings" - ip=$(hostname -I | sed 's/ / /g'); ip=${ip:+$(printf "IPv4 address:\n%s" "$ip")} + ip=$(hostname -I | sed 's/ / /g'); ip=${ip:+$(printf "IPv4 address: %s" "$ip")} wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" choice="" # zero the choice before loading the submenu while true; do - networking_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$networking_choice" --title "$title" --menu "$ip" $([ -z "$ip" ] && echo 16 || echo 18) 40 4 \ + networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "$ip" --default-item "$networking_choice" --title "$title" --menu "" $([ -z "$ip" ] && echo 14 || echo 16) 40 4 \ 1 "Turn Wi-Fi on/off" \ 2 "View Wi-Fi settings" \ 3 "Change Wi-Fi settings" \ @@ -76,17 +103,12 @@ networking_settings() { 6 "Set hostname" \ 7 "Test internet connection" \ " " "" \ - 8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + 8 "Back to main menu" 3>&1 1>&2 2>&3) + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $networking_choice in 1) # Turn Wi-Fi on/off) if ! ip link show wlan0 &>/dev/null; then - dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a wifi adapter connected?" 8 40 + dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a Wi-Fi adapter connected?" 8 40 else while true; do choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \ @@ -94,10 +116,7 @@ networking_settings() { 2 "Turn Wi-Fi off" \ " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-network-config.sh -x "up" && break ;; 2) femto-network-config.sh -x "down" && break ;; @@ -143,7 +162,7 @@ networking_settings() { # utilities utilities() { - local title="Utilities" + local title="Utilities & Tools" while true; do utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --menu "$title" 21 50 4 \ 1 "View system info" \ @@ -159,14 +178,10 @@ utilities() { 11 "Shutdown" \ " " "" \ 12 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $utilities_choice in - 1) + 1) #sysinfo) choice="" # zero the choice before loading the submenu while true; do choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 17 40 5 \ @@ -242,10 +257,7 @@ utilities() { 2 "Disable" \ " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-utils.sh -l "enable" ;; 2) femto-utils.sh -l "disable" ;; @@ -261,10 +273,7 @@ utilities() { 2 "Disable" \ " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-utils.sh -a "enable" ;; 2) femto-utils.sh -a "disable" ;; @@ -307,13 +316,8 @@ set_lora_radio() { "AI Thinker ra-01sh" "(SX1262_XTAL)"\ "None" "(simulated radio)"\ " " "" \ - "Skip" "" 3>&1 1>&2 2>&3) - - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + "Skip" "" 3>&1 1>&2 2>&3) + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog local radio="" case $choice in "Ebyte e22-900m30s") @@ -367,17 +371,12 @@ meshtastic_settings() { 8 "Upgrade/install Meshtasticd" \ 9 "Uninstall Meshtasticd" \ " " "" \ - 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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + 10 "Back to main menu" 3>&1 1>&2 2>&3) + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $meshtastic_choice in 1) # view node info) loading "Getting node info..." - dialog --no-collapse --colors --title "Node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 + eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")" ;; 2) # get current configuration URL & QR code) loading "Getting Meshtastic QR code and URL..." @@ -410,10 +409,7 @@ meshtastic_settings() { 6 "Legacy admin channel" \ " " "" \ 7 "Return to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) # view/change public key) loading "Getting current public key..." @@ -474,10 +470,7 @@ meshtastic_settings() { 2 "Disable (default)" \ " " "" \ 3 "Return to previous menu" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) # enable legacy admin) dialog --no-collapse --title "Legacy Admin" --yesno "Enable legacy admin channel?\n" 0 0 @@ -525,10 +518,7 @@ meshtastic_settings() { $(if echo "$service_state" | grep -q 'enabled'; then echo "Disable service x"; fi) \ " " " " \ "Back to previous menu" "x" 3>&1 1>&2 2>&3) - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in "View detailed service status") loading "Getting Meshtasticd service status..." @@ -600,13 +590,8 @@ help_menu() { 6 "About Luckfox" \ 7 "About Ubuntu" \ " " "" \ - 8 "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 -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + 8 "Back to main menu" 3>&1 1>&2 2>&3) + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $help_choice in 1) #About Femtofox) dialog --no-collapse --title "About Femtofox" --default-item "$choice" --backtitle "Foxbuntu $(grep -oP 'major=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'minor=\K[0-9]+' /etc/foxbuntu-release).$(grep -oP 'patch=\K[0-9]+' /etc/foxbuntu-release)$(grep -oP 'hotfix=\K[a-z]+' /etc/foxbuntu-release)" --msgbox "$(femto-license.sh -a)" 18 65 @@ -621,13 +606,7 @@ help_menu() { 4 "Luckfox Pico Mini" \ " " "" \ 5 "Back to Help Menu" 3>&1 1>&2 2>&3) - - exit_status=$? # This line checks the exit status of the dialog command - - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) dialog --no-collapse --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;; 2) dialog --no-collapse --title "Femtofox Zero" --msgbox "$(femto-pinout.sh -z)" 34 48 ;; @@ -684,9 +663,7 @@ while getopts ":hlwL:i" opt; do ;; esac done -if [ -n "$1" ]; then - exit -fi +[ -n "$1" ] && exit # if there were arguments, exit before loading the menu # Main menu while true; do @@ -695,17 +672,11 @@ while true; do 2 "Networking" \ 3 "Meshtastic" \ 4 "Software manager" \ - 5 "Utilities" \ + 5 "Utilities & tools" \ 6 "Help" \ " " "" \ 7 "Exit" 3>&1 1>&2 2>&3) - - exit_status=$? # This line checks the exit status of the dialog command - - if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $main_menu_choice in 1) femto-install-wizard.sh ;; 2) networking_settings ;; @@ -717,4 +688,4 @@ while true; do esac done -exit 0 +exit 0 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 95bdb08..3d7cc45 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -81,32 +81,46 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do echo -e "$help" ;; i) # Option -i (Get important node info) + declare -a output_array output=$(meshtastic --host --info) - preset_or_settings="Use preset? $(echo "$output" | grep -oP '"usePreset":\s*\K\w+')\n" - if echo "$output" | grep -qP '"usePreset":\s*true'; then - preset_or_settings+="Preset: $(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')" - else - preset_or_settings+="\ -Bandwidth: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')\n\ -Spread factor: $(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')\n\ -Coding rate: $(echo "$output" | grep -oP '"codingRate":\s*\K\w+')" + output_array+=("Service status=$(femto-meshtasticd-config.sh -S)") + output_array+=("Version=$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)") + output_array+=("Node name=$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)") + output_array+=("NodeID=$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")") + output_array+=("Nodenum=$(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)") + output_array+=("TX enabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+')") + use_preset=$(echo "$output" | grep -oP '"usePreset":\s*\K\w+') + output_array+=("Use preset=$use_preset") + if [ "$use_preset" = "true" ]; then # if use-preset is true, then display the preset + output_array+=("Preset=$(echo "$output" | grep -oP '"modemPreset":\s*"\K[^"]+')") + else # otherwise, display the lora settings + output_array+=("Bandwidth=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+')") + output_array+=("Spread factor=$(echo "$output" | grep -oP '"spreadFactor":\s*\K\w+')") + output_array+=("Coding rate=$(echo "$output" | grep -oP '"codingRate":\s*\K\w+')") fi - echo -e "\ -Service status: $(femto-meshtasticd-config.sh -S)\n\ -Version: $(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)\n\ -Node name: $(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)\n\ -NodeID: !$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1)) (nodenum: $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))\n\ -TX enabled? $(txEnabled=$(echo "$output" | grep -oP '"txEnabled":\s*\K\w+'); [[ "$txEnabled" == "true" ]] && echo "\033[0;34menabled\033[0m" || echo "\033[0;31mdisabled\033[0m")\n\ -Role: $(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)\n\ -$preset_or_settings\n\ -Frequency offset: $(echo "$output" | grep -oP '"bandwidth":\s*\K\w+') -Region: $(echo "$output" | grep -oP '"region":\s*"\K[^"]+')\n\ -Hop limit: $(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')\n\ -$(channelNum=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1); [[ -n "$channelNum" && "$channelNum" -gt 0 ]] && echo -e "Frequency slot: $channelNum\n")\ -$(overrideFrequency=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+'); [[ -n "$overrideFrequency" && $(echo "$overrideFrequency > 0" | bc) -eq 1 ]] && echo "Override freq: $overrideFrequency\n")\ -Public key: $(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)\n\ -Nodes in nodedb: $(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)\ -" + output_array+=("Role=$(echo "$output" | grep -oP '"role":\s*"\K[^"]+' | head -n 1)") + freq_offset=$(echo "$output" | grep -oP '"bandwidth":\s*\K\w+') + if [ "$freq_offset" != 0 ]; then # only display frequency offset if not 0 + output_array+=("Override freq=$freq_offset") + fi + output_array+=("Region=$(echo "$output" | grep -oP '"region":\s*"\K[^"]+')") + output_array+=("Hop limit=$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')") + freq_slot=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1) + if [ "$freq_slot" != 0 ]; then # only display frequency slot if not 0 + freq_slot+=("Override freq=$freq_slot") + fi + override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+') + if [ "$override_freq" != "0" ]; then # only display override frequency if not 0 + output_array+=("Override freq=$override_freq") + fi + output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)") + output_array+=("Nodes in nodedb=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)") + # now, echo the array + for pair in "${output_array[@]}"; do + key=$(echo "$pair" | cut -d'=' -f1) + value=$(echo "$pair" | cut -d'=' -f2-) + echo "$key:$value" + done ;; g) # Option -g (get config URL) url=$(meshtastic --host --qr-all | grep -oP '(?<=Complete URL \(includes all channels\): )https://[^ ]+') #add look for errors diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh index ac97796..865e365 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-software.sh @@ -5,9 +5,8 @@ package_dir="/usr/local/bin/packages" install() { dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nProceed?" 10 40 - if [ $? -eq 1 ]; then #if cancel/no - return 1 - fi + [ $? -eq 1 ] && return 1 #if cancel/no + echo "Installing $($package_dir/$1.sh -N)..." # Run the installation script, capturing the output and displaying it in real time output=$($package_dir/$1.sh -i) @@ -24,9 +23,7 @@ install() { uninstall() { dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nReinstallation will require internet connectivity.\n\nProceed?" 10 40 - if [ $? -eq 1 ]; then #if cancel/no - return 1 - fi + [ $? -eq 1 ] && return 1 #if cancel/no echo "Uninstalling $($package_dir/$1.sh -N)..." output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty") install_status=$? # Capture the exit status of the eval command @@ -41,9 +38,7 @@ uninstall() { initialize() { dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nProceed?" 13 50 - if [ $? -eq 1 ]; then #if cancel/no - return 1 - fi + [ $? -eq 1 ] && return 1 #if cancel/no clear echo "Initializing $($package_dir/$1.sh -N)..." eval "$package_dir/$1.sh -a" @@ -56,9 +51,7 @@ initialize() { upgrade() { dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nProceed?" 10 40 - if [ $? -eq 1 ]; then #if cancel/no - return 1 - fi + [ $? -eq 1 ] && return 1 #if cancel/no echo "Upgrading $($package_dir/$1.sh -N)..." output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty") install_status=$? # Capture the exit status of the eval command @@ -107,13 +100,7 @@ package_menu() { $(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 - - if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi - + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog # execute the actual commands case $choice in "Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$package_dir/$1.sh -l" ;; @@ -145,10 +132,7 @@ while true; do menu_entries+=(" " "") # add blank line and "Back to Main Menu" entry menu_entries+=("$index" "Back to main menu") software_option=$(dialog --no-collapse --cancel-label "Back" --default-item "$software_option" --menu "$title" $((9 + index)) 50 $((index + 1)) "${menu_entries[@]}" 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 + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case_block=" case \$software_option in" index=1 diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh index 16ffb96..dc13426 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh @@ -76,12 +76,12 @@ storage_info() { local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')" local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')" local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {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 mounted_drives="$( [ "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')" || echo "none" )" echo -e "microSD size: $microsd_size\n\ Memory: $memory\n\ Swap: $swap\n\ -$mounted_drives" +Mounted drives: $mounted_drives" } os_info() { From 051c42e7b67e71a08d42b39b0ca7a6fc5a3de9a0 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 17:30:18 +0200 Subject: [PATCH 19/24] Refactor femto scripts to provide data in more easily utilized fashion --- .../usr/local/bin/femto-config | 92 +++++++++++-------- .../usr/local/bin/femto-meshtasticd-config.sh | 8 +- .../usr/local/bin/femto-network-config.sh | 47 ++++++---- .../usr/local/bin/femto-utils.sh | 69 +++++++------- 4 files changed, 125 insertions(+), 91 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 023d12a..5092fb5 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -37,26 +37,46 @@ loading() { dialog --no-collapse --infobox "$1" 5 45 } -# function to pull data from various femto scripts and convert it to the contents of a read only dialog --form -ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width` - unset output_array #debug code, delete me - declare -a output_array - # Read the output from femto-meshtasticd-config.sh and store it in the array +## function to pull data from various femto scripts and convert it to the contents of a read only dialog --form +# ingest_data() { # usage: `ingest_data "command.sh -argument" key_width value_width` +# unset output_array #debug code, delete me +# declare -a output_array +# # Read the output from femto-meshtasticd-config.sh and store it in the array +# while IFS=':' read -r key value; do +# # Trim leading/trailing spaces from key and value +# key=$(echo "$key" | xargs) +# value=$(echo "$value" | xargs) +# output_array+=("$key=$value") # Use indexed array to preserve order +# done < <(eval $1) +# form_contents="" +# i=1 +# for pair in "${output_array[@]}"; do +# key=$(cut -d'=' -f1 <<< "$pair") +# value=$(cut -d'=' -f2- <<< "$pair") +# form_contents+="\"$key\" $i 1 \"$value\" $i $2 $3 -1 " +# ((i++)) +# done +# echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g' +# } +## CODE TO USE THIS FUNCTION: +# eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")" + + +# function to pull data from various femto scripts and convert it a simple text string, with dialog colors +ingest_data() { # usage: `ingest_data "command.sh -argument" key_width` + local output_string="" + # Read the output from femto-meshtasticd-config.sh and store output_string while IFS=':' read -r key value; do # Trim leading/trailing spaces from key and value - key=$(echo "$key" | xargs) - value=$(echo "$value" | xargs) - output_array+=("$key=$value") # Use indexed array to preserve order + key=$(replace_colors "$(echo "$key" | xargs)") + value=$(replace_colors "$(echo "$value" | xargs)") + if [[ -z "$key" && -z "$value" ]]; then + output_string+="---\n" + else + output_string+=$(printf "%s:%*s%s\n" "$key" $(($2 - 1 - ${#key})) "" "$value\n") # save the key and value to the output_string, adding padding between them as determined by `$2 - 1 - key-length` The 1 accounts for the : + fi done < <(eval $1) - form_contents="" - i=1 - for pair in "${output_array[@]}"; do - key=$(cut -d'=' -f1 <<< "$pair") - value=$(cut -d'=' -f2- <<< "$pair") - form_contents+="\"$key\" $i 1 \"$value\" $i $2 $3 -1 " - ((i++)) - done - echo "$form_contents" | sed 's/\x1b\[[0-9;]*m//g' + echo -e "$output_string" } wifi_config() { @@ -90,11 +110,10 @@ wifi_config() { networking_settings() { local title="Networking" local title2="Wi-Fi (wlan0) Settings" - ip=$(hostname -I | sed 's/ / /g'); ip=${ip:+$(printf "IPv4 address: %s" "$ip")} wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" choice="" # zero the choice before loading the submenu while true; do - networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "$ip" --default-item "$networking_choice" --title "$title" --menu "" $([ -z "$ip" ] && echo 14 || echo 16) 40 4 \ + networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "IPv4 address: $(femto-network-config.sh -i)" --default-item "$networking_choice" --title "$title" --menu "" 16 40 4 \ 1 "Turn Wi-Fi on/off" \ 2 "View Wi-Fi settings" \ 3 "Change Wi-Fi settings" \ @@ -127,14 +146,14 @@ networking_settings() { ;; 2) # View Wi-Fi settings) echo "Getting Wi-Fi configuration..." - dialog --no-collapse --title "$title2" --colors --msgbox "$(replace_colors "$(femto-network-config.sh -w)")" 0 0 + dialog --no-collapse --title "$title2" --colors --msgbox "$(ingest_data "femto-network-config.sh -w" 15)" 0 0 ;; 3) # Change Wi-Fi settings) wifi_config ;; 4) # View ethernet settings) echo "Getting ethernet configuration..." - dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(echo -e "$(replace_colors "$(femto-network-config.sh -e)")")" 0 0 + dialog --no-collapse --title "Ethernet (eth0) settings" --colors --msgbox "$(ingest_data "femto-network-config.sh -e" 15)" 0 0 ;; 5) # Restart networking) dialog --no-collapse --title "$title2" --yesno "Wi-Fi and Ethernet will be restarted.\nMeshtastic Wi-Fi setting will be set to ON.\n\nProceed?" 10 40 @@ -184,16 +203,15 @@ utilities() { 1) #sysinfo) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 17 40 5 \ + choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 16 40 5 \ 1 "CPU" \ 2 "Operating system" \ 3 "Storage & memory" \ 4 "Peripherals & devices" \ 5 "Networking" \ 6 "Meshtastic node info" \ - 7 "Complete system info" \ " " "" \ - 8 "Back to previous menu" 3>&1 1>&2 2>&3) + 7 "Back to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog break @@ -203,33 +221,35 @@ utilities() { case $choice in 1) # CPU) loading "Loading CPU info..." - dialog --no-collapse --colors --title "CPU info" --msgbox "$(replace_colors "$(femto-utils.sh -c)")" 0 0 + dialog --no-collapse --colors --title "CPU info" --msgbox "$(ingest_data "femto-utils.sh -c" 15)" 0 0 + #dialog --no-collapse --colors --title "CPU info" --msgbox "$(replace_colors "$(femto-utils.sh -c)")" 0 0 ;; 2) # Operating system) loading "Loading operating system info..." - dialog --no-collapse --colors --extra-button --title "Operating system" --msgbox "$(replace_colors "$(femto-utils.sh -o)")" 0 0 + dialog --no-collapse --colors --title "Operating system info" --msgbox "$(ingest_data "femto-utils.sh -o" 15)" 0 0 + #dialog --no-collapse --colors --extra-button --title "Operating system" --msgbox "$(replace_colors "$(femto-utils.sh -o)")" 0 0 ;; 3) # Storage & memory) loading "Loading storage & memory info..." - dialog --no-collapse --colors --title "Storage & memory" --msgbox "$(replace_colors "$(femto-utils.sh -S)")" 0 0 + dialog --no-collapse --colors --title "Storage & memory info" --msgbox "$(ingest_data "femto-utils.sh -S" 15)" 0 0 + #dialog --no-collapse --colors --title "Storage & memory" --msgbox "$(replace_colors "$(femto-utils.sh -S)")" 0 0 ;; 4) # Peripherals & devices) loading "Loading peripherals & devices info..." - dialog --no-collapse --colors --title "Peripherals & devices" --msgbox "$(replace_colors "$(femto-utils.sh -p)")" 0 0 + dialog --no-collapse --colors --title "Peripherals & devices info" --msgbox "$(ingest_data "femto-utils.sh -p" 15)" 0 0 + #dialog --no-collapse --colors --title "Peripherals & devices" --msgbox "$(replace_colors "$(femto-utils.sh -p)")" 0 0 ;; 5) # Networking) loading "Loading networking info..." - dialog --no-collapse --colors --title "Networking" --msgbox "$(replace_colors "$(femto-utils.sh -n)")" 0 0 + dialog --no-collapse --colors --title "Networking info" --msgbox "$(ingest_data "femto-utils.sh -n" 15)" 0 0 + #dialog --no-collapse --colors --title "Networking" --msgbox "$(replace_colors "$(femto-utils.sh -n)")" 0 0 ;; 6) # Meshtastic node info) loading "Loading Meshtastic node info..." - dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 + dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 + #dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 ;; - 7) # Complete system info) - loading "Loading complete system info..." - dialog --no-collapse --colors --title "System info" --msgbox "$(replace_colors "$(femto-utils.sh -i)")" 0 0 - ;; - 8) break ;; + 7) break ;; esac fi done @@ -376,7 +396,7 @@ meshtastic_settings() { case $meshtastic_choice in 1) # view node info) loading "Getting node info..." - eval "$(echo -e "dialog --no-collapse --no-cancel --form \"Meshtastic node info\" 0 0 0 $(ingest_data "femto-meshtasticd-config.sh -i" 18 0) 2>/dev/null")" + dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "sudo femto-meshtasticd-config.sh -i" 17)" 0 0 ;; 2) # get current configuration URL & QR code) loading "Getting Meshtastic QR code and URL..." diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index 3d7cc45..e315e04 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -83,7 +83,7 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do i) # Option -i (Get important node info) declare -a output_array output=$(meshtastic --host --info) - output_array+=("Service status=$(femto-meshtasticd-config.sh -S)") + output_array+=("Service=$(femto-meshtasticd-config.sh -S)") output_array+=("Version=$(echo "$output" | grep -oP '"firmwareVersion":\s*"\K[^"]+' | head -n 1)") output_array+=("Node name=$(echo "$output" | grep -oP 'Owner:\s*\K.*' | head -n 1)") output_array+=("NodeID=$(echo "!$(printf "%08x\n" $(echo "$output" | grep -oP '"myNodeNum":\s*\K\d+' | head -n 1))")") @@ -107,14 +107,14 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do output_array+=("Hop limit=$(echo "$output" | grep -oP '"hopLimit":\s*\K\w+')") freq_slot=$(echo "$output" | grep -oP '"channelNum":\s*\K\d+' | head -n 1) if [ "$freq_slot" != 0 ]; then # only display frequency slot if not 0 - freq_slot+=("Override freq=$freq_slot") + freq_slot+=("Freq slot=$freq_slot") fi override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+') if [ "$override_freq" != "0" ]; then # only display override frequency if not 0 - output_array+=("Override freq=$override_freq") + output_array+=("Over. freq=$override_freq") fi output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)") - output_array+=("Nodes in nodedb=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)") + output_array+=("Nodes in db=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)") # now, echo the array for pair in "${output_array[@]}"; do key=$(echo "$pair" | cut -d'=' -f1) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh index 50140c2..31f5735 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh @@ -15,6 +15,7 @@ Options are: -c "COUNTRY" Set Wi-Fi 2-letter country code (such as US, DE) -r Restart Wi-Fi -e Get ethernet settings +-i Get IPv4 addresses -w Get Wi-Fi settings -n "HOSTNAME" Change hostname -t Test internet connection @@ -37,7 +38,7 @@ if [ $# -eq 0 ]; then fi # Parse options -while getopts ":hx:Ts:p:c:ewn:tr" opt; do +while getopts ":hx:Ts:p:c:eiwn:tr" opt; do case ${opt} in h) # Option -h (help) echo -e "$help" @@ -77,42 +78,52 @@ 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;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")" +echo -e "\ +Eth status:$([ "$status" == "UP" ] && echo -e "\033[4m\033[0;34mconnected\033[0m" || echo -e "\033[0;31mdisconnected\033[0m")" if [ "$status" == "UP" ]; then - echo "IPv4 Address: $(ifconfig eth0 | grep 'inet ' | awk '{print $2}')\n\ -IPv6 Address: $(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')" + echo -e "\ +IPv4 Address:$(ifconfig eth0 | grep 'inet ' | awk '{print $2}') +IPv6 Address:$(ifconfig eth0 | grep 'inet6 ' | awk '{print $2}')" fi -echo -e "MAC Address: $(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\ -Hostname: $(hostname).local" +echo -e "\ +MAC Address:$(ifconfig eth0 | grep 'ether ' | awk '{print $2}')\n\ +Hostname:$(hostname).local" ;; w) # Option -w (wifi settings) - wifi_settings="SSID: $(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\ -Password: (hidden)\n\ -Country: $(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)" + wifi_settings="\ +SSID:$(grep -m 1 '^\s*ssid=' "$wpa_supplicant_conf" | cut -d '"' -f 2)\n\ +Password:(hidden)\n\ +Country:$(grep -m 1 "^country=" "$wpa_supplicant_conf" | cut -d '=' -f 2)" if ip link show wlan0 2>/dev/null | grep -q "wlan0"; then - mac_address_line="MAC address: $(ifconfig wlan0 | grep ether | awk '{print $2}')\n" + mac_address_line="\ +MAC address:$(ifconfig wlan0 | grep ether | awk '{print $2}')" if [ "$(cat /etc/wifi_state.txt)" = "up" ]; then - echo -e "Wi-Fi status: \033[4m\033[0;34menabled\033[0m\n\ -Connected to: $(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\ -Signal Strength: $(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\ -Current IP: $(hostname -I | awk '{print $1}')\n -Hostname: $(hostname).local\n\ + echo -e "\ +Wi-Fi status:\033[4m\033[0;34menabled\033[0m\n\ +Connected to:$(iwconfig 2>/dev/null | grep -i 'ESSID' | awk -F 'ESSID:"' '{print $2}' | awk -F '"' '{print $1}' | sed 's/^$/none/')\n\ +Sig. strength:$(iwconfig 2>/dev/null | grep -i 'Signal level' | awk -F 'Signal level=' '{print $2}' | awk '{print $1}')\n\ +Current IP:$(hostname -I | awk '{print $1}')\n +Hostname:$(hostname).local\n\ $mac_address_line" else if ip link show wlan0 &>/dev/null; then # if wlan0 exists - echo -e "Wi-Fi status: \033[0;31mdisabled\033[0m\n\ + echo -e "\ +Wi-Fi status:\033[0;31mdisabled\033[0m\n\ \n\ $wifi_settings" fi fi else - echo -e "Wi-Fi status: \033[0;31mwlan0 not detected\033[0m\n\ + echo -e "\ +Wi-Fi status:\033[0;31mwlan0 not detected\033[0m\n\ \n\ -Wi-Fi settings:\n\ $wifi_settings" fi ;; + i) # Option -i (Get all IPv4 addresses) + hostname -I | awk '{for(i=1; i<=NF; i++) {if(i>1) printf ", "; printf $i} print ""}' + ;; t) # Option -t (test internet connection) # Define ping targets and initialize counter targets=("1.1.1.1" "8.8.8.8") diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh index dc13426..9fa71cb 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-utils.sh @@ -64,24 +64,26 @@ cpu_info() { local cpu_speed="$(lscpu | grep "CPU min MHz" | awk '{print int($4)}')-$(lscpu | grep "CPU max MHz" | awk '{print int($4)}')mhz" local cpu_serial="$(awk '/Serial/ {print $3}' /proc/cpuinfo)" - echo -e "Core: $core\n\ -Model: $cpu_model\n\ -Architecture: $cpu_architecture\n\ -Speed: $cpu_speed x $(nproc) cores\n\ -Temperature: $cpu_temp\n\ -Serial # $cpu_serial" + echo -e "\ +Core:$core\n\ +Model:$cpu_model\n\ +Architecture:$cpu_architecture\n\ +Speed:$cpu_speed x $(nproc) cores\n\ +Temperature:$cpu_temp\n\ +Serial #:$cpu_serial" } storage_info() { - local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')" - local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')" - local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')" + local microsd_size="$(df --block-size=1 / | awk 'NR==2 {total=$2; avail=$4; total_human=sprintf("%.2f", total/1024/1024/1024); avail_human=sprintf("%.2f", avail/1024/1024/1024); printf "%.2f GB (%.2f%% free)", total_human, (avail/total)*100}')" + local memory="$(free -m | awk 'NR==2{printf "%d MB (%.2f%% free)\n", $2, 100 - (($3/$2)*100)}')" + local swap="$(free -m | awk 'NR==3 {if ($2 > 1000) {printf "%.2f GB (%.2f%% free)", $2/1024, ($4/$2)*100} else {printf "%d MB (%.2f%% free)", $2, ($4/$2)*100}}')" local mounted_drives="$( [ "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done)" ] && echo "$(for dir in /mnt/*/; do [ -d "$dir" ] && echo -n "/mnt${dir#"/mnt"} "; done | sed 's/\/$//')" || echo "none" )" - echo -e "microSD size: $microsd_size\n\ -Memory: $memory\n\ -Swap: $swap\n\ -Mounted drives: $mounted_drives" + echo -e "\ +microSD size:$microsd_size\n\ +Memory:$memory\n\ +Swap:$swap\n\ +Mnted drives:$mounted_drives" } os_info() { @@ -92,21 +94,22 @@ os_info() { local kernel_active_modules="$(lsmod | awk 'NR>1 {print $1}' | tr '\n' ' ' && echo)" local kernel_boot_modules="$(modules=$(sed -n '6,$p' /etc/modules | sed ':a;N;$!ba;s/\n/, /g;s/, $//'); [ -z "$modules" ] && echo "none" || echo "$modules")" - echo -e "Operating System: $os_version\n\ -Kernel version: $(uname -r)\n\ -Uptime: $system_uptime\n\ -Logging: $logging_enabled\n\ -Activity LED: $act_led\n\ -System time: $(date)\n\ -K modules active: $kernel_active_modules\n\ -K boot modules: $kernel_boot_modules" + echo -e "\ +OS:$os_version\n\ +Kernel ver:$(uname -r)\n\ +Uptime:$system_uptime\n\ +Logging:$logging_enabled\n\ +Activity LED:$act_led\n\ +System time:$(date)\n\ +K mods active:$kernel_active_modules\n\ +K boot mods:$kernel_boot_modules" } networking_info() { local wifi_status="$(femto-network-config.sh -w | grep -v '^$' | grep -v '^Hostname')" #remove hostname line, as it's identical to the one in ethernet settings local eth_status="$(femto-network-config.sh -e)" echo -e "$wifi_status\n\ ---- + $eth_status" } @@ -119,7 +122,7 @@ peripherals_info() { local uart3_state="$([ "$(awk -F= '/^UART3_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" local uart4_state="$([ "$(awk -F= '/^UART4_M1_STATUS/ {print $2}' /etc/luckfox.cfg)" -eq 1 ] && echo "enabled" || echo "disabled")" local lora_radio="$(femto-meshtasticd-config.sh -k)" - local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB: "; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB: none detected"}')" + local usb_devices="$(lsusb | grep -v 'root hub' | awk 'NR>0{printf "USB:"; for(i=7;i<=NF;i++) printf "%s ", $i; print ""} END {if (NR == 0) printf "USB:none detected"}')" # gather i2c addresses i2c_addresses="" # initialize empty string to collect populated addresses while IFS= read -r line; do # iterate over each row of output (captured at end of while loop) @@ -136,16 +139,16 @@ peripherals_info() { done <<< "$(echo "$(sudo i2cdetect -y 3)")" [[ -z "$i2c_addresses" ]] && i2c_addresses="none detected" # if no addresses found, "none detected" - echo -e "LoRa radio: $lora_radio\n\ + echo -e "LoRa radio:$lora_radio\n\ $usb_devices\n\ -i2c devices: $i2c_addresses\n\ -USB mode: $usb_mode\n\ -SPI-0 state: $spi0_state\n\ -SPI-0 speed: $spi0_speed\n\ -i2c-3 state: $i2c3_state\n\ -i2c-3 speed: $i2c3_speed\n\ -UART-3 state: $uart3_state\n\ -UART-4 state: $uart4_state" +i2c devices:$i2c_addresses\n\ +USB mode:$usb_mode\n\ +SPI-0 state:$spi0_state\n\ +SPI-0 speed:$spi0_speed\n\ +i2c-3 state:$i2c3_state\n\ +i2c-3 speed:$i2c3_speed\n\ +UART-3 state:$uart3_state\n\ +UART-4 state:$uart4_state" } all_system_info() { @@ -154,7 +157,7 @@ all_system_info() { CPU:\n\ $(cpu_info)\n\ \n\ - OS:\n\ + Operating System:\n\ $(os_info)\n\ \n\ Storage:\n\ From c55c0bd00ecf0afafdbccef8c914b4ab4f6b477f Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 18:04:05 +0200 Subject: [PATCH 20/24] Continued refactor --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-config | 7 +------ .../usr/local/bin/femto-meshtasticd-config.sh | 2 +- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index 5092fb5..d6e9cb4 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -227,27 +227,22 @@ utilities() { 2) # Operating system) loading "Loading operating system info..." dialog --no-collapse --colors --title "Operating system info" --msgbox "$(ingest_data "femto-utils.sh -o" 15)" 0 0 - #dialog --no-collapse --colors --extra-button --title "Operating system" --msgbox "$(replace_colors "$(femto-utils.sh -o)")" 0 0 ;; 3) # Storage & memory) loading "Loading storage & memory info..." dialog --no-collapse --colors --title "Storage & memory info" --msgbox "$(ingest_data "femto-utils.sh -S" 15)" 0 0 - #dialog --no-collapse --colors --title "Storage & memory" --msgbox "$(replace_colors "$(femto-utils.sh -S)")" 0 0 ;; 4) # Peripherals & devices) loading "Loading peripherals & devices info..." dialog --no-collapse --colors --title "Peripherals & devices info" --msgbox "$(ingest_data "femto-utils.sh -p" 15)" 0 0 - #dialog --no-collapse --colors --title "Peripherals & devices" --msgbox "$(replace_colors "$(femto-utils.sh -p)")" 0 0 ;; 5) # Networking) loading "Loading networking info..." dialog --no-collapse --colors --title "Networking info" --msgbox "$(ingest_data "femto-utils.sh -n" 15)" 0 0 - #dialog --no-collapse --colors --title "Networking" --msgbox "$(replace_colors "$(femto-utils.sh -n)")" 0 0 ;; 6) # Meshtastic node info) loading "Loading Meshtastic node info..." dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 - #dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(replace_colors "$(femto-meshtasticd-config.sh -i)")" 0 0 ;; 7) break ;; esac @@ -396,7 +391,7 @@ meshtastic_settings() { case $meshtastic_choice in 1) # view node info) loading "Getting node info..." - dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "sudo femto-meshtasticd-config.sh -i" 17)" 0 0 + dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 ;; 2) # get current configuration URL & QR code) loading "Getting Meshtastic QR code and URL..." diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh index e315e04..fdf196c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-meshtasticd-config.sh @@ -111,7 +111,7 @@ while getopts ":higkl:q:uU:rR:aA:cpo:sM:Stwuxm" opt; do fi override_freq=$(echo "$output" | grep -oP '"overrideFrequency":\s*\K[0-9.]+') if [ "$override_freq" != "0" ]; then # only display override frequency if not 0 - output_array+=("Over. freq=$override_freq") + output_array+=("Override freq=$override_freq") fi output_array+=("Public key=$(echo "$output" | grep -oP '"publicKey":\s*"\K[^"]+' | head -n 1)") output_array+=("Nodes in db=$(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)") From 37f98473a3de15cba78930bc5ba004be725d918f Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 18:17:05 +0200 Subject: [PATCH 21/24] Add complete system info back in --- .../usr/local/bin/femto-config | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index d6e9cb4..dae841b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -210,8 +210,9 @@ utilities() { 4 "Peripherals & devices" \ 5 "Networking" \ 6 "Meshtastic node info" \ + 7 "Complete system info" \ " " "" \ - 7 "Back to previous menu" 3>&1 1>&2 2>&3) + 8 "Back to previous menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog break @@ -222,7 +223,6 @@ utilities() { 1) # CPU) loading "Loading CPU info..." dialog --no-collapse --colors --title "CPU info" --msgbox "$(ingest_data "femto-utils.sh -c" 15)" 0 0 - #dialog --no-collapse --colors --title "CPU info" --msgbox "$(replace_colors "$(femto-utils.sh -c)")" 0 0 ;; 2) # Operating system) loading "Loading operating system info..." @@ -244,7 +244,29 @@ utilities() { loading "Loading Meshtastic node info..." dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 ;; - 7) break ;; + 7) # Complete system info) + loading "Loading complete system info..." + dialog --no-collapse --colors --title "Meshtastic node info" --msgbox "\ + Femtofox + CPU: +$(ingest_data "femto-utils.sh -c" 15) + + Operating System: +$(ingest_data "femto-utils.sh -o" 15) + + Storage: +$(ingest_data "femto-utils.sh -S" 15) + + Networking (wlan0 & eth0): +$(ingest_data "femto-utils.sh -p" 15) + + Peripherals: +$(ingest_data "femto-utils.sh -n" 15) + + Meshtasticd: +$(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 + ;; + 8) break ;; esac fi done From 9c24f93fe2be6da298235c44ec4041f777fc6188 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 19:16:37 +0200 Subject: [PATCH 22/24] Fix color in internet connectivity test --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh index 31f5735..362c0fd 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-network-config.sh @@ -140,7 +140,7 @@ $wifi_settings" if [ "$successful" -eq 0 ]; then echo -e "\033[0;31mNo internet connection detected.\033[0m" else - echo -e "Internet connection is \033[4m\033[0;32mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses." + echo -e "Internet connection is \033[4m\033[0;34mup\033[0m.\n\nPinged $(echo "${targets[*]}" | sed 's/ /, /g').\nReceived $successful/$total responses." fi ;; r) # Option -r (restart Wi-Fi) From db2c49a2687a30f3ad357e4f03acaa3d34b0701b Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 1 Feb 2025 23:01:00 +0200 Subject: [PATCH 23/24] Add helptext support to menus --- .../out/rootfs_uclibc_rv1106/root/.dialogrc | 3 + .../usr/local/bin/femto-config | 230 +++++++++--------- 2 files changed, 118 insertions(+), 115 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc index 9783b2c..21fd218 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/root/.dialogrc @@ -25,3 +25,6 @@ form_text_color = (WHITE,CYAN,ON) # Readonly form item color form_item_readonly_color = (BLUE,WHITE,ON) + +# Item help-text color +itemhelp_color = (BLACK,BLUE,OFF) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index dae841b..d18e5d0 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config @@ -91,7 +91,7 @@ wifi_config() { wifi_psk=$(echo "$config" | sed -n '2p') wifi_country=$(echo "$config" | sed -n '3p') - cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" + cmd="femto-network-config.sh -s \"$wifi_ssid\" -p \"$wifi_psk\"" # build the wifi setting command to send to the network config script [ -n "$wifi_country" ] && cmd="$cmd -c \"$wifi_country\"" cmd="$cmd -r" if [ -z "$wifi_ssid" ]; then @@ -113,16 +113,16 @@ networking_settings() { wpa_supplicant_conf="/etc/wpa_supplicant/wpa_supplicant.conf" choice="" # zero the choice before loading the submenu while true; do - networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "IPv4 address: $(femto-network-config.sh -i)" --default-item "$networking_choice" --title "$title" --menu "" 16 40 4 \ - 1 "Turn Wi-Fi on/off" \ - 2 "View Wi-Fi settings" \ - 3 "Change Wi-Fi settings" \ - 4 "View ethernet settings" \ - 5 "Restart networking" \ - 6 "Set hostname" \ - 7 "Test internet connection" \ - " " "" \ - 8 "Back to main menu" 3>&1 1>&2 2>&3) + networking_choice=$(dialog --no-collapse --cancel-label "Back" --backtitle "IPv4 address: $(femto-network-config.sh -i)" --default-item "$networking_choice" --title "$title" --item-help --menu "" 16 40 4 \ + 1 "Turn Wi-Fi on/off" "" \ + 2 "View Wi-Fi settings" "" \ + 3 "Change Wi-Fi settings" "" \ + 4 "View ethernet settings" "" \ + 5 "Restart networking" "" \ + 6 "Set hostname" "" \ + 7 "Test internet connection" "" \ + " " "" "" \ + 8 "Back to main menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $networking_choice in 1) # Turn Wi-Fi on/off) @@ -130,11 +130,11 @@ networking_settings() { dialog --no-collapse --colors --msgbox "\Z1Network adapter wlan0 does not exist.\Zn\n\nIs a Wi-Fi adapter connected?" 8 40 else while true; do - choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \ - 1 "Turn Wi-Fi on" \ - 2 "Turn Wi-Fi off" \ - " " "" \ - 3 "Return to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Enable/disable Wi-Fi" --item-help --menu "Tip: Wi-Fi can also be toggled by short-pressing the BOOT button on the Luckfox." 13 50 5 \ + 1 "Turn Wi-Fi on" "" \ + 2 "Turn Wi-Fi off" "" \ + " " "" "" \ + 3 "Return to previous menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-network-config.sh -x "up" && break ;; @@ -162,7 +162,7 @@ networking_settings() { fi ;; 6) # set hostname) - new_hostname=$(dialog --no-collapse --title "$title" --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3) + new_hostname=$(dialog --no-collapse --title "$title" --max-input 253 --inputbox "Enter new hostname:" 8 40 $(hostname) 3>&1 1>&2 2>&3) if [ $? -eq 0 ]; then #unless cancel/no femto-network-config.sh -n "$new_hostname" dialog --no-collapse --title "$title" --msgbox "Femtofox is now reachable at\n$new_hostname.local" 8 40 @@ -183,36 +183,36 @@ networking_settings() { utilities() { local title="Utilities & Tools" while true; do - utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --menu "$title" 21 50 4 \ - 1 "View system info" \ - 2 "Set system time" \ - 3 "Kernel modules" \ - 4 "Re-run first-boot script" \ - 5 "Run USB configuration tool" \ - 6 "Run OEM luckfox-config" \ - 7 "Process viewer/manager" \ - 8 "Disable/enable logging" \ - 9 "Disable/enable activity LED" \ - 10 "Reboot" \ - 11 "Shutdown" \ - " " "" \ - 12 "Back to main menu" 3>&1 1>&2 2>&3) + utilities_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$utilities_choice" --item-help --menu "$title" 21 50 4 \ + 1 "View system info" "" \ + 2 "Set system time" "" \ + 3 "Kernel modules" "" \ + 4 "Re-run first-boot script" "" \ + 5 "Run USB configuration tool" "" \ + 6 "Run OEM luckfox-config" "" \ + 7 "Process viewer/manager" "" \ + 8 "Disable/enable logging" "" \ + 9 "Disable/enable activity LED" "" \ + 10 "Reboot" "" \ + 11 "Shutdown" "" \ + " " "" "" \ + 12 "Back to main menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $utilities_choice in 1) #sysinfo) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --menu "System info" 16 40 5 \ - 1 "CPU" \ - 2 "Operating system" \ - 3 "Storage & memory" \ - 4 "Peripherals & devices" \ - 5 "Networking" \ - 6 "Meshtastic node info" \ - 7 "Complete system info" \ - " " "" \ - 8 "Back to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --help-button --help-label "Help" --cancel-label "Back" --default-item "$choice" --item-help --menu "System info" 17 40 5 \ + 1 "CPU" "" \ + 2 "Operating system" "" \ + 3 "Storage & memory" "" \ + 4 "Peripherals & devices" ""\ + 5 "Networking" "" \ + 6 "Meshtastic node info" "" \ + 7 "Complete system info" "" \ + " " "" "" \ + 8 "Back to previous menu" "" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog break @@ -289,11 +289,11 @@ $(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 8) # logging) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \ - 1 "Enable (default)" \ - 2 "Disable" \ - " " "" \ - 3 "Return to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable logging to reduce SD card wear.\nCurrent state: $(replace_colors "$(femto-utils.sh -l "check")")" 14 50 2 \ + 1 "Enable (default)" "" \ + 2 "Disable" "" \ + " " "" "" \ + 3 "Return to previous menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-utils.sh -l "enable" ;; @@ -305,11 +305,11 @@ $(ingest_data "femto-meshtasticd-config.sh -i" 15)" 0 0 9) # logging) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \ - 1 "Enable (default)" \ - 2 "Disable" \ - " " "" \ - 3 "Return to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --colors --title "Logging" --cancel-label "Back" --default-item "$choice" --item-help --menu "Before deploying a Femtofox, it is advisable to disable the Activity LED to save power.\nCurrent state: $(replace_colors "$(femto-utils.sh -a "check")")" 14 50 2 \ + 1 "Enable (default)" "" \ + 2 "Disable" "" \ + " " "" "" \ + 3 "Return to previous menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) femto-utils.sh -a "enable" ;; @@ -343,17 +343,17 @@ set_lora_radio() { while true; do echo "Checking LoRa radio..." #Display filename, if exists: $(files=$(ls /etc/meshtasticd/config.d/* 2>/dev/null) && [ -n "$files" ] && echo "\n\nConfiguration files in use:\n$files" | paste -sd, -)) - choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --title "Meshtastic LoRa radio" --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \ - "Ebyte e22-900m30s" "(SX1262_TCXO)" \ - "Ebyte e22-900m22s" "(SX1262_TCXO)"\ - "Ebyte e80-900m22s" "(SX1262_XTAL)"\ - "Heltec ht-ra62" "(SX1262_TCXO)"\ - "Seeed wio-sx1262" "(SX1262_TCXO)"\ - "Waveshare sx126x-xxxm" "(SX1262_XTAL)"\ - "AI Thinker ra-01sh" "(SX1262_XTAL)"\ - "None" "(simulated radio)"\ - " " "" \ - "Skip" "" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --colors --cancel-label "Back" --default-item "$choice" --title "Meshtastic LoRa radio" --item-help --menu "Currently configured LoRa radio:\n$(replace_colors "$(femto-meshtasticd-config.sh -k)")$(ls -1 /etc/meshtasticd/config.d 2>/dev/null | paste -sd ', ' - | sed 's/^/ (/; s/$/)/; s/,/, /g' | grep -v '^ ()$')" 19 50 10 \ + "Ebyte e22-900m30s" "(SX1262_TCXO)" "" \ + "Ebyte e22-900m22s" "(SX1262_TCXO)" "" \ + "Ebyte e80-900m22s" "(SX1262_XTAL)" "" \ + "Heltec ht-ra62" "(SX1262_TCXO)" "" \ + "Seeed wio-sx1262" "(SX1262_TCXO)" "" \ + "Waveshare sx126x-xxxm" "(SX1262_XTAL)" "" \ + "AI Thinker ra-01sh" "(SX1262_XTAL)" "" \ + "None" "(simulated radio)" "" \ + " " "" "" \ + "Skip" "" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog local radio="" case $choice in @@ -397,18 +397,18 @@ meshtastic_settings() { local title="Meshtastic Settings" while true; do echo "Checking Meshtasticd service state..." - meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 19 50 4 \ - 1 "View node info" \ - 2 "View configuration URL & QR code" \ - 3 "Set new configuration URL" \ - 4 "Set LoRa radio" \ - 5 "Security settings" \ - 6 "Mesh connectivity test" \ - 7 "Manage Meshtasticd service" \ - 8 "Upgrade/install Meshtasticd" \ - 9 "Uninstall Meshtasticd" \ - " " "" \ - 10 "Back to main menu" 3>&1 1>&2 2>&3) + meshtastic_choice=$(dialog --no-collapse --colors --title "$title" --cancel-label "Back" --default-item "$meshtastic_choice" --item-help --menu "Meshtasticd service is $(replace_colors "$(femto-meshtasticd-config.sh -S)")$(femto-meshtasticd-config.sh -k | grep -q 'simulated' && echo '\n\Z1Warning: using simulated radio\Zn')" 20 50 4 \ + 1 "View node info" "" \ + 2 "View configuration URL & QR code" "" \ + 3 "Set new configuration URL" "" \ + 4 "Set LoRa radio" "" \ + 5 "Security settings" "" \ + 6 "Mesh connectivity test" "" \ + 7 "Manage Meshtasticd service" "" \ + 8 "Upgrade/install Meshtasticd" "" \ + 9 "Uninstall Meshtasticd" "" \ + " " "" "" \ + 10 "Back to main menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $meshtastic_choice in 1) # view node info) @@ -436,16 +436,16 @@ meshtastic_settings() { 5) # remote admin) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --menu "" 16 40 5 \ - 1 "View/change public key" \ - 2 "View/change private key" \ - " " "" \ - 3 "View admin keys" \ - 4 "Set admin key" \ - 5 "Clear admin keys" \ - 6 "Legacy admin channel" \ - " " "" \ - 7 "Return to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$choice" --title "Meshtastic Security Settings" --item-help --menu "" 16 40 5 \ + 1 "View/change public key" "" \ + 2 "View/change private key" "" \ + " " "" "" \ + 3 "View admin keys" "" \ + 4 "Set admin key" "" \ + 5 "Clear admin keys" "" \ + 6 "Legacy admin channel" "" \ + " " "" "" \ + 7 "Return to previous menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) # view/change public key) @@ -502,11 +502,11 @@ meshtastic_settings() { choice="" # zero the choice before loading the submenu while true; do loading "Getting current legacy admin state..." - choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \ - 1 "Enable" \ - 2 "Disable (default)" \ - " " "" \ - 3 "Return to previous menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --colors --title "Legacy Admin" --default-item "$choice" --item-help --menu "Current state: $(replace_colors "$(femto-meshtasticd-config.sh -p)")" 12 40 5 \ + 1 "Enable" "" \ + 2 "Disable (default)" "" \ + " " "" "" \ + 3 "Return to previous menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) # enable legacy admin) @@ -618,16 +618,16 @@ meshtastic_settings() { help_menu() { while true; do local title="Help / About" - help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --menu "$title" 0 0 7 \ - 1 "About Femtofox" \ - 2 "Display pinout" \ - 3 "Femtofox licensing info - short" \ - 4 "Femtofox licensing info - long" \ - 5 "Meshtastic licensing info" \ - 6 "About Luckfox" \ - 7 "About Ubuntu" \ - " " "" \ - 8 "Back to main menu" 3>&1 1>&2 2>&3) + help_choice=$(dialog --no-collapse --cancel-label "Back" --default-item "$help_choice" --item-help --menu "$title" 0 0 7 \ + 1 "About Femtofox" "" \ + 2 "Display pinout" "" \ + 3 "Femtofox licensing info - short" "" \ + 4 "Femtofox licensing info - long" "" \ + 5 "Meshtastic licensing info" "" \ + 6 "About Luckfox" "" \ + 7 "About Ubuntu" "" \ + " " "" "" \ + 8 "Back to main menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $help_choice in 1) #About Femtofox) @@ -636,13 +636,13 @@ help_menu() { 2) #Display pinout) choice="" # zero the choice before loading the submenu while true; do - choice=$(dialog --no-collapse --cancel-label "Back" --menu "Pinouts" 15 40 5 \ - 1 "Femtofox Pro/CE" \ - 2 "Femtofox Zero" \ - 3 "Femtofox Tiny" \ - 4 "Luckfox Pico Mini" \ - " " "" \ - 5 "Back to Help Menu" 3>&1 1>&2 2>&3) + choice=$(dialog --no-collapse --cancel-label "Back" --item-help --menu "Pinouts" 15 40 5 \ + 1 "Femtofox Pro/CE" "" \ + 2 "Femtofox Zero" "" \ + 3 "Femtofox Tiny" "" \ + 4 "Luckfox Pico Mini" "" \ + " " "" "" \ + 5 "Back to Help Menu" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $choice in 1) dialog --no-collapse --title "Femtofox" --msgbox "$(femto-pinout.sh -f)" 43 68 ;; @@ -704,15 +704,15 @@ done # Main menu while true; do - main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --menu "Femtofox Config" 16 40 5 \ - 1 "Settings wizard" \ - 2 "Networking" \ - 3 "Meshtastic" \ - 4 "Software manager" \ - 5 "Utilities & tools" \ - 6 "Help" \ - " " "" \ - 7 "Exit" 3>&1 1>&2 2>&3) + main_menu_choice=$(dialog --no-collapse --cancel-label "Exit" --default-item "$main_menu_choice" --item-help --menu "Femtofox Config" 16 40 5 \ + 1 "Settings wizard" "" \ + 2 "Networking" "" \ + 3 "Meshtastic" "" \ + 4 "Software manager" "" \ + 5 "Utilities & tools" "" \ + 6 "Help" "" \ + " " "" "" \ + 7 "Exit" "" 3>&1 1>&2 2>&3) [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog case $main_menu_choice in 1) femto-install-wizard.sh ;; From 00797704bd6946f5cedde6245d873b6be00ca5cd Mon Sep 17 00:00:00 2001 From: nagumii Date: Sun, 2 Feb 2025 16:02:30 +0200 Subject: [PATCH 24/24] Add apt package listing to package description --- .../usr/local/bin/packages/mosquitto_mqtt_broker.sh | 6 ++++-- .../usr/local/bin/packages/mosquitto_mqtt_client.sh | 6 ++++-- .../usr/local/bin/packages/package_template.sh | 6 ++++-- .../rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh | 8 +++++--- 4 files changed, 17 insertions(+), 9 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh index a901fc7..2ba27e7 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh @@ -32,7 +32,8 @@ Arguments: -U Get URL -O Get options supported by this script -S Get service status --L Get Install location +-L Get install location +-P Get package name -C Get Conflicts -I Check if installed. Returns an error if not installed EOF @@ -53,7 +54,7 @@ name="Mosquitto MQTT Broker" # software name author="Eclipse Foundation" # software author - OPTIONAL description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!) URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="mosquitto" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2" package_name="mosquitto" # apt package name, if applicable @@ -139,6 +140,7 @@ while getopts ":h$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + P) echo -e $package_name ;; C) echo -e $conflicts ;; I) # Option -I (Check if already installed) check diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh index 46fbed4..f576cf4 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh @@ -32,7 +32,8 @@ Arguments: -U Get URL -O Get options supported by this script -S Get service status --L Get Install location +-L Get install location +-P Get package name -C Get Conflicts -I Check if installed. Returns an error if not installed EOF @@ -53,7 +54,7 @@ name="Mosquitto MQTT Client" # software name author="Eclipse Foundation" # software author - OPTIONAL description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!) URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL -options="xiugedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiugedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` @@ -137,6 +138,7 @@ while getopts ":h$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + P) echo -e $package_name ;; C) echo -e $conflicts ;; I) # Option -I (Check if already installed) check diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index c4c94f6..f3db15d 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -33,7 +33,8 @@ Arguments: -U Get URL -O Get options supported by this script -S Get service status --L Get Install location +-L Get install location +-P Get package name -C Get Conflicts -I Check if installed. Returns an error if not installed EOF @@ -53,7 +54,7 @@ name="name" # software name author="author" # software author - OPTIONAL description="description" # software description - OPTIONAL (but strongly recommended!) URL="URL" # software URL. Can contain multiple URLs - OPTIONAL -options="hxiuagedsrlNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS` +options="hxiuagedsrlNADUOSLPCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS` launch="/opt/package/run.sh" # command to launch software, if applicable service_name="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" package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't @@ -148,6 +149,7 @@ while getopts ":$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + P) echo -e $package_name ;; C) echo -e $conflicts ;; I) # Option -I (Check if already installed) check diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh index d085851..56cccc8 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/samba.sh @@ -33,7 +33,8 @@ Arguments: -U Get URL -O Get options supported by this script -S Get service status --L Get Install location +-L Get install location +-P Get package name -C Get Conflicts -I Check if installed. Returns an error if not installed EOF @@ -49,14 +50,14 @@ 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 -user_message="To connect to network share, enter \`\\\\femtofox\\home\` from Windows, \`smb://$(hostname)\\home\` from MacOS or \`smbclient //$(hostname)/femto -U femto\` from Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." +user_message="To connect to network share, enter \`\\\\femtofox\\home\` in Windows, \`smb://$(hostname)/home\` in MacOS or \`smbclient //$(hostname)/femto -U femto\` in Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`." init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu, or enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and then restart the Samba service." name="Samba File Sharing" # software name author="Software Freedom Conservancy" # software author - OPTIONAL description="Femtofox comes with Samba preinstalled but disabled. $init_instructions\n\n$user_message" # software description - OPTIONAL (but strongly recommended!) URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL -options="xiuagedsrNADUOSCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="xiuagedsrNADUOSPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` launch="" # command to launch software, if applicable service_name="smbd nmbd" # 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="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` @@ -157,6 +158,7 @@ while getopts ":h$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + P) echo -e $package_name ;; C) echo -e $conflicts ;; I) # Option -I (Check if already installed) check