From 110d5f1a4d6855b743dd216f4938c10886420dad Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 18:53:12 +0200 Subject: [PATCH 1/4] Forgot to merge this and had to rewrite -_- --- .../usr/local/bin/femto-config | 1 + .../usr/local/bin/femto-meshtasticd-config.sh | 37 ++++++++++++++----- 2 files changed, 28 insertions(+), 10 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 009e93a..b3f4a7a 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 @@ -517,6 +517,7 @@ meshtastic_settings() { while true; do echo "Checking Meshtasticd service state..." local service_state="$(replace_colors "$(femto-meshtasticd-config.sh -S)")" + echo $service_state 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 \ "View detailed service status" "x" \ " " " " \ 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 6d8328e..4d0378a 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 @@ -18,9 +18,10 @@ Options are: -p Get legacy admin channel state -o "true" Set legacy admin channel state (true/false = enabled/disabled), case sensitive -r Test mesh connectivity by sending "test" to channel 0 and waiting for. Will attempt 3 times --s Start/restart Meshtasticd Service --t Stop Meshtasticd Service --S Get Meshtasticd Service state +-s Start/restart Meshtasticd service +-t Stop Meshtasticd service +-M "enable" Enable/disable Meshtasticd service. Options: "enable" "disable" +-S Get Meshtasticd service state -u Upgrade Meshtasticd -x Uninstall Meshtasticd -m Meshtastic update tool. Syntax: \`femto-meshtasticd-config.sh -m \"--set security.admin_channel_enabled false\" 10 \"Disable legacy admin\"\` @@ -70,7 +71,7 @@ meshtastic_update() { } # Parse options -while getopts ":higkl:q:va:cpo:sStruxm" opt; do +while getopts ":higkl:q:va:cpo:sM:Struxm" opt; do case ${opt} in h) # Option -h (help) echo -e "$help" @@ -168,13 +169,29 @@ Nodes in nodedb: $(echo "$output" | grep -oP '"![a-zA-Z0-9]+":\s*\{' | wc -l)\ systemctl restart meshtasticd echo "Meshtasticd service started/restarted." ;; - S) # Option -S (Get Meshtasticd Service state) - if echo "$(systemctl status meshtasticd)" | grep -q "active (running)"; then - echo -e "\033[4m\033[0;34mrunning\033[0m" - elif echo "$(systemctl status meshtasticd)" | grep -q "inactive (dead)"; then - echo -e "\033[4m\033[0;31mnot running\033[0m" + M) # Option -M (Meshtasticd Service disable/enable) + if [ "$OPTARG" = "enable" ]; then + systemctl enable meshtasticd + systemctl restart meshtasticd + elif [ "$OPTARG" = "disable" ]; then + systemctl disable meshtasticd + systemctl stop meshtasticd else - echo "unknown" + echo "-M argument requires either \"enable\" or \"disable\"" + echo $help + fi + ;; + S) # Option -S (Get Meshtasticd Service state) + if systemctl is-enabled meshtasticd &>/dev/null; then + if echo "$(systemctl status meshtasticd)" | grep -q "active (running)"; then + echo -e "\033[4m\033[0;34menabled and running\033[0m" + elif echo "$(systemctl status meshtasticd)" | grep -q "inactive (dead)"; then + echo -e "\033[4m\033[0;31mdnabled but not running\033[0m" + else + echo "unknown" + fi + else + echo -e "\033[4m\033[0;31mdisabled\033[0m" fi ;; t) # Option -t (stop Meshtasticd service) From 3ea190d02d1f3f82b620c7fc4a850b925e8f2f9c Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 18:55:29 +0200 Subject: [PATCH 2/4] Remove debug echo from femto-config --- .../sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config | 1 - 1 file changed, 1 deletion(-) 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 b3f4a7a..009e93a 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 @@ -517,7 +517,6 @@ meshtastic_settings() { while true; do echo "Checking Meshtasticd service state..." local service_state="$(replace_colors "$(femto-meshtasticd-config.sh -S)")" - echo $service_state 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 \ "View detailed service status" "x" \ " " " " \ From 3c4a62a57d59515e602f602b3df11d31ecfd7ae0 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 18:58:31 +0200 Subject: [PATCH 3/4] Remove errant exit --- .../out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh index f4785fd..e8f2812 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh @@ -27,7 +27,6 @@ log_message() { set_timezone() { if timedatectl set-timezone "$1"; then log_message "\nTime zone set to $1 (UTC$(date +%z)) successfully." - exit 0 else log_message "\nFailed to set the time zone to $1." exit 1 From 60a4f0657b5b4f2eb38049bf8fa66836bc31a2d0 Mon Sep 17 00:00:00 2001 From: nagumii Date: Mon, 20 Jan 2025 22:46:28 +0200 Subject: [PATCH 4/4] Remove redundant notification screen from timezone set --- .../rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh index e8f2812..3d73f7c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-set-time.sh @@ -25,10 +25,8 @@ log_message() { } set_timezone() { - if timedatectl set-timezone "$1"; then - log_message "\nTime zone set to $1 (UTC$(date +%z)) successfully." - else - log_message "\nFailed to set the time zone to $1." + if ! timedatectl set-timezone "$1"; then + log_message "\nFailed to set the time zone to $1." exit 1 fi }