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`