From 5a15ef3e579e1edd8e1c660d2960ea75fd4288db Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 10 Jan 2025 21:05:17 +0200 Subject: [PATCH 01/16] major refactor of software menu and packages --- .../usr/local/bin/software/meshing_around.sh | 156 ++++++++++++++++++ .../local/bin/software/software_template.sh | 100 +++++++++++ .../usr/local/bin/software/tc2_bbs.sh | 129 +++++++++++++++ 3 files changed, 385 insertions(+) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh new file mode 100755 index 0000000..77ce232 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh @@ -0,0 +1,156 @@ +#!/bin/bash +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`." + exit 1 +fi + +args="$@" +help=$(cat < Date: Fri, 10 Jan 2025 21:05:36 +0200 Subject: [PATCH 02/16] Update femto-software.sh --- .../usr/local/bin/femto-software.sh | 192 +++++------------- 1 file changed, 51 insertions(+), 141 deletions(-) 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 2ee1458..90de11c 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 @@ -1,118 +1,10 @@ #!/bin/bash - +export NCURSES_NO_UTF8_ACS=1 +export TERM=screen +export LANG=C.UTF-8 +#set -x uninstall="false" -meshing_around() { # Install Meshing Around - failedInstall=false - #check if /opt/meshing-around exists if not git clone - if [ ! -d /opt/meshing-around ]; then - dialog --title "$software" --yesno "Meshing Around is a feature-rich bot designed to enhance your Meshtastic network experience with a variety of powerful tools and fun features\nConnectivity and utility through text-based message delivery.\nWhether you're looking to perform network tests, send messages, or even play games, mesh_bot.py has you covered.\nInstallation requires internet connection.\n\nLearn more at https://github.com/SpudGunMan/meshing-around\nIf software is already present, will attempt to update.\n\nInstall?" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - if ! git clone https://github.com/spudgunman/meshing-around /opt/meshing-around; then - dialog --title "$software" --msgbox "\nCloning of Meshing Around git repo failed.\nCheck internet connectivity." 10 60 - failedInstall=true - fi - fi - else - # /opt/meshing-around exists, check for updates - cd /opt/meshing-around - if ! sudo git pull; then - dialog --title "$software" --msgbox "\nFailed to update Meshing Around.\nCheck internet connectivity." 10 60 - failedInstall=true - fi - # check if /opt/meshing-around/data has any .pkl files if so assume it's installed - if [ -n "$(find /opt/meshing-around/data -name '*.pkl' -print -quit)" ]; then - # todo uninstall? - dialog --title "$software" --yesno "Meshing Around appears installed and updated, do you want to edit the config file? (press ctl+o,enter to save, ctl+x to exit nano)" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - sudo nano /opt/meshing-around/config.ini - fi - # set flag to not run install.sh - installed=true - echo "Restarting services..." - sudo systemctl restart mesh_bot - sudo systemctl restart pong_bot - fi - fi - # if /opt/meshing-around exists - if [ -f /opt/meshing-around/install.sh ] && [ "$installed" != true ] && [ "$failedInstall" != true ]; then - # ask what type of bot mesh or pong - dialog --title "$software" --yesno "Meshing Around can be configured to run as mesh_bot or pong_bot.\n\nRun mesh_bot?" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - /opt/meshing-around/install.sh mesh - dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+s save, ctl+x to exit editor)" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - sudo nano /opt/meshing-around/config.ini - echo "Restarting services..." - sudo systemctl restart mesh_bot - fi - # finished. display the contents of install_notes.txt - dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60 - else - /opt/meshing-around/install.sh pong - dialog --title "$software" --yesno "Would you like to edit the config file? (press ctl+s save, ctl+x to exit editor)" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - sudo nano /opt/meshing-around/config.ini - echo "Restarting services..." - sudo systemctl restart pong_bot - fi - # finished. display the contents of install_notes.txt - dialog --title "$software" --textbox /opt/meshing-around/install_notes.txt 20 60 - fi - fi -} - - -tc2_bbs() { # Install TC²BBS - dialog --title "$software" --yesno "The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory.\nInstallation requires internet connection.\n\nLearn more at https://github.com/TheCommsChannel/TC2-BBS-mesh\nIf software is already present, will attempt to update.\n\nInstall?" 0 0 - if [ $? -eq 0 ]; then #unless cancel/no - if [ ! -d /opt/TC2-BBS-mesh ]; then - if ! git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git /opt/TC2-BBS-mesh; then - dialog --title "$software" --msgbox "\nCloning of TC²-BBS git repo failed.\nCheck internet connectivity." 10 60 - return - fi - chown -R femto /opt/TC2-BBS-mesh - git config --global --add safe.directory /opt/TC2-BBS-mesh # prevents git error when updating - else - # /opt/meshing-around exists, check for updates - cd /opt/TC2-BBS-mesh - if ! sudo git pull; then - dialog --title "$software" --msgbox "\nFailed to update TC²-BBS.\nCheck internet connectivity." 10 60 - return - fi - fi - else - return - fi - if [ ! -f /opt/TC2-BBS-mesh/config.ini ]; then # if the config file doesn't exist but the clone was successful, then we need to do some configuring and rejiggering - cd /opt/TC2-BBS-mesh - echo "Creating virtual environment. This can take a couple minutes." - python3 -m venv venv - source venv/bin/activate - pip install -r requirements.txt - mv example_config.ini config.ini - sed -i 's/type = serial/type = tcp/' config.ini - sed -i 's/^# hostname = 192.168.x.x/hostname = 127.0.0.1/' config.ini - fi - echo "Installation/upgrade successful! Adding/recreating service." - cd /opt/TC2-BBS-mesh - source venv/bin/activate - sed -i "s/pi/${SUDO_USER:-$(whoami)}/g" mesh-bbs.service - sed -i "s|/home/femto/|/opt/|g" mesh-bbs.service - cp mesh-bbs.service /etc/systemd/system/ - sudo systemctl enable mesh-bbs.service - sudo systemctl restart mesh-bbs.service - - # for whatever reason, this is necessary - sleep 5 - sudo systemctl restart mesh-bbs - - echo -e "\nPress any key to continue..." - read -n 1 -s -r - dialog --title "$software" --msgbox "\nInstallation complete." 8 50 -} - - curses_client() { # Install curses client git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic ln -s /opt/curses-client-for-meshtastic/meshtastic-curses.py ~/meshtastic-curses.py @@ -140,34 +32,52 @@ gpsd() { # Install gpsd dialog --title "$software" --msgbox "\nInstallation complete.\n\nGPSD." 10 60 } +# build and display package intro, then load package menu +package_intro() { + dialog --title "$software" --msgbox "\ + $(/usr/local/bin/software/$1.sh -N)\n\ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'A'; then echo -e "by $(/usr/local/bin/software/$1.sh -A)"; fi)\n\ +\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'D'; then echo -e "\n$(/usr/local/bin/software/$1.sh -D)"; fi)\n\ +\n\ +An internet connection is required for installation.\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $(/usr/local/bin/software/$1.sh -U)"; fi) +" 0 0 + echo "Loading software menu..." + package_menu $1 +} -help=$(cat <&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 $choice in + "Install") eval "/usr/local/bin/software/$1.sh -i" ;; + "Uninstall") eval "/usr/local/bin/software/$1.sh -u" ;; + "Upgrade") eval "/usr/local/bin/software/$1.sh -g" ;; + "Enable service") eval "/usr/local/bin/software/$1.sh -e" ;; + "Disable service") eval "/usr/local/bin/software/$1.sh -d" ;; + "Stop service") eval "/usr/local/bin/software/$1.sh -s" ;; + "Start/restart service") eval "/usr/local/bin/software/$1.sh -r" ;; + "Back") break ;; + esac + done +} while true; do @@ -188,8 +98,8 @@ title="Software" fi case $option in - 1) meshing_around ;; - 2) tc2_bbs ;; + 1) package_intro "meshing_around" ;; + 2) package_intro "tc2_bbs" ;; 3) curses_client ;; 4) mosquitto ;; 5) gpsd ;; From 154561fe85c28fe08fe73ee7d58ab08f2fb99afc Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 10 Jan 2025 22:03:12 +0200 Subject: [PATCH 03/16] Update femto-software.sh --- .../usr/local/bin/femto-software.sh | 29 ------------------- 1 file changed, 29 deletions(-) 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 90de11c..4e159b2 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 @@ -2,35 +2,6 @@ export NCURSES_NO_UTF8_ACS=1 export TERM=screen export LANG=C.UTF-8 -#set -x -uninstall="false" - -curses_client() { # Install curses client - git clone https://github.com/pdxlocations/curses-client-for-meshtastic.git /opt/curses-client-for-meshtastic - ln -s /opt/curses-client-for-meshtastic/meshtastic-curses.py ~/meshtastic-curses.py - # config the curses client to localhost tcp TODO, permissions? - dialog --title "$software" --msgbox "\nInstallation complete.\n\nRun \`~/meshtastic-curses.py\` to launch." 10 60 -} - - -mosquitto() { # Install mosquitto - apt update - DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" mosquitto mosquitto-clients - # config mosquitto to listen on all interfaces and allow anonymous - sudo sh -c "echo 'listener 1883 0.0.0.0\nallow_anonymous true' >> /etc/mosquitto/mosquitto.conf" - sudo systemctl restart mosquitto - dialog --title "$software" --msgbox "\nInstallation complete.\n\nMosquitto service has been started." 10 60 -} - - -gpsd() { # Install gpsd - apt update - DEBIAN_FRONTEND=noninteractive apt install -y --option Dpkg::Options::="--force-confold" gpsd gpsd-clients python-gps - # do stuff TODO config gpsd and chrony - # telemetry script - sudo systemctl restart gpsd - dialog --title "$software" --msgbox "\nInstallation complete.\n\nGPSD." 10 60 -} # build and display package intro, then load package menu package_intro() { From 6714a79eb5ae9501b4b386ca6fc39aecd5c32435 Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 10 Jan 2025 22:12:22 +0200 Subject: [PATCH 04/16] add install location variable --- .../usr/local/bin/femto-software.sh | 8 ++++---- .../usr/local/bin/software/meshing_around.sh | 7 ++++++- .../usr/local/bin/software/software_template.sh | 16 ++++++++++++---- 3 files changed, 22 insertions(+), 9 deletions(-) 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 4e159b2..102dece 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 @@ -5,7 +5,7 @@ export LANG=C.UTF-8 # build and display package intro, then load package menu package_intro() { - dialog --title "$software" --msgbox "\ + dialog --title "Software Manager" --msgbox "\ $(/usr/local/bin/software/$1.sh -N)\n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'A'; then echo -e "by $(/usr/local/bin/software/$1.sh -A)"; fi)\n\ \n\ @@ -29,7 +29,7 @@ package_menu() { $(if /usr/local/bin/software/$1.sh -O | grep -q 's'; then echo "Stop service x"; fi) \ $(if /usr/local/bin/software/$1.sh -O | grep -q 'r'; then echo "Start/restart service x"; fi) \ "" "" \ - "Exit" "" 3>&1 1>&2 2>&3) + "Back" "" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -45,14 +45,14 @@ package_menu() { "Disable service") eval "/usr/local/bin/software/$1.sh -d" ;; "Stop service") eval "/usr/local/bin/software/$1.sh -s" ;; "Start/restart service") eval "/usr/local/bin/software/$1.sh -r" ;; - "Back") break ;; + "Back to software manager") break ;; esac done } while true; do -title="Software" +title="Software Manager" option="" option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \ 1 "Meshing Around by Spud" \ diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh index 77ce232..da36b08 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh @@ -6,7 +6,8 @@ fi args="$@" help=$(cat < Date: Fri, 10 Jan 2025 22:16:57 +0200 Subject: [PATCH 05/16] Refined comments in template --- .../usr/local/bin/software/meshing_around.sh | 8 ++++---- .../usr/local/bin/software/software_template.sh | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh index da36b08..6533837 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh @@ -34,12 +34,12 @@ EOF # Arguments to the script are stored in $args 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 OPTIONAL. Can contain multiple URLs +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="iugedsrNADUOS" # script options in use by software package. For example, for a package with no service, exclude `edsr` service_name="mesh_bot pong_bot" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2" -location="" # install location +location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` if [ $# -eq 0 ]; then diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh index ad5be60..1435677 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh @@ -34,12 +34,12 @@ EOF # Arguments to the script are stored in $args name="" # software name -author="" # software author OPTIONAL -description="" # software description OPTIONAL (but strongly recommended!) -URL="" # software URL OPTIONAL. Can contain multiple URLs +author="" # software author - OPTIONAL +description="" # software description - OPTIONAL (but strongly recommended!) +URL="" # software URL. Can contain multiple URLs - OPTIONAL options="iugedsrNADUOSL" # script options in use by software package. For example, for a package with no service, exclude `edsr` 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 +location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name` if [ $# -eq 0 ]; then From 7b3885f7a896c3635eabe0d31b2a6ff947ba4e28 Mon Sep 17 00:00:00 2001 From: nagumii Date: Fri, 10 Jan 2025 22:54:14 +0200 Subject: [PATCH 06/16] More refinements --- .../usr/local/bin/femto-software.sh | 27 +++++++++++++++++-- .../usr/local/bin/software/meshing_around.sh | 7 ++++- .../local/bin/software/software_template.sh | 6 ++++- .../usr/local/bin/software/tc2_bbs.sh | 16 +++++------ 4 files changed, 43 insertions(+), 13 deletions(-) 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 102dece..4b123de 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 @@ -3,13 +3,36 @@ export NCURSES_NO_UTF8_ACS=1 export TERM=screen export LANG=C.UTF-8 +install() { + dialog --title "Software Manager" --yesno "\nInstalling $1.\n\nProceed?" 10 40 + if [ $? -eq 1 ]; then #if cancel/no + return 1 + fi + # Run the installation script, capturing the output and displaying it in real time + output=$(eval "/usr/local/bin/software/$1.sh -i 2>&1 | tee /dev/tty") + install_status=$? # Capture the exit status of the eval command + + # Check the exit status of the installation command + if [ $install_status -eq 0 ]; then + dialog --colors --title "Software Manager" --msgbox "\n\Z2Installation successful!\Zn\n\nDetailed installation info:\n$output" 0 0 + else + dialog --colors --title "Software Manager" --msgbox "\n\Z1Installation FAILED!\Zn\n\nDetailed installation info:\n$output" 0 0 + fi +} + + + # build and display package intro, then load package menu package_intro() { - dialog --title "Software Manager" --msgbox "\ + dialog --colors --title "Software Manager" --msgbox "\ $(/usr/local/bin/software/$1.sh -N)\n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'A'; then echo -e "by $(/usr/local/bin/software/$1.sh -A)"; fi)\n\ \n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'D'; then echo -e "\n$(/usr/local/bin/software/$1.sh -D)"; fi)\n\ +\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'C'; then echo -e "\nDo not install with: \Zu$(/usr/local/bin/software/$1.sh -C)\Zn"; fi)\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'L'; then echo -e "\nInstalls to: \Zu$(/usr/local/bin/software/$1.sh -L)\Zn"; fi)\n\ + \n\ An internet connection is required for installation.\n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $(/usr/local/bin/software/$1.sh -U)"; fi) @@ -38,7 +61,7 @@ package_menu() { fi case $choice in - "Install") eval "/usr/local/bin/software/$1.sh -i" ;; + "Install") install $1 ;; "Uninstall") eval "/usr/local/bin/software/$1.sh -u" ;; "Upgrade") eval "/usr/local/bin/software/$1.sh -g" ;; "Enable service") eval "/usr/local/bin/software/$1.sh -e" ;; diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh index 6533837..1661d3b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh @@ -24,6 +24,7 @@ Arguments: -O Get options supported by this script -S Get service status -L Install location +-C Conflicts EOF ) @@ -32,14 +33,17 @@ EOF # Populate the install, uninstall and upgrade functions # Remember that this script may be launched in terminal, via web UI or another method, so inputs aren't really possible # Arguments to the script are stored in $args +# For install/uninstall/upgrade, output should be given as echo or printf +# Successful operations should `exit 0`, fails should `exit 1` 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="iugedsrNADUOS" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="iugedsrNADUOSLC" # script options in use by software package. For example, for a package with no service, exclude `edsr` service_name="mesh_bot pong_bot" # 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` +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" if [ $# -eq 0 ]; then @@ -155,6 +159,7 @@ while getopts ":h$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + C) echo -e $conflicts ;; esac done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh index 1435677..469dab1 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh @@ -24,6 +24,7 @@ Arguments: -O Get options supported by this script -S Get service status -L Install location +-C Conflicts EOF ) @@ -32,14 +33,16 @@ EOF # Populate the install, uninstall and upgrade functions # Remember that this script may be launched in terminal, via web UI or another method, so inputs aren't really possible # Arguments to the script are stored in $args +# For install/uninstall/upgrade, output should be given as echo or printf name="" # software name author="" # software author - OPTIONAL description="" # software description - OPTIONAL (but strongly recommended!) URL="" # software URL. Can contain multiple URLs - OPTIONAL -options="iugedsrNADUOSL" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="iugedsrNADUOSLC" # script options in use by software package. For example, for a package with no service, exclude `edsr` 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` +conflicts="" # 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" if [ $# -eq 0 ]; then @@ -102,6 +105,7 @@ while getopts ":h$options" opt; do systemctl status $service_name ;; L) echo -e $location ;; + C) echo -e $conflicts ;; esac done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh index 0d3c30a..1b2085d 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh @@ -35,7 +35,7 @@ fi install() { - dialog --title "$software" --yesno "\nInstallation requires internet connection.\n\nLearn more at \nIf software is already present, will attempt to update.\n\nInstall?" 0 0 + #dialog --title "$software" --yesno "\nInstallation requires internet connection.\n\nLearn more at \nIf software is already present, will attempt to update.\n\nInstall?" 0 0 if [ $? -eq 0 ]; then #unless cancel/no if [ ! -d /opt/TC2-BBS-mesh ]; then if ! git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git /opt/TC2-BBS-mesh; then @@ -48,7 +48,7 @@ install() { # /opt/meshing-around exists, check for updates cd /opt/TC2-BBS-mesh if ! sudo git pull; then - dialog --title "$software" --msgbox "\nFailed to update TC²-BBS.\nCheck internet connectivity." 10 60 + #dialog --title "$software" --msgbox "\nFailed to update TC²-BBS.\nCheck internet connectivity." 10 60 return fi fi @@ -58,9 +58,9 @@ install() { if [ ! -f /opt/TC2-BBS-mesh/config.ini ]; then # if the config file doesn't exist but the clone was successful, then we need to do some configuring and rejiggering cd /opt/TC2-BBS-mesh echo "Creating virtual environment. This can take a couple minutes." - python3 -m venv venv - source venv/bin/activate - pip install -r requirements.txt + #python3 -m venv venv + #source venv/bin/activate + #pip install -r requirements.txt mv example_config.ini config.ini sed -i 's/type = serial/type = tcp/' config.ini sed -i 's/^# hostname = 192.168.x.x/hostname = 127.0.0.1/' config.ini @@ -77,10 +77,8 @@ install() { # for whatever reason, this is necessary sleep 5 sudo systemctl restart mesh-bbs - - echo -e "\nPress any key to continue..." - read -n 1 -s -r - dialog --title "$software" --msgbox "\nInstallation complete." 8 50 + + #dialog --title "$software" --msgbox "\nInstallation complete." 8 50 } From 58e65d44457cf22c8277976f723d5af542274830 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 11 Jan 2025 01:04:57 +0200 Subject: [PATCH 07/16] Further refinements to package manager --- .../usr/local/bin/femto-software.sh | 37 ++++++++++--------- .../usr/local/bin/software/meshing_around.sh | 17 ++++++++- .../local/bin/software/software_template.sh | 21 +++++++++-- 3 files changed, 52 insertions(+), 23 deletions(-) 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 4b123de..f5c3641 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 @@ -3,8 +3,9 @@ export NCURSES_NO_UTF8_ACS=1 export TERM=screen export LANG=C.UTF-8 +title="Software Manager" install() { - dialog --title "Software Manager" --yesno "\nInstalling $1.\n\nProceed?" 10 40 + dialog --title "$title" --yesno "\nInstalling $1.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi @@ -14,9 +15,9 @@ install() { # Check the exit status of the installation command if [ $install_status -eq 0 ]; then - dialog --colors --title "Software Manager" --msgbox "\n\Z2Installation successful!\Zn\n\nDetailed installation info:\n$output" 0 0 + dialog --colors --title "$title" --beep --msgbox "\n\Z2Installation successful!\Zn\n\nDetailed installation info:\n$output" 0 0 else - dialog --colors --title "Software Manager" --msgbox "\n\Z1Installation FAILED!\Zn\n\nDetailed installation info:\n$output" 0 0 + dialog --colors --title "$title" --beep --msgbox "\n\Z1Installation FAILED!\Zn\n\nDetailed installation info:\n$output" 0 0 fi } @@ -24,35 +25,35 @@ install() { # build and display package intro, then load package menu package_intro() { - dialog --colors --title "Software Manager" --msgbox "\ + dialog --colors --title "$title" --msgbox "\ $(/usr/local/bin/software/$1.sh -N)\n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'A'; then echo -e "by $(/usr/local/bin/software/$1.sh -A)"; fi)\n\ \n\ $(if /usr/local/bin/software/$1.sh -O | grep -q 'D'; then echo -e "\n$(/usr/local/bin/software/$1.sh -D)"; fi)\n\ \n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'C'; then echo -e "\nDo not install with: \Zu$(/usr/local/bin/software/$1.sh -C)\Zn"; fi)\n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'L'; then echo -e "\nInstalls to: \Zu$(/usr/local/bin/software/$1.sh -L)\Zn"; fi)\n\ +$(echo "Currently: " && /usr/local/bin/software/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'L'; then echo -e "\nInstalls to: \Zu$(/usr/local/bin/software/$1.sh -L)\Zn"; fi)\n\ +$(if /usr/local/bin/software/$1.sh -O | grep -q 'C'; then echo -e "\nConflicts with: \Zu$(/usr/local/bin/software/$1.sh -C)\Zn"; fi)\n\ \n\ An internet connection is required for installation.\n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $(/usr/local/bin/software/$1.sh -U)"; fi) -" 0 0 +$(if /usr/local/bin/software/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $(/usr/local/bin/software/$1.sh -U)"; fi)" 0 0 echo "Loading software menu..." package_menu $1 } package_menu() { while true; do - choice=$(dialog --title "Software" --cancel-label "Back" --menu "$(/usr/local/bin/software/$1.sh -N)" 16 45 5 \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'i'; then echo "Install x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'u'; then echo "Uninstall x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'g'; then echo "Upgrade x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'e'; then echo "Enable service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'd'; then echo "Disable service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 's'; then echo "Stop service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'r'; then echo "Start/restart service x"; fi) \ + choice=$(dialog --title "$title" --cancel-label "Back" --menu "$(/usr/local/bin/software/$1.sh -N)" 16 45 5 \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'i' && /usr/local/bin/software/$1.sh -I; then echo "Install x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'u' && ! /usr/local/bin/software/$1.sh -I; then echo "Uninstall x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'g' && ! /usr/local/bin/software/$1.sh -I; then echo "Upgrade x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'e' && ! /usr/local/bin/software/$1.sh -I; then echo "Enable service x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'd' && ! /usr/local/bin/software/$1.sh -I; then echo "Disable service x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 's' && ! /usr/local/bin/software/$1.sh -I; then echo "Stop service x"; fi) \ + $(if /usr/local/bin/software/$1.sh -O | grep -q 'r' && ! /usr/local/bin/software/$1.sh -I; then echo "Start/restart service x"; fi) \ "" "" \ - "Back" "" 3>&1 1>&2 2>&3) + "Back to software manager" "" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -75,7 +76,7 @@ package_menu() { while true; do -title="Software Manager" +title="$title" option="" option=$(dialog --cancel-label "Back" --menu "$title" 0 0 6 \ 1 "Meshing Around by Spud" \ diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh index 1661d3b..e0a95bc 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh @@ -25,6 +25,7 @@ Arguments: -S Get service status -L Install location -C Conflicts +-I Check if installed. Returns an error if already installed EOF ) @@ -40,12 +41,11 @@ 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="iugedsrNADUOSLC" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` service_name="mesh_bot pong_bot" # 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` 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" - if [ $# -eq 0 ]; then echo "No arguments provided." echo -e "$help" @@ -123,6 +123,16 @@ upgrade() { echo placeholder } +# Check if already installed. `exit 1` if yes, `exit 0` if no +check() { + if [ -d "$location" ]; then + #echo "Already installed" + exit 1 + else + #echo "Not installed" + exit 0 + fi +} while getopts ":h$options" opt; do case ${opt} in @@ -160,6 +170,9 @@ while getopts ":h$options" opt; do ;; L) echo -e $location ;; C) echo -e $conflicts ;; + I) # Option -I (Check if already installed) + check + ;; esac done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh index 469dab1..2aaae6b 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh @@ -23,8 +23,9 @@ Arguments: -U Get URL -O Get options supported by this script -S Get service status --L Install location --C Conflicts +-L Get Install location +-C Get Conflicts +-I Check if installed. Returns an error if already installed EOF ) @@ -39,7 +40,7 @@ name="" # software name author="" # software author - OPTIONAL description="" # software description - OPTIONAL (but strongly recommended!) URL="" # software URL. Can contain multiple URLs - OPTIONAL -options="iugedsrNADUOSLC" # script options in use by software package. For example, for a package with no service, exclude `edsr` +options="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` 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` conflicts="" # 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" @@ -69,6 +70,17 @@ upgrade() { echo placeholder } +# Check if already installed. `exit 1` if yes, `exit 0` if no +check() { + # the following works for cloned repos, but not for apt installs + # if [ -d "$location" ]; then + # #echo "Already installed" + # exit 1 + # else + # #echo "Not installed" + # exit 0 + # fi +} while getopts ":h$options" opt; do case ${opt} in @@ -106,6 +118,9 @@ while getopts ":h$options" opt; do ;; L) echo -e $location ;; C) echo -e $conflicts ;; + I) # Option -I (Check if already installed) + check + ;; esac done From b3e8200111cc7ac56b9d4f61b338b65606a04848 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 11 Jan 2025 01:12:30 +0200 Subject: [PATCH 08/16] rename software dir to packages --- .../usr/local/bin/packages/meshing_around.sh | 179 ++++++++++++++++++ .../local/bin/packages/software_template.sh | 127 +++++++++++++ .../usr/local/bin/packages/tc2_bbs.sh | 127 +++++++++++++ 3 files changed, 433 insertions(+) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/tc2_bbs.sh 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 new file mode 100755 index 0000000..e0a95bc --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh @@ -0,0 +1,179 @@ +#!/bin/bash +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`." + exit 1 +fi + +args="$@" +help=$(cat < Date: Sat, 11 Jan 2025 01:13:56 +0200 Subject: [PATCH 09/16] complete renaming of software dir --- .../usr/local/bin/femto-config | 2 +- .../usr/local/bin/femto-software.sh | 45 ++--- .../usr/local/bin/software/meshing_around.sh | 179 ------------------ .../local/bin/software/software_template.sh | 127 ------------- .../usr/local/bin/software/tc2_bbs.sh | 127 ------------- 5 files changed, 24 insertions(+), 456 deletions(-) delete mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh delete mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/software_template.sh delete mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/tc2_bbs.sh 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 e731524..26b383d 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 @@ -501,7 +501,7 @@ while true; do 1 "Settings wizard" \ 2 "Networking" \ 3 "Meshtasticd" \ - 4 "Software" \ + 4 "Software manager" \ 5 "Utilities" \ 6 "Help" \ "" "" \ 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 f5c3641..4f64c17 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 @@ -4,13 +4,14 @@ export TERM=screen export LANG=C.UTF-8 title="Software Manager" +package_dir="/usr/local/bin/packages" install() { dialog --title "$title" --yesno "\nInstalling $1.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi # Run the installation script, capturing the output and displaying it in real time - output=$(eval "/usr/local/bin/software/$1.sh -i 2>&1 | tee /dev/tty") + output=$(eval "$package_dir/$1.sh -i 2>&1 | tee /dev/tty") install_status=$? # Capture the exit status of the eval command # Check the exit status of the installation command @@ -26,32 +27,32 @@ install() { # build and display package intro, then load package menu package_intro() { dialog --colors --title "$title" --msgbox "\ - $(/usr/local/bin/software/$1.sh -N)\n\ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'A'; then echo -e "by $(/usr/local/bin/software/$1.sh -A)"; fi)\n\ + $($package_dir/$1.sh -N)\n\ + $(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\ \n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'D'; then echo -e "\n$(/usr/local/bin/software/$1.sh -D)"; fi)\n\ +$(if $package_dir/$1.sh -O | grep -q 'D'; then echo -e "\n$($package_dir/$1.sh -D)"; fi)\n\ \n\ -$(echo "Currently: " && /usr/local/bin/software/$1.sh -I && echo "\Zuinstalled\Zn" || echo "\Zunot installed\Zn")\n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'L'; then echo -e "\nInstalls to: \Zu$(/usr/local/bin/software/$1.sh -L)\Zn"; fi)\n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'C'; then echo -e "\nConflicts with: \Zu$(/usr/local/bin/software/$1.sh -C)\Zn"; fi)\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 -e "\nInstalls to: \Zu$($package_dir/$1.sh -L)\Zn"; fi)\n\ +$(if $package_dir/$1.sh -O | grep -q 'C'; then echo -e "\nConflicts with: \Zu$($package_dir/$1.sh -C)\Zn"; fi)\n\ \n\ An internet connection is required for installation.\n\ -$(if /usr/local/bin/software/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $(/usr/local/bin/software/$1.sh -U)"; fi)" 0 0 +$(if $package_dir/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0 echo "Loading software menu..." package_menu $1 } package_menu() { while true; do - choice=$(dialog --title "$title" --cancel-label "Back" --menu "$(/usr/local/bin/software/$1.sh -N)" 16 45 5 \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'i' && /usr/local/bin/software/$1.sh -I; then echo "Install x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'u' && ! /usr/local/bin/software/$1.sh -I; then echo "Uninstall x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'g' && ! /usr/local/bin/software/$1.sh -I; then echo "Upgrade x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'e' && ! /usr/local/bin/software/$1.sh -I; then echo "Enable service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'd' && ! /usr/local/bin/software/$1.sh -I; then echo "Disable service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 's' && ! /usr/local/bin/software/$1.sh -I; then echo "Stop service x"; fi) \ - $(if /usr/local/bin/software/$1.sh -O | grep -q 'r' && ! /usr/local/bin/software/$1.sh -I; then echo "Start/restart service x"; fi) \ + choice=$(dialog --title "$title" --cancel-label "Back" --menu "$($package_dir/$1.sh -N)" 16 45 5 \ + $(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) \ + $(if $package_dir/$1.sh -O | grep -q 'g' && ! $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'e' && ! $package_dir/$1.sh -I; then echo "Enable service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'd' && ! $package_dir/$1.sh -I; then echo "Disable service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 's' && ! $package_dir/$1.sh -I; then echo "Stop service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'r' && ! $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \ "" "" \ "Back to software manager" "" 3>&1 1>&2 2>&3) @@ -63,12 +64,12 @@ package_menu() { case $choice in "Install") install $1 ;; - "Uninstall") eval "/usr/local/bin/software/$1.sh -u" ;; - "Upgrade") eval "/usr/local/bin/software/$1.sh -g" ;; - "Enable service") eval "/usr/local/bin/software/$1.sh -e" ;; - "Disable service") eval "/usr/local/bin/software/$1.sh -d" ;; - "Stop service") eval "/usr/local/bin/software/$1.sh -s" ;; - "Start/restart service") eval "/usr/local/bin/software/$1.sh -r" ;; + "Uninstall") eval "$package_dir/$1.sh -u" ;; + "Upgrade") eval "$package_dir/$1.sh -g" ;; + "Enable service") eval "$package_dir/$1.sh -e" ;; + "Disable service") eval "$package_dir/$1.sh -d" ;; + "Stop service") eval "$package_dir/$1.sh -s" ;; + "Start/restart service") eval "$package_dir/$1.sh -r" ;; "Back to software manager") break ;; esac done diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh deleted file mode 100755 index e0a95bc..0000000 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/software/meshing_around.sh +++ /dev/null @@ -1,179 +0,0 @@ -#!/bin/bash -if [[ $EUID -ne 0 ]]; then - echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`." - exit 1 -fi - -args="$@" -help=$(cat < Date: Sat, 11 Jan 2025 14:01:32 +0200 Subject: [PATCH 10/16] Continued improvements to package manager --- .../usr/local/bin/femto-software.sh | 40 ++++++++------- .../usr/local/bin/packages/meshing_around.sh | 20 +++++--- .../local/bin/packages/software_template.sh | 50 +++++++++++-------- 3 files changed, 66 insertions(+), 44 deletions(-) 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 4f64c17..dabd699 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 @@ -5,6 +5,7 @@ export LANG=C.UTF-8 title="Software Manager" package_dir="/usr/local/bin/packages" + install() { dialog --title "$title" --yesno "\nInstalling $1.\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no @@ -13,19 +14,21 @@ install() { # 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") 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 + output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output - # Check the exit status of the installation command - if [ $install_status -eq 0 ]; then - dialog --colors --title "$title" --beep --msgbox "\n\Z2Installation successful!\Zn\n\nDetailed installation info:\n$output" 0 0 + if [ $install_status -eq 0 ]; then # if the installation was successful + dialog --colors --title "$title" --beep --msgbox "\n\Z2Installation successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nDetailed installation info:\n$output" 0 0 else - dialog --colors --title "$title" --beep --msgbox "\n\Z1Installation FAILED!\Zn\n\nDetailed installation info:\n$output" 0 0 + dialog --colors --title "$title" --beep --msgbox "\n\Z1Installation FAILED!\Zn\n\n$user_message\n\nDetailed installation info:\n$output" 0 0 fi } - -# build and display package intro, then load package menu +# build and display package intro package_intro() { + echo "Loading package info..." + # check if each field in the package info is supported by the package, and if so get it and insert it into the package info dialog dialog --colors --title "$title" --msgbox "\ $($package_dir/$1.sh -N)\n\ $(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\ @@ -39,20 +42,21 @@ $(if $package_dir/$1.sh -O | grep -q 'C'; then echo -e "\nConflicts with: \Zu$($ \n\ An internet connection is required for installation.\n\ $(if $package_dir/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0 - echo "Loading software menu..." - package_menu $1 + package_menu $1 # after user hits "OK", move on to package menu } 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 \ - $(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) \ - $(if $package_dir/$1.sh -O | grep -q 'g' && ! $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \ - $(if $package_dir/$1.sh -O | grep -q 'e' && ! $package_dir/$1.sh -I; then echo "Enable service x"; fi) \ - $(if $package_dir/$1.sh -O | grep -q 'd' && ! $package_dir/$1.sh -I; then echo "Disable service x"; fi) \ - $(if $package_dir/$1.sh -O | grep -q 's' && ! $package_dir/$1.sh -I; then echo "Stop service x"; fi) \ - $(if $package_dir/$1.sh -O | grep -q 'r' && ! $package_dir/$1.sh -I; then echo "Start/restart service 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) \ + $(if $package_dir/$1.sh -O | grep -q 'g' && $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'e' && $package_dir/$1.sh -I; then echo "Enable service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'd' && $package_dir/$1.sh -I; then echo "Disable service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \ "" "" \ "Back to software manager" "" 3>&1 1>&2 2>&3) @@ -62,6 +66,7 @@ package_menu() { break fi + # execute the actual commands case $choice in "Install") install $1 ;; "Uninstall") eval "$package_dir/$1.sh -u" ;; @@ -96,10 +101,11 @@ title="$title" case $option in 1) package_intro "meshing_around" ;; 2) package_intro "tc2_bbs" ;; - 3) curses_client ;; + 3) package_intro "software_template" ;; 4) mosquitto ;; 5) gpsd ;; - 6) break ;; + 6) package_intro "software_template" ;; + 7) break ;; esac done 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 e0a95bc..44cb9ff 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 @@ -25,7 +25,7 @@ Arguments: -S Get service status -L Install location -C Conflicts --I Check if installed. Returns an error if already installed +-I Check if installed. Returns an error if not installed EOF ) @@ -36,6 +36,8 @@ EOF # Arguments to the script are stored in $args # For install/uninstall/upgrade, output should be given as echo or printf # 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 name="Meshing Around" # software name author="Spud" # software author - OPTIONAL @@ -114,23 +116,29 @@ install() { } +# uninstall script uninstall() { -echo placeholder + echo "user_message: Exit message to user, displayed prominently in post-install" + exit 0 # should be `exit 1` if the installation failed } +#upgrade script upgrade() { -echo placeholder + echo "user_message: Exit message to user, displayed prominently in post-install" + exit 0 # should be `exit 1` if the installation failed } -# Check if already installed. `exit 1` if yes, `exit 0` if no + +# Check if already installed. `exit 0` if yes, `exit 1` if no check() { + #the following works for cloned repos, but not for apt installs if [ -d "$location" ]; then #echo "Already installed" - exit 1 + exit 0 else #echo "Not installed" - exit 0 + exit 1 fi } diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh index 2aaae6b..458f74c 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh @@ -25,7 +25,7 @@ Arguments: -S Get service status -L Get Install location -C Get Conflicts --I Check if installed. Returns an error if already installed +-I Check if installed. Returns an error if not installed EOF ) @@ -35,15 +35,19 @@ EOF # Remember that this script may be launched in terminal, via web UI or another method, so inputs aren't really possible # Arguments to the script are stored in $args # For install/uninstall/upgrade, output should be given as echo or printf +# 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 -name="" # software name -author="" # software author - OPTIONAL -description="" # software description - OPTIONAL (but strongly recommended!) -URL="" # software URL. Can contain multiple URLs - OPTIONAL -options="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` -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` -conflicts="" # 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" + +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="iugedsrNADUOSLCI" # script options in use by software package. For example, for a package with no service, exclude `edsr` +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` +conflicts="package name, other package name" # 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" if [ $# -eq 0 ]; then @@ -55,31 +59,35 @@ fi # install script install() { - echo placeholder + echo "user_message: Exit message to user, displayed prominently in post-install" + exit 0 # should be `exit 1` if the installation failed } # uninstall script uninstall() { - echo placeholder + echo "user_message: Exit message to user, displayed prominently in post-install" + exit 0 # should be `exit 1` if the installation failed } #upgrade script upgrade() { - echo placeholder + echo "user_message: Exit message to user, displayed prominently in post-install" + exit 0 # should be `exit 1` if the installation failed } -# Check if already installed. `exit 1` if yes, `exit 0` if no + +# Check if already installed. `exit 0` if yes, `exit 1` if no check() { - # the following works for cloned repos, but not for apt installs - # if [ -d "$location" ]; then - # #echo "Already installed" - # exit 1 - # else - # #echo "Not installed" - # exit 0 - # fi + #the following works for cloned repos, but not for apt installs + if [ -d "$location" ]; then + #echo "Already installed" + exit 0 + else + #echo "Not installed" + exit 1 + fi } while getopts ":h$options" opt; do From d4d4a0bea95fd8cf285bc51db83435039c871df8 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 11 Jan 2025 18:29:07 +0200 Subject: [PATCH 11/16] add curses client to package manager --- .../usr/local/bin/packages/curses_client.sh | 169 ++++++++++++++++++ .../usr/local/bin/packages/meshing_around.sh | 16 +- .../local/bin/packages/software_template.sh | 48 ++--- .../usr/local/bin/packages/tc2_bbs.sh | 150 ++++++++++------ 4 files changed, 300 insertions(+), 83 deletions(-) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh new file mode 100755 index 0000000..d201816 --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh @@ -0,0 +1,169 @@ + #!/bin/bash +if [[ $EUID -ne 0 ]]; then + echo "This script must be run as root. Try \`sudo femto-meshtasticd-config\`." + exit 1 +fi + +args="$@" # arguments to this script +interaction="true" +help=$(cat <> "/home/${SUDO_USER:-$(whoami)}/.bashrc" + echo "Shortcut \`curses\` added to .bashrc" + else + echo "Shortcut already exists in .bashrc" + fi + source /home/${SUDO_USER:-$(whoami)}/.bashrc + echo "user_message: To launch, run \`curses\`." + exit 0 # should be `exit 1` if the installation failed +} + + +# uninstall script +uninstall() { + rm -rf $location + sed -i "/alias curses/d" "/home/${SUDO_USER:-$(whoami)}/.bashrc" + echo "Shortcut \`curses\` removed from .bashrc" + source /home/${SUDO_USER:-$(whoami)}/.bashrc + echo "user_message: All files removed shortcut \`curses\` removed." + exit 0 # should be `exit 1` if the installation failed +} + + +#upgrade script +upgrade() { + cd $location + if ! git pull; then + echo "user_message: Git pull failed. Is internet connected?" + exit 1 + fi + exit 0 +} + + +# Check if already installed. `exit 0` if yes, `exit 1` if no +check() { + #the following works for cloned repos, but not for apt installs + if [ -d "$location" ]; then + #echo "Already installed" + exit 0 + else + #echo "Not installed" + 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/meshing_around.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/meshing_around.sh index 44cb9ff..efb637c 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 @@ -7,8 +7,10 @@ fi args="$@" help=$(cat < Date: Sat, 11 Jan 2025 18:29:33 +0200 Subject: [PATCH 12/16] Update femto-software.sh --- .../usr/local/bin/femto-software.sh | 65 ++++++++++++++----- 1 file changed, 50 insertions(+), 15 deletions(-) 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 dabd699..af519b2 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 @@ -7,10 +7,11 @@ title="Software Manager" package_dir="/usr/local/bin/packages" install() { - dialog --title "$title" --yesno "\nInstalling $1.\n\nProceed?" 10 40 + dialog --title "$title" --yesno "\nInstall $1\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi + echo "Installing $1..." # 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") install_status=$? # Capture the exit status of the eval command @@ -18,12 +19,47 @@ install() { output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\Z2Installation successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nDetailed installation info:\n$output" 0 0 + dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\Z1Installation FAILED!\Zn\n\n$user_message\n\nDetailed installation info:\n$output" 0 0 + dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } +uninstall() { + dialog --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 + if [ $? -eq 1 ]; then #if cancel/no + return 1 + fi + echo "Uninstalling $1..." + output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty") + 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 + output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output + if [ $install_status -eq 0 ]; then # if the installation was successful + dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + else + dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + fi +} + +upgrade() { + dialog --title "$title" --yesno "\nUpgrade $1\n\nProceed?" 10 40 + if [ $? -eq 1 ]; then #if cancel/no + return 1 + fi + echo "Upgrading $1..." + output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty") + 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 + output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output + if [ $install_status -eq 0 ]; then # if the installation was successful + dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + else + dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + fi + +} + # build and display package intro package_intro() { @@ -32,16 +68,13 @@ package_intro() { dialog --colors --title "$title" --msgbox "\ $($package_dir/$1.sh -N)\n\ $(if $package_dir/$1.sh -O | grep -q 'A'; then echo -e "by $($package_dir/$1.sh -A)"; fi)\n\ -\n\ -$(if $package_dir/$1.sh -O | grep -q 'D'; then echo -e "\n$($package_dir/$1.sh -D)"; fi)\n\ +$(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 -e "\nInstalls to: \Zu$($package_dir/$1.sh -L)\Zn"; fi)\n\ -$(if $package_dir/$1.sh -O | grep -q 'C'; then echo -e "\nConflicts with: \Zu$($package_dir/$1.sh -C)\Zn"; fi)\n\ - -\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\ An internet connection is required for installation.\n\ -$(if $package_dir/$1.sh -O | grep -q 'U'; then echo -e "\nFor more information, visit $($package_dir/$1.sh -U)"; fi)" 0 0 +$(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 } @@ -50,6 +83,7 @@ package_menu() { 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 \ + $(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) \ $(if $package_dir/$1.sh -O | grep -q 'g' && $package_dir/$1.sh -I; then echo "Upgrade x"; fi) \ @@ -58,7 +92,7 @@ package_menu() { $(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \ "" "" \ - "Back to software manager" "" 3>&1 1>&2 2>&3) + "Back to software manager" "" 3>&1 1>&2 2>&3) exit_status=$? # This line checks the exit status of the dialog command @@ -68,14 +102,15 @@ package_menu() { # execute the actual commands case $choice in + "Run software") eval "$package_dir/$1.sh -l" ;; "Install") install $1 ;; - "Uninstall") eval "$package_dir/$1.sh -u" ;; - "Upgrade") eval "$package_dir/$1.sh -g" ;; + "Uninstall") uninstall $1 ;; + "Upgrade") upgrade $1 ;; "Enable service") eval "$package_dir/$1.sh -e" ;; "Disable service") eval "$package_dir/$1.sh -d" ;; "Stop service") eval "$package_dir/$1.sh -s" ;; "Start/restart service") eval "$package_dir/$1.sh -r" ;; - "Back to software manager") break ;; + "Back to software manager") break ;; esac done } @@ -101,7 +136,7 @@ title="$title" case $option in 1) package_intro "meshing_around" ;; 2) package_intro "tc2_bbs" ;; - 3) package_intro "software_template" ;; + 3) package_intro "curses_client" ;; 4) mosquitto ;; 5) gpsd ;; 6) package_intro "software_template" ;; From e328cc3bf9464a22ac8964cb7c5e1c7503e62d71 Mon Sep 17 00:00:00 2001 From: nagumii Date: Sat, 11 Jan 2025 19:01:49 +0200 Subject: [PATCH 13/16] rename file --- .../local/bin/packages/package_template.sh | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh 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 new file mode 100755 index 0000000..194695f --- /dev/null +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/package_template.sh @@ -0,0 +1,141 @@ +#!/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 < Date: Sat, 11 Jan 2025 19:01:58 +0200 Subject: [PATCH 14/16] Delete software_template.sh --- .../local/bin/packages/software_template.sh | 141 ------------------ 1 file changed, 141 deletions(-) delete mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh deleted file mode 100755 index ffc9178..0000000 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/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 < Date: Sat, 11 Jan 2025 19:52:16 +0200 Subject: [PATCH 15/16] +x --- .../usr/local/bin/packages/curses_client.sh | 8 +- .../usr/local/bin/packages/meshing_around.sh | 123 ++++++--------- .../local/bin/packages/software_template.sh | 141 ++++++++++++++++++ .../usr/local/bin/packages/tc2_bbs.sh | 56 +++---- 4 files changed, 223 insertions(+), 105 deletions(-) create mode 100755 foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/software_template.sh diff --git a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh index d201816..dbfaafb 100755 --- a/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh +++ b/foxbuntu/sysdrv/out/rootfs_uclibc_rv1106/usr/local/bin/packages/curses_client.sh @@ -5,12 +5,12 @@ if [[ $EUID -ne 0 ]]; then fi args="$@" # arguments to this script -interaction="true" +interactive="true" help=$(cat < Date: Sat, 11 Jan 2025 19:52:37 +0200 Subject: [PATCH 16/16] Update femto-software.sh --- .../usr/local/bin/femto-software.sh | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) 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 af519b2..46628db 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 @@ -7,11 +7,11 @@ title="Software Manager" package_dir="/usr/local/bin/packages" install() { - dialog --title "$title" --yesno "\nInstall $1\n\nProceed?" 10 40 + dialog --title "$title" --yesno "\nInstall $($package_dir/$1.sh -N)\n\nProceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi - echo "Installing $1..." + 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") install_status=$? # Capture the exit status of the eval command @@ -19,26 +19,26 @@ install() { output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuInstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$(echo -e $output)" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } uninstall() { - dialog --title "$title" --yesno "\nUninstall $1\n\nProceed?" 10 40 + dialog --title "$title" --yesno "\nUninstall $1\n\nWill permanently delete all files and settings. Proceed?" 10 40 if [ $? -eq 1 ]; then #if cancel/no return 1 fi - echo "Uninstalling $1..." + echo "Uninstalling $($package_dir/$1.sh -N)..." output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty") 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 output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuUninstallation of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } @@ -47,15 +47,15 @@ upgrade() { if [ $? -eq 1 ]; then #if cancel/no return 1 fi - echo "Upgrading $1..." + echo "Upgrading $($package_dir/$1.sh -N)..." output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty") 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 output=$(echo "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output if [ $install_status -eq 0 ]; then # if the installation was successful - dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $1 successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) successful!\Zn$([ -n "$user_message" ] && echo "\n\n$user_message")\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks else - dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $1 FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks + dialog --colors --title "$title" --beep --msgbox "\n\ZuUpgrade of $($package_dir/$1.sh -N) FAILED!\Zn\n\n$user_message\n\nLog:\n$output" 0 0 # if there's a user_message, display it with two preceeding line breaks fi } @@ -91,6 +91,7 @@ package_menu() { $(if $package_dir/$1.sh -O | grep -q 'd' && $package_dir/$1.sh -I; then echo "Disable service x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 's' && $package_dir/$1.sh -I; then echo "Stop service x"; fi) \ $(if $package_dir/$1.sh -O | grep -q 'r' && $package_dir/$1.sh -I; then echo "Start/restart service x"; fi) \ + $(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Get service status x"; fi) \ "" "" \ "Back to software manager" "" 3>&1 1>&2 2>&3) @@ -110,6 +111,7 @@ package_menu() { "Disable service") eval "$package_dir/$1.sh -d" ;; "Stop service") eval "$package_dir/$1.sh -s" ;; "Start/restart service") eval "$package_dir/$1.sh -r" ;; + "Get service status") dialog --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;; "Back to software manager") break ;; esac done @@ -123,10 +125,8 @@ title="$title" 1 "Meshing Around by Spud" \ 2 "The Comms Channel BBS, TC²BBS" \ 3 "Curses Client for Meshtastic" \ - 4 "Mosquitto MQTT broker" \ - 5 "GPS and Telemetry" \ "" ""\ - 6 "Back to Main Menu" 3>&1 1>&2 2>&3) + 4 "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 @@ -137,11 +137,14 @@ title="$title" 1) package_intro "meshing_around" ;; 2) package_intro "tc2_bbs" ;; 3) package_intro "curses_client" ;; - 4) mosquitto ;; - 5) gpsd ;; - 6) package_intro "software_template" ;; - 7) break ;; + 4) break ;; esac done -exit 0 \ No newline at end of file +exit 0 + + + # 4 "Mosquitto MQTT broker" \ + # 5 "GPS and Telemetry" \ + # 4) mosquitto ;; + # 5) gpsd ;; \ No newline at end of file