Final touches

This commit is contained in:
nagumii 2025-02-14 14:13:30 +02:00
parent 35128e204e
commit d52e26def2
2 changed files with 17 additions and 9 deletions

View file

@ -4,14 +4,22 @@ title="Software Manager"
package_dir="/usr/local/bin/packages"
install() {
dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nProceed?" 10 40
dialog --no-collapse --title "Install $($package_dir/$1.sh -N)" --yesno "\nInstallation requires internet connectivity.\n\nInstall $($package_dir/$1.sh -N)?" 10 40
[ $? -eq 1 ] && return 1 #if cancel/no
echo "Installing $($package_dir/$1.sh -N)..."
# Run the installation script, capturing the output and displaying it in real time
output=$($package_dir/$1.sh -i | tee /dev/tty)
install_status=$? # Capture the exit status of the eval command
if [ ${#output} -gt 2048 ]; then # Truncate to 2048 characters and append ellipsis and note if necessary
truncated_output="${output:0:2000}...\nLOG TRUNCATED"
if [[ "$output" =~ user_message: ]]; then # preserve user_message by adding to end of string
truncated_output="$truncated_output\n$(echo "$output" | sed -n 's/.*\(user_message:.*\)/\1/p')"
fi
output="$truncated_output"
fi
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
echo $user_message
output=$(echo -e "$output" | sed '/user_message: /,$d') # remove the user message from the detailed output
if [ $install_status -eq 0 ]; then # if the installation was successful
@ -22,7 +30,7 @@ install() {
}
uninstall() {
dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nReinstallation will require internet connectivity.\n\nProceed?" 10 40
dialog --no-collapse --title "Uninstall $($package_dir/$1.sh -N)" --yesno "\nNote: reinstallation will require internet connectivity.\n\nUninstall $($package_dir/$1.sh -N)?" 10 40
[ $? -eq 1 ] && return 1 #if cancel/no
echo "Uninstalling $($package_dir/$1.sh -N)..."
output=$(eval "$package_dir/$1.sh -u 2>&1 | tee /dev/tty")
@ -37,7 +45,7 @@ uninstall() {
}
initialize() {
dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nProceed?" 13 50
dialog --no-collapse --title "$title" --yesno "\nIntialize $($package_dir/$1.sh -N)\n\nInitialization runs commands that require user interaction and so can only be run from terminal.\n\nInitialize $($package_dir/$1.sh -N)?" 13 50
[ $? -eq 1 ] && return 1 #if cancel/no
clear
echo "Initializing $($package_dir/$1.sh -N)..."
@ -50,7 +58,7 @@ initialize() {
}
upgrade() {
dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nProceed?" 10 40
dialog --no-collapse --title "Upgrade $($package_dir/$1.sh -N)" --yesno "\nUpgrade requires internet connectivity.\n\nUpgrade $($package_dir/$1.sh -N)?" 10 40
[ $? -eq 1 ] && return 1 #if cancel/no
echo "Upgrading $($package_dir/$1.sh -N)..."
output=$(eval "$package_dir/$1.sh -g 2>&1 | tee /dev/tty")

View file

@ -13,9 +13,9 @@ 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="xiuagedsrNADUOSELGTCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiugedsrNADUOSELGTCI" # 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"
service_name="mesh_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`
license="$location/LICENSE" # file to cat to display license
license_name="GPL3" # license name, such as MIT, GPL3, custom, whatever. short text string
@ -29,7 +29,9 @@ install() {
fi
pip install -r $location/requirements.txt
if [ "$interactive" = "true" ]; then #interactive install
interactive_init
"$location/install.sh" | tee /dev/tty
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
exit 0
else
echo "user_message: IMPORTANT: To complete installation, run \`sudo $location/install.sh\`\nTo change settings, run \`sudo nano $location/config.ini\`"
exit 0
@ -59,8 +61,6 @@ uninstall() {
# code that must be run to initialize the installation prior to use, but can only be run from terminal
interactive_init() {
"$location/install.sh" | tee /dev/tty
echo "user_message: To change settings, run \`sudo nano $location/config.ini\`"
exit 0
}