From e337ed62ae8b325c2a13ab1e4094fe13922c1e08 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 18:42:37 +0200 Subject: [PATCH 1/8] Switch source of meshtasticd mac address to eth0 --- environment-setup/femtofox.chroot | 2 +- .../etc/meshtasticd/config.d/femto_mac_address.yaml | 4 ++++ .../etc/meshtasticd/{config.yaml => config.yaml.bak} | 0 .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 4 ++++ 4 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.d/femto_mac_address.yaml rename foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/{config.yaml => config.yaml.bak} (100%) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index ebf59e2..95496ec 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -56,7 +56,7 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." systemctl enable button -systemctl enable meshtasticd +#systemctl enable meshtasticd systemctl enable femto-runonce.service systemctl enable femto-usb-config-tool.service systemctl enable femto-boot-complete.service diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.d/femto_mac_address.yaml b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.d/femto_mac_address.yaml new file mode 100644 index 0000000..b1f2e8a --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.d/femto_mac_address.yaml @@ -0,0 +1,4 @@ +# this sets the mac address source to eth0, replacing the previous code that derived a seed from the CPU s/n. +# of course, eth0 also has its mac address derived from CPU s/n, but this way meshtastic uses the exact mac address, instead of a bastardized version converted to a 9 digit int with `| bc | tail -c -9`. +General: + MACAddressSource: eth0 \ No newline at end of file diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.yaml b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.yaml.bak similarity index 100% rename from foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.yaml rename to foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/meshtasticd/config.yaml.bak 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 e3470cb..ccc6b41 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 @@ -22,6 +22,7 @@ Re-running this script will:\n\ * Set the eth0 MAC to be derivative of CPU serial number\n\ * Add terminal type to user femto's .bashrc\n\ * Add a shortcut \`sfc\` to user femto's .bashrc\n\ +* Enable the meshtasticd service\n\ \n\ Finally, the Femtofox will reboot.\n\ \n\ @@ -106,6 +107,9 @@ else log_message "\`alias sfc='sudo femto-config'\` already present in .bashrc, skipping" fi +log_message "Enabling meshtasticd service" +systemctl enable 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..." From d2d2fd9cbe51b71328ae4c424774428ee06f8445 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 19:22:59 +0200 Subject: [PATCH 2/8] Update override.conf --- .../etc/systemd/system/meshtasticd.service.d/override.conf | 2 -- 1 file changed, 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf index add99ee..2af10c1 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/meshtasticd.service.d/override.conf @@ -1,6 +1,4 @@ [Service] -ExecStart= -ExecStart=/bin/sh -c '/usr/sbin/meshtasticd -h $(sed -n "/Serial/ s/^.*: \\(.*\\)$/\\U\\1/p" /proc/cpuinfo | bc | tail -c 9)' Nice=-20 [Unit] From 60f2432c69ed13fab1870bbd1a3c212ea6a0a81d Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 21:09:20 +0200 Subject: [PATCH 3/8] Update femtofox.chroot --- environment-setup/femtofox.chroot | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 95496ec..4fde2e5 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -56,13 +56,13 @@ echo "femtofox" | tee /etc/hostname > /dev/null echo "Configuring autostart of systemd services..." systemctl enable button -#systemctl enable meshtasticd systemctl enable femto-runonce.service systemctl enable femto-usb-config-tool.service systemctl enable femto-boot-complete.service systemctl enable femto-wifi-mesh-control systemctl enable femto-watchclock-dog +systemctl disable meshtasticd systemctl disable apt-daily.timer systemctl disable unattended-upgrades systemctl disable smbd nmbd # samba services, can be enabled via menu From 298c545cfae74720fc79ddc13e1da136e2846b3b Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 21:36:20 +0200 Subject: [PATCH 4/8] Update femto-runonce.sh --- .../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 ccc6b41..3a0c50d 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 @@ -38,6 +38,7 @@ echo -e "\e[32m******* First boot *******\e[0m" # pulse LED during firstboot ( + echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction while true; do echo 1 > /sys/class/gpio/gpio34/value; sleep 0.5; From 7bf723d62dcd9ed3e5a0830c7efcc279de48ab47 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 22:09:01 +0200 Subject: [PATCH 5/8] fix a couple service Afters --- .../etc/systemd/system/femto-runonce.service | 2 +- .../etc/systemd/system/femto-usb-config-tool.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service index d5692f4..574335d 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-runonce.service @@ -1,6 +1,6 @@ [Unit] Description=Foxbuntu First Boot -After=meshtasticd.service +After=rc-local.service Before=serial-getty@ttyFIQ0.service DefaultDependencies=no diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service index 679b722..8f1c5dc 100644 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/etc/systemd/system/femto-usb-config-tool.service @@ -1,6 +1,6 @@ [Unit] Description=Foxbuntu USB Configuration Tool -After=meshtasticd.service +After=rc-local.service Before=serial-getty@ttyFIQ0.service DefaultDependencies=no From 0ce3fb15354e7a972ff95c2702637051123d4392 Mon Sep 17 00:00:00 2001 From: nagumii Date: Wed, 12 Feb 2025 22:15:37 +0200 Subject: [PATCH 6/8] remove debug line --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-runonce.sh | 1 - 1 file changed, 1 deletion(-) 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 3a0c50d..ccc6b41 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 @@ -38,7 +38,6 @@ echo -e "\e[32m******* First boot *******\e[0m" # pulse LED during firstboot ( - echo 34 > /sys/class/gpio/export && echo out > /sys/class/gpio/gpio34/direction while true; do echo 1 > /sys/class/gpio/gpio34/value; sleep 0.5; From 7ed3a99ee46aaed6f86fb1bf5c635960350c481c Mon Sep 17 00:00:00 2001 From: nagumii Date: Thu, 13 Feb 2025 13:42:53 +0200 Subject: [PATCH 7/8] Revamp kernel module manager --- .../usr/local/bin/femto-kernel-modules.sh | 89 ++++++++++++------- 1 file changed, 55 insertions(+), 34 deletions(-) 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 50df6dc..3ac19f4 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 @@ -1,9 +1,17 @@ #!/bin/bash +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root." + echo "Try \`sudo femto-config\`." + exit 1 +fi + help=$(cat <> /etc/modules fi - echo "$1 has been enabled and will be started at boot." + echo -e "\033[4m$1\033[0m has been enabled and will be started at boot.\n\nSome modules are unloaded automatically when not in use." else + echo -e "Failed to enable \033[4m$1\033[0m." exit 1 fi elif [ $2 = "disable" ]; then rmmod $1 # Disable the module - if [ $? -eq 0 ]; then - sed -i "/^$1$/d" /etc/modules - echo "$1 has been disabled and removed from boot." - else - exit 1 - fi + sed -i "/^$1$/d" /etc/modules + echo -e "\033[4m$1\033[0m has been disabled and removed from boot.\n\nIt may be automatically loaded if compatible hardware is detected." else echo "Invalid argument \"$2\".\n$help" fi } # Parse options -while getopts ":hx" opt; do +while getopts ":hbax" opt; do case ${opt} in h) # Option -l (set lora radio) echo "$help" exit 0 ;; + b) # kernel modules set to start at boot) + echo -e "$(modules=$(sed -n '6,$p' /etc/modules | awk '{printf "%s\033[0m \033[4m", $0}' | sed 's/\033\[0m \033\[4m$//'); [ -z "$modules" ] && echo "none" || echo "$modules")" + ;; + a) # kernel modules currently active) + echo -e "$(lsmod | awk 'NR>1 {printf "%s\033[0m \033[4m", $1}' | sed 's/\033\[0m \033\[4m$//')" + ;; x) # Option -x (Set kernel module status (enable/disable)) echo "$(module_switch $2 $3)" ;; @@ -48,42 +59,52 @@ if [ -n "$1" ]; then # if there are arguments, don't proceed to menu exit fi -dialog --infobox "Loading kernel module menu..." 5 45 -modules=() - -# Create a list of modules (filename minus the .ko) -for module in $(ls "/lib/modules/5.10.160"/*.ko); do - module_name=$(basename "$module" .ko) - modules+=("$module_name" "$(modinfo $module_name | grep -i 'description' | cut -d: -f2 | sed 's/^[ \t]*//')") -done +dialog --no-collapse --colors --title "$title" --yesno "\ +Kernel modules are loadable pieces of code that extend a Linux kernel's functionality without requiring a reboot. Common examples include device drivers, file systems, or system calls.\n\ +\n\ +This tool will allow you to manage kernel modules and add pre-compiled modules to Foxbuntu.\n\ +\n\ +Boot modules: \Zu$(femto-utils.sh -R "$(femto-kernel-modules.sh -b)")\Zu\Zn\n\ +Active modules: \Zu$(femto-utils.sh -R "$(femto-kernel-modules.sh -a)")\Zu\Zn\n\ +\n\ +Continue? +" 0 0 +[ ! $? -eq 0 ] && exit 1 while true; do + dialog --infobox "Loading kernel module menu..." 5 45 + modules=("Module name" "Loaded/Boot? Description" "" "") + + # Create a list of modules (filename minus the .ko) + for module in $(ls "/lib/modules/5.10.160"/*.ko); do + module_name=$(basename "$module" .ko) + modules+=("$module_name" "$(lsmod | grep -q "^$module_name " && echo ✅ || echo ❌)$(femto-kernel-modules.sh -b | sed 's/\x1b\[[0-9;]*m//g' | grep -qw "$module_name" && echo ✅ || echo ❌) $(modinfo $module_name | grep -i 'description' | cut -d: -f2 | sed 's/^[ \t]*//')") + done + # Create the menu options - 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 - - if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog - break - fi + option=$(dialog --cancel-label "Back" --title "Kernel Modules" --no-shadow --default-item "$selected_module" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3) + [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog # 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 \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 - else - dialog --colors --title "Enable Module" --yesno "The module '$selected_module' is currently \Z1disabled\Zn.\n\nDo you want to enable it?\n\nFull module info:\n$modinfo_output\n\nNote: Dependencies will be loaded automatically." 25 0 - if [ $? -eq 0 ]; then - dialog --msgbox "$(module_switch $selected_module enable)" 7 60 - fi + dialog --colors --yes-label "Back" --no-label "Disable" --extra-button --extra-label "Enable" --title "$selected_module" --yesno "\ +Module is currently $(lsmod | grep -q "^$selected_module " && echo "\Z4loaded\Zn" || echo "\Z1unloaded\Zn") and is set $(femto-utils.sh -R "$(femto-kernel-modules.sh -b | sed 's/\x1b\[[0-9;]*m//g' | grep -qw "$selected_module" && echo "\Z4to load at boot\Zn" || echo "\Z1not to load at boot\Zn. It may load automatically if needed")").\n\ +\n\ +Full module info:\n\ +$modinfo_output\n\ +\n\ +Note: Dependencies are loaded/unloaded automatically." 0 0 + exit_status=$? # This line checks the exit status of the dialog command + if [ $exit_status -eq 0 ]; then # "Back" button (yes) + continue + elif [ $exit_status -eq 3 ]; then # "Enable" button (no) + dialog --colors --title "$selected_module" --msgbox "$(femto-utils.sh -R "$(module_switch $selected_module enable)")" 9 60 + elif [ $exit_status -eq 1 ]; then # "Disable" button (extra) + dialog --colors --title "$selected_module" --msgbox "$(femto-utils.sh -R "$(module_switch $selected_module disable)")" 9 60 fi done From f689b8ba208883aa41785e3f9e2fbd8df70d595a Mon Sep 17 00:00:00 2001 From: noon92 <40807970+noon92@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:44:36 +0200 Subject: [PATCH 8/8] Update femto-kernel-modules.sh --- .../usr/local/bin/femto-kernel-modules.sh | 91 +++++++------------ 1 file changed, 35 insertions(+), 56 deletions(-) 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 3ac19f4..eb1b599 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 @@ -1,17 +1,9 @@ #!/bin/bash -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root." - echo "Try \`sudo femto-config\`." - exit 1 -fi - help=$(cat <> /etc/modules fi - echo -e "\033[4m$1\033[0m has been enabled and will be started at boot.\n\nSome modules are unloaded automatically when not in use." + echo "$1 has been enabled and will be started at boot." else - echo -e "Failed to enable \033[4m$1\033[0m." exit 1 fi elif [ $2 = "disable" ]; then rmmod $1 # Disable the module - sed -i "/^$1$/d" /etc/modules - echo -e "\033[4m$1\033[0m has been disabled and removed from boot.\n\nIt may be automatically loaded if compatible hardware is detected." + if [ $? -eq 0 ]; then + sed -i "/^$1$/d" /etc/modules + echo "$1 has been disabled and removed from boot." + else + exit 1 + fi else echo "Invalid argument \"$2\".\n$help" fi } # Parse options -while getopts ":hbax" opt; do +while getopts ":hx" opt; do case ${opt} in h) # Option -l (set lora radio) echo "$help" exit 0 ;; - b) # kernel modules set to start at boot) - echo -e "$(modules=$(sed -n '6,$p' /etc/modules | awk '{printf "%s\033[0m \033[4m", $0}' | sed 's/\033\[0m \033\[4m$//'); [ -z "$modules" ] && echo "none" || echo "$modules")" - ;; - a) # kernel modules currently active) - echo -e "$(lsmod | awk 'NR>1 {printf "%s\033[0m \033[4m", $1}' | sed 's/\033\[0m \033\[4m$//')" - ;; x) # Option -x (Set kernel module status (enable/disable)) echo "$(module_switch $2 $3)" ;; @@ -59,53 +48,43 @@ if [ -n "$1" ]; then # if there are arguments, don't proceed to menu exit fi +dialog --infobox "Loading kernel module menu..." 5 45 -dialog --no-collapse --colors --title "$title" --yesno "\ -Kernel modules are loadable pieces of code that extend a Linux kernel's functionality without requiring a reboot. Common examples include device drivers, file systems, or system calls.\n\ -\n\ -This tool will allow you to manage kernel modules and add pre-compiled modules to Foxbuntu.\n\ -\n\ -Boot modules: \Zu$(femto-utils.sh -R "$(femto-kernel-modules.sh -b)")\Zu\Zn\n\ -Active modules: \Zu$(femto-utils.sh -R "$(femto-kernel-modules.sh -a)")\Zu\Zn\n\ -\n\ -Continue? -" 0 0 -[ ! $? -eq 0 ] && exit 1 +modules=() + +# Create a list of modules (filename minus the .ko) +for module in $(ls "/lib/modules/5.10.160"/*.ko); do + module_name=$(basename "$module" .ko) + modules+=("$module_name" "$(modinfo $module_name | grep -i 'description' | cut -d: -f2 | sed 's/^[ \t]*//')") +done while true; do - dialog --infobox "Loading kernel module menu..." 5 45 - modules=("Module name" "Loaded/Boot? Description" "" "") - - # Create a list of modules (filename minus the .ko) - for module in $(ls "/lib/modules/5.10.160"/*.ko); do - module_name=$(basename "$module" .ko) - modules+=("$module_name" "$(lsmod | grep -q "^$module_name " && echo ✅ || echo ❌)$(femto-kernel-modules.sh -b | sed 's/\x1b\[[0-9;]*m//g' | grep -qw "$module_name" && echo ✅ || echo ❌) $(modinfo $module_name | grep -i 'description' | cut -d: -f2 | sed 's/^[ \t]*//')") - done - # Create the menu options - option=$(dialog --cancel-label "Back" --title "Kernel Modules" --no-shadow --default-item "$selected_module" --menu "" 42 103 8 "${modules[@]}" 3>&1 1>&2 2>&3) - [ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog + 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 + + if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog + break + fi # 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 - dialog --colors --yes-label "Back" --no-label "Disable" --extra-button --extra-label "Enable" --title "$selected_module" --yesno "\ -Module is currently $(lsmod | grep -q "^$selected_module " && echo "\Z4loaded\Zn" || echo "\Z1unloaded\Zn") and is set $(femto-utils.sh -R "$(femto-kernel-modules.sh -b | sed 's/\x1b\[[0-9;]*m//g' | grep -qw "$selected_module" && echo "\Z4to load at boot\Zn" || echo "\Z1not to load at boot\Zn. It may load automatically if needed")").\n\ -\n\ -Full module info:\n\ -$modinfo_output\n\ -\n\ -Note: Dependencies are loaded/unloaded automatically." 0 0 - exit_status=$? # This line checks the exit status of the dialog command - if [ $exit_status -eq 0 ]; then # "Back" button (yes) - continue - elif [ $exit_status -eq 3 ]; then # "Enable" button (no) - dialog --colors --title "$selected_module" --msgbox "$(femto-utils.sh -R "$(module_switch $selected_module enable)")" 9 60 - elif [ $exit_status -eq 1 ]; then # "Disable" button (extra) - dialog --colors --title "$selected_module" --msgbox "$(femto-utils.sh -R "$(module_switch $selected_module disable)")" 9 60 + # 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 \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 + else + dialog --colors --title "Enable Module" --yesno "The module '$selected_module' is currently \Z1disabled\Zn.\n\nDo you want to enable it?\n\nFull module info:\n$modinfo_output\n\nNote: Dependencies will be loaded automatically." 25 0 + if [ $? -eq 0 ]; then + dialog --msgbox "$(module_switch $selected_module enable)" 7 60 + fi fi done -exit 0 \ No newline at end of file +exit 0