diff --git a/environment-setup/femtofox.chroot b/environment-setup/femtofox.chroot index 531d67c..409ecd1 100644 --- a/environment-setup/femtofox.chroot +++ b/environment-setup/femtofox.chroot @@ -50,6 +50,9 @@ systemctl enable ttyd echo "Cloning Control for Meshtastic by pdxlocations" git clone https://github.com/pdxlocations/control.git /opt/control +pip install -r /opt/control/requirements.txt +chown -R femto /opt/control +git config --global --add safe.directory /opt/control # prevents git error when updating 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-config b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-config index ca33b5f..6ef09fe 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 @@ -532,8 +532,10 @@ meshtastic_settings() { ;; 5) # Meshtastic settings) check_meshtasticd_running && ( - dialog --no-collapse --infobox "Loading Meshtastic settings menu...\n\nThis can take up to a minute." 6 45 + dialog --no-collapse --infobox "Loading Meshtastic settings menu...\n\nStopping conflicting services, will restart after exit...\n\nThis can take up to a minute." 9 50 + femto-utils.sh -A stop python /opt/control/main.py --host + femto-utils.sh -A start ) ;; 6) #test mesh connectivity) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh index 037dec2..2d92d35 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/femto-install-wizard.sh @@ -73,8 +73,10 @@ wizard() { ;; 5) # Full Meshtastic settings menu) femto-config -c && ( - dialog --no-collapse --infobox "Loading Meshtastic settings menu...\n\nThis can take up to a minute." 6 45 + dialog --no-collapse --infobox "Loading Meshtastic settings menu...\n\nStopping conflicting services, will restart after exit...\n\nThis can take up to a minute." 9 50 + femto-utils.sh -A stop python /opt/control/main.py --host + femto-utils.sh -A start ) ;; 6) # return to previous menu) 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 2a0cb78..0e3af30 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 @@ -22,6 +22,7 @@ Options are: -E Generate/overwrite SSH encryption keys -C "service" Check if service is enabled, disabled, running -R "command" Replace colors for dialog menus +-A "stop" Stop/start services that are using the meshtastic API so the Control for Meshtastic settings UI can run without interference. Options: "stop" "start" -v Get Foxbuntu version EOF ) @@ -222,7 +223,7 @@ replace_colors() { echo "$input" } -while getopts ":harsl:ipcnoSEC:R:v" opt; do +while getopts ":harsl:ipcnoSEC:R:A:v" opt; do case ${opt} in h) # Option -h (help) echo -e "$help" @@ -285,6 +286,36 @@ while getopts ":harsl:ipcnoSEC:R:v" opt; do R) # replace colors) replace_colors "$OPTARG" ;; + A) # Stop/start services that are using the meshtastic API) + # this code cycles through all the software packages and looks for ones that are installed, conflict with Control and have a service that is enabled. If it finds such a software package, it either stops or starts it, according to $OPTARG + if [[ $OPTARG == "stop" ]]; then + action_text="Stopping" + action="s" + elif [[ $OPTARG == "start" ]]; then + action_text="Starting" + action="r" + else + echo "\`$OPTARG\` is not a valid argument for -A. Options are \"stop\" and \"start\"." + echo -e "$help" + exit 1 + fi + + for file in /usr/local/bin/packages/*.sh; do + filename=$(basename "$file") + + [[ "$filename" == femto_* ]] && continue # Skip files starting with "femto_" + + if sudo "$file" -I; then + if echo "$(sudo "$file" -C)" | grep -q "\"full control\" Meshtastic software"; then + service_state=$(sudo femto-utils.sh -C "$(sudo $file -E)") + if [[ $service_state =~ "enabled" ]] ; then + echo "$action_text $(sudo $file -N) service..." + eval "sudo $file -$action" + fi + fi + fi + done + ;; v) # get foxbuntu version) echo "Foxbuntu v$(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\S+' /etc/foxbuntu-release)" ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/control_for_meshtastic.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/control_for_meshtastic.sh index 37c06c4..0aef37b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/control_for_meshtastic.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/control_for_meshtastic.sh @@ -12,13 +12,13 @@ name="Control for Meshtastic" # software name author="pdxlocations" # software author - OPTIONAL description="Control for Meshtastic is a fully-featured Meshtastic configuration tool made for running in console, utilizing Curses.\n\nControl is installed by default on Femtofox and is used for Meshtastic configuration in femto-config. Uninstallation is not recommended." # software description - OPTIONAL (but strongly recommended!) URL="https://github.com/pdxlocations/control" # software URL. Can contain multiple URLs - OPTIONAL -options="hxiuglNADUOLGTI" # script options in use by software package. For example, for a package with no service, exclude `edsrS` +options="hxiuglNADUOLGTIC" # script options in use by software package. For example, for a package with no service, exclude `edsrS` launch="python /opt/control/main.py --host" # command to launch software, if applicable license="/opt/control/LICENSE" # file to cat to display license location="/opt/control" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` license="$location/LICENSE" # file to cat to display license license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string -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" +conflicts="\"Full control\" Meshtastic software, such as TC²-BBS and Meshing Around - but only while running." # 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() { @@ -29,7 +29,7 @@ install() { pip install -r $location/requirements.txt chown -R femto $location #give ownership of installation directory to $user git config --global --add safe.directory $location # prevents git error when updating - echo "user_message: To launch, run \`python $location/main.py --host\`" + echo "user_message: To launch, go to Meshtastic settings. Launching manually may conflict with \`full control\` Meshtastic software such as BBS." exit 0 # should be `exit 1` if operation failed } 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 768932f..2dda8ad 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,7 +19,7 @@ service_name="mesh_bot" # the name of the service, such as `chrony`. REQUIRED if location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` license="$location/LICENSE" # file to cat to display license license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string -conflicts="TC²-BBS, any other \"full control\" style bots" # comma delineated plain-text list of packages with which this package conflicts. 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" +conflicts="TC²-BBS, other \"full control\" Meshtastic software, Control (only when running)." # comma delineated plain-text list of packages with which this package conflicts. 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() { 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 3a479b4..e36a8ea 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 @@ -20,7 +20,7 @@ service_name="mesh-bbs" # the name of the service/s, such as `chrony`. REQUIRE location="/opt/TC2-BBS-mesh" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` license="$location/LICENSE" # file to cat to display license license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string -conflicts="Meshing Around, other \"full control\" packages" # 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" +conflicts="Meshing Around, other \"full control\" Meshtastic software, Control (only when running)." # 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() {