diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/curses b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/curses new file mode 100644 index 0000000..2289fc1 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/curses @@ -0,0 +1,5 @@ +#!/bin/bash +export NCURSES_NO_UTF8_ACS=1 +export TERM=xterm-256color +export LANG=C.UTF-8 +python /opt/curses-client-for-meshtastic/main.py --host 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 25dc19b..ec4c8fc 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 @@ -165,16 +165,17 @@ utilities() { local title="Utilities" while true; do local option="" - option=$(dialog --cancel-label "Back" --menu "$title" 16 40 4 \ + option=$(dialog --cancel-label "Back" --menu "$title" 17 40 4 \ 1 "Set system timezone" \ 2 "Kernel modules" \ 3 "Re-run first-boot script" \ 4 "Run USB configuration tool" \ 5 "Run OEM luckfox-config" \ - 6 "Reboot" \ - 7 "Shutdown" \ + 6 "Process viewer/manager" \ + 7 "Reboot" \ + 8 "Shutdown" \ "" "" \ - 8 "Back to Main Menu" 3>&1 1>&2 2>&3) + 9 "Back to Main Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -196,14 +197,15 @@ utilities() { fi ;; 5) luckfox-config ;; - 6) + 6) htop ;; + 7) dialog --title "$title" --yesno "Reboot now?\n\nTip: Reboot can also be triggered by long-pressing the BOOT button on the luckfox." 10 45 if [ $? -eq 0 ]; then #unless cancel/no dialog --infobox "Rebooting..." 5 45 reboot fi ;; - 7) + 8) dialog --title "$title" --yesno "Shut down now?\n\nTo power system back on, disconnect/reconnect power.\n\nThe system shutdown command prevents damage to the filesystem from power interrupts, but does not stop power consumption.\n\nTip: You can also shut down the Femtofox by pressing the BOOT button for 5 seconds or by running \`sudo halt\`." 14 60 if [ $? -eq 0 ]; then #unless cancel/no dialog --infobox "Shutting down...\n\nPower consumption will not stop." 5 45 @@ -211,7 +213,7 @@ utilities() { halt fi ;; - 8) return ;; + 9) return ;; esac done } 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 eecf9f7..3d208bb 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 @@ -10,7 +10,7 @@ install() { fi echo "Installing $($package_dir/$1.sh -N)..." # Run the installation script, capturing the output and displaying it in real time - output=$(eval "$package_dir/$1.sh -i 2>&1 | tee /dev/tty") + 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 @@ -24,7 +24,7 @@ install() { } uninstall() { - dialog --title "$title" --yesno "\nUninstall $1\n\nWill permanently delete all files and settings. Proceed?" 10 40 + dialog --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -69,10 +69,10 @@ package_intro() { $(if $package_dir/$1.sh -O | grep -q 'D'; then echo "\n$($package_dir/$1.sh -D)"; fi)\n\ \n\ $(echo "Currently: " && $package_dir/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\ -$(if $package_dir/$1.sh -O | grep -q 'L'; then echo "Installs to: \Zu$($package_dir/$1.sh -L)\Zn"; fi)\n\ -$(if $package_dir/$1.sh -O | grep -q 'C'; then echo "Conflicts with: \Zu$($package_dir/$1.sh -C)\Zn\n"; fi)\n\ +$(if output=$($package_dir/$1.sh -L); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn"; fi)\ +$(if output=$($package_dir/$1.sh -C); [ -n "$output" ]; then echo "Installs to: \Zu$output\Zn"; fi)\ An internet connection is required for installation.\n\ -$(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 50 75 +$(if $package_dir/$1.sh -O | grep -q 'U'; then echo "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0 package_menu $1 # after user hits "OK", move on to package menu } @@ -80,7 +80,7 @@ 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 --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 16 45 5 \ + choice=$(dialog --title "$title" --cancel-label "Back" --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) \ @@ -120,11 +120,13 @@ while true; do title="$title" option="" option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \ - 1 "Meshing Around by Spud" \ - 2 "The Comms Channel BBS, TC²BBS" \ - 3 "Curses Client for Meshtastic" \ + 1 "The Comms Channel BBS, TC²BBS" \ + 2 "Curses Client for Meshtastic" \ + 3 "Meshing Around by Spud" \ + 4 "Mosquitto MQTT Broker" \ + 5 "Mosquitto MQTT Client" \ "" ""\ - 4 "Back to Main Menu" 3>&1 1>&2 2>&3) + 6 "Back to Main Menu" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command if [ $exit_status -ne 0 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog @@ -132,10 +134,12 @@ title="$title" fi case $option in - 1) package_intro "meshing_around" ;; - 2) package_intro "tc2_bbs" ;; - 3) package_intro "curses_client" ;; - 4) break ;; + 1) package_intro "tc2_bbs" ;; + 2) package_intro "curses_client" ;; + 3) package_intro "meshing_around" ;; + 4) package_intro "mosquitto_mqtt_broker" ;; + 5) package_intro "mosquitto_mqtt_client" ;; + 6) break ;; esac done 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 new file mode 100644 index 0000000..e8a264d --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_broker.sh @@ -0,0 +1,148 @@ +#!/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 mosquitto -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 +} + + +# uninstall script +uninstall() { + DEBIAN_FRONTEND=noninteractive apt remove -y mosquitto 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\`." + 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 mosquitto 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 + 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/mosquitto_mqtt_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.sh new file mode 100644 index 0000000..834d85c --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/mosquitto_mqtt_client.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 mosquitto-clients -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 +} + + +# uninstall script +uninstall() { + DEBIAN_FRONTEND=noninteractive apt remove -y mosquitto-clients 2>&1 | tee /dev/tty + echo "user_message: Some files may remain on system. To remove, run \`sudo apt remove --purge mosquitto -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 mosquitto-clients 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-clients; 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/package_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh index 194695f..19a5dcd 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 @@ -61,6 +61,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 echo "user_message: Exit message to user, displayed prominently in post-install" exit 0 # should be `exit 1` if operation failed } @@ -73,7 +75,7 @@ uninstall() { } -#upgrade script +# upgrade script upgrade() { echo "user_message: Exit message to user, displayed prominently in post-install" exit 0 # should be `exit 1` if operation failed @@ -81,12 +83,19 @@ upgrade() { # Check if already installed. `exit 0` if yes, `exit 1` if no check() { - #the following works for cloned repos, but not for apt installs + # the following works for cloned repos, but not for apt installs if [ -d "$location" ]; then exit 0 else exit 1 fi + + # this works for apt packages + if [ dpkg -l | grep -q package-name ] ; then + exit 0 + else + exit 1 + fi } while getopts ":h$options" opt; do 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 4df601d..66af6c2 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 @@ -54,7 +54,7 @@ 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` -launch="/opt/TC2-BBS-mesh/server.py" # command to launch software, if applicable +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` 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"