More refinements

This commit is contained in:
nagumii 2025-01-10 22:54:14 +02:00
parent fc0ace852f
commit 7b3885f7a8
4 changed files with 43 additions and 13 deletions

View file

@ -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" ;;

View file

@ -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

View file

@ -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

View file

@ -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
}