Further refinements to package manager

This commit is contained in:
nagumii 2025-01-11 01:04:57 +02:00
parent 7b3885f7a8
commit 58e65d4445
3 changed files with 52 additions and 23 deletions

View file

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

View file

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

View file

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