Add license button to package installer

This commit is contained in:
nagumii 2025-02-08 00:54:25 +02:00
parent e0cc5ddc6c
commit efd5adc63e
9 changed files with 134 additions and 36 deletions

View file

@ -88,7 +88,8 @@ 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)
service_state=$(femto-utils.sh -C "$($package_dir/$1.sh -E)")
choice=$(dialog --no-collapse --colors --title "$($package_dir/$1.sh -N)" --cancel-label "Back" --default-item "$choice" --menu "$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Service status: $(femto-utils.sh -R "$service_state")"; fi)" 18 45 5 \
if $package_dir/$1.sh -O | grep -q 'G' && $package_dir/$1.sh -I; then license_button="--help-button --help-label License"; fi
choice=$(dialog --no-collapse --colors --title "$($package_dir/$1.sh -N)" --cancel-label "Back" --default-item "$choice" $license_button --menu "$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Service status: $(femto-utils.sh -R "$service_state")"; fi)" 18 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) \
@ -101,21 +102,27 @@ package_menu() {
$(if $package_dir/$1.sh -O | grep -q 'S' && $package_dir/$1.sh -I; then echo "Detailed service status x"; fi) \
" " "" \
"Back to software manager" "" 3>&1 1>&2 2>&3)
[ $? -eq 1 ] && break # Exit the loop if the user selects "Cancel" or closes the dialog
# execute the actual commands
case $choice in
"Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$package_dir/$1.sh -l" ;;
"Install") install $1 ;;
"Uninstall") uninstall $1 ;;
"Initialize") initialize $1 ;;
"Upgrade") upgrade $1 ;;
"Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;;
"Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;;
"Stop service") echo "Stopping service..." && eval "$package_dir/$1.sh -s" ;;
"Start/restart service") echo "Starting/restarting service..." && eval "$package_dir/$1.sh -r" ;;
"Detailed service status") echo "Getting service status..." && dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;;
"Back to software manager") break ;;
esac
exit_status=$? # This line checks the exit status of the dialog command
if [ $exit_status -eq 1 ]; then # Exit the loop if the user selects "Cancel" or closes the dialog
break
elif [ $exit_status -eq 2 ]; then # Help ("extra") button
dialog --no-collapse --colors --title "$($package_dir/$1.sh -N) License" --msgbox "$($package_dir/$1.sh -G)" 0 0
else
# execute the actual commands
case $choice in
"Run software") echo "Launching $($package_dir/$1.sh -N)..." && eval "$($package_dir/$1.sh -l)" ;;
"Install") install $1 ;;
"Uninstall") uninstall $1 ;;
"Initialize") initialize $1 ;;
"Upgrade") upgrade $1 ;;
"Enable service") echo "Enabling and starting service..." && eval "$package_dir/$1.sh -e" && eval "$package_dir/$1.sh -r" ;;
"Disable service") echo "Disabling and stopping service..." && eval "$package_dir/$1.sh -d" && eval "$package_dir/$1.sh -s" ;;
"Stop service") echo "Stopping service..." && eval "$package_dir/$1.sh -s" ;;
"Start/restart service") echo "Starting/restarting service..." && eval "$package_dir/$1.sh -r" ;;
"Detailed service status") echo "Getting service status..." && dialog --no-collapse --title "$title" --msgbox "$(eval "$package_dir/$1.sh -S")" 0 0 ;;
"Back to software manager") break ;;
esac
fi
done
}

View file

@ -10,10 +10,11 @@ help=$(cat <<EOF
Arguments:
-h This message
Environment - must be first argument:
-x User UI is not terminal (script interactive unavailable)
-x User UI is not terminal (script interaction unavailable)
Actions:
-i Install
-u Uninstall
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
-g Upgrade
-e Enable service, if applicable
-d Disable service, if applicable
@ -27,7 +28,10 @@ Arguments:
-U Get URL
-O Get options supported by this script
-S Get service status
-L Get Install location
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
EOF
@ -48,10 +52,11 @@ name="Contact" # software name
author="pdxlocations" # software author - OPTIONAL
description="A Text-Based Console UI for Meshtastic Nodes. Formerly called Curse Client.\nAfter install, run \`contact\` to launch." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/pdxlocations/contact/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiuglNADUOLCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
options="xiuglNADUOLGCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
launch="python /opt/contact/main.py --host" # command to launch software, if applicable
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="/opt/contact" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
conflicts="" # 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"
@ -115,6 +120,11 @@ check() {
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -157,6 +167,9 @@ while getopts ":h$options" opt; do
systemctl status $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)
check

View file

@ -15,7 +15,7 @@ help=$(cat <<EOF
Arguments:
-h This message
Environment - must be first argument:
-x User UI is not terminal (script interactive unavailable)
-x User UI is not terminal (script interaction unavailable)
Actions:
-i Install
-u Uninstall
@ -34,7 +34,9 @@ Arguments:
-O Get options supported by this script
-S Get service status
-E Get service name
-L Get Install location
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
EOF
@ -54,10 +56,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="xiuagedsrNADUOSELCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiuagedsrNADUOSELGCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
launch="" # command to launch software, if applicable
service_name="mesh_bot pong_bot mesh_bot_reporting" # the name of the service, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="/opt/meshing-around" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
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"
# install script
@ -122,6 +125,11 @@ check() {
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -171,6 +179,9 @@ while getopts ":h$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)
check

View file

@ -19,6 +19,7 @@ Arguments:
Actions:
-i Install
-u Uninstall
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
-g Upgrade
-e Enable service, if applicable
-d Disable service, if applicable
@ -34,6 +35,7 @@ Arguments:
-S Get service status
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
@ -55,11 +57,12 @@ name="Mosquitto MQTT Broker" # software name
author="Eclipse Foundation" # software author - OPTIONAL
description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!)
URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiugedsrNADUOSEPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiugedsrNADUOSEGPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
launch="" # command to launch software, if applicable
service_name="mosquitto" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
package_name="mosquitto" # apt package name, if applicable
location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
conflicts="" # 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"
# install script
@ -99,6 +102,11 @@ else
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -144,6 +152,9 @@ while getopts ":h$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
P) echo -e $package_name ;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)

View file

@ -19,6 +19,7 @@ Arguments:
Actions:
-i Install
-u Uninstall
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
-g Upgrade
-e Enable service, if applicable
-d Disable service, if applicable
@ -34,6 +35,7 @@ Arguments:
-S Get service status
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
@ -55,10 +57,11 @@ name="Mosquitto MQTT Client" # software name
author="Eclipse Foundation" # software author - OPTIONAL
description="Eclipse Mosquitto is an open source (EPL/EDL licensed) message broker that implements the MQTT protocol versions 5.0, 3.1.1 and 3.1. Mosquitto is lightweight and is suitable for use on all devices from low power single board computers to full servers.\n\nThe MQTT protocol provides a lightweight method of carrying out messaging using a publish/subscribe model. This makes it suitable for Internet of Things messaging such as with low power sensors or mobile devices such as phones, embedded computers or microcontrollers.\n\nThe Mosquitto project also provides a C library for implementing MQTT clients, and the very popular mosquitto_pub and mosquitto_sub command line MQTT clients.\n\nMosquitto is part of the Eclipse Foundation, and is an iot.eclipse.org project. The development is driven by Cedalo." # software description - OPTIONAL (but strongly recommended!)
URL="https://mosquitto.org/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiugedsrNADUOSEPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiugedsrNADUOSEGPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
launch="" # command to launch software, if applicable
service_name="" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="usr/share/doc/mosquitto-clients/copyright" # file to cat to display license
package_name="mosquitto-clients" # apt package name, if applicable
conflicts="" # 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"
@ -97,6 +100,11 @@ else
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -142,6 +150,9 @@ while getopts ":h$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
P) echo -e $package_name ;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)

View file

@ -35,6 +35,7 @@ Arguments:
-S Get service status
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
@ -55,11 +56,13 @@ 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="hxiuagedsrlNADUOSELPCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
options="hxiuagedsrlNADUOSELGPCI" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
launch="/opt/package/run.sh" # command to launch software, if applicable
license="/opt/package/license" # file to cat to display license
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"
package_name="apt_package" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
location="/opt/location" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
conflicts="package1, package2" # 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"
# install script
@ -105,6 +108,11 @@ check() {
fi
}
# display license - limit to 2000 chars
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -153,6 +161,9 @@ while getopts ":$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
P) echo -e $package_name ;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)

View file

@ -33,8 +33,9 @@ Arguments:
-U Get URL
-O Get options supported by this script
-S Get service status
-E Get service nam
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
@ -51,17 +52,18 @@ EOF
# 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
user_message="To connect to network share, enter \`\\\\femtofox\\home\` in Windows, \`smb://$(hostname)/home\` in MacOS or \`smbclient //$(hostname)/femto -U femto\` in Linux.\nDefault configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect, especially after succeeding previously, hit [win]+R and enter \`net use * /delete\`."
init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu, or enable the Samba service, run \`sudo smbpasswd -a femto\` to set a Samba password, and then restart the Samba service."
user_message="To connect to network share, enter \`\\\\femtofox\\home\` in Windows, \`smb://$(hostname)/home\` in MacOS or \`smbclient //$(hostname)/femto -U femto\` in Linux. Default configuration shares /home/femto. Edit \`/etc/samba/smb.conf\` to add other shares.\n\nTroubleshooting: if Windows refuses to connect after succeeding previously, hit [win]+R and enter \`net use * /delete\`."
init_instructions="To enable file sharing, run \`Initialize\` in the femto-config Samba menu to set a Samba password."
name="Samba File Sharing" # software name
author="Software Freedom Conservancy" # software author - OPTIONAL
description="Femtofox comes with Samba preinstalled but disabled. $init_instructions\n\n$user_message" # software description - OPTIONAL (but strongly recommended!)
URL="https://www.samba.org/" # software URL. Can contain multiple URLs - OPTIONAL
options="xiuagedsrNADUOSEPCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiuagedsrNADUOSEGPCI" # 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="smbd nmbd" # 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`
license="/usr/share/doc/samba/copyright" # file to cat to display license
package_name="samba" # apt package name, if applicable
conflicts="" # 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"
@ -97,7 +99,7 @@ interactive_init() {
exit 0
}
#upgrade script
# upgrade script
upgrade() {
echo "apt update can take a long while..."
DEBIAN_FRONTEND=noninteractive apt-get update -y 2>&1 | tee /dev/tty | grep -q "Err" && { echo "user_message: apt update failed. Is internet connected?"; exit 1; }
@ -114,6 +116,11 @@ else
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -161,7 +168,12 @@ while getopts ":h$options" opt; do
E) # Option -E (Get service name)
echo $service_name
;;
L) echo -e $location ;;
L) # Option -L (location)
echo -e $location
;;
G) # Option -G (Get license)
license
;;
P) echo -e $package_name ;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)

View file

@ -15,10 +15,11 @@ help=$(cat <<EOF
Arguments:
-h This message
Environment - must be first argument:
-x User UI is not terminal (script interactive unavailable)
-x User UI is not terminal (script interaction unavailable)
Actions:
-i Install
-u Uninstall
-a Interactive initialization script: code that must be run to initialize the installation prior to use, but can only be run from terminal
-g Upgrade
-e Enable service, if applicable
-d Disable service, if applicable
@ -32,8 +33,10 @@ Arguments:
-U Get URL
-O Get options supported by this script
-S Get service status
-E Get service nam
-L Get Install location
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
EOF
@ -54,10 +57,11 @@ name="TC²-BBS" # software name
author="The Comms Channel" # software author - OPTIONAL
description="The TC²-BBS system integrates with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory." # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/TheCommsChannel/TC2-BBS-mesh" # software URL. Can contain multiple URLs - OPTIONAL
options="xiugedsrNADUOSELCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
options="xiugedsrNADUOSELGCI" # script options in use by software package. For example, for a package with no service, exclude `edsr`
launch="python /opt/TC2-BBS-mesh/server.py" # command to launch software, if applicable
service_name="mesh-bbs" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
location="/opt/TC2-BBS-mesh" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
conflicts="Meshing Around, other \"full control\" packages" # 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"
# install script
@ -122,6 +126,11 @@ check() {
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
while getopts ":h$options" opt; do
case ${opt} in
h) # Option -h (help)
@ -167,6 +176,9 @@ while getopts ":h$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)
check

View file

@ -35,6 +35,7 @@ Arguments:
-S Get service status
-E Get service name
-L Get install location
-G Get license
-P Get package name
-C Get Conflicts
-I Check if installed. Returns an error if not installed
@ -57,11 +58,12 @@ name="ttyd Web Terminal" # software name
author="Shuanglei Tao" # software author - OPTIONAL
description="ttyd is a simple command-line tool for sharing terminal over the web.\n\nWhen running, ttyd is available at https://$(hostname).local:7681\nttyd is installed and enabled by default on Foxbuntu.\n\nSSL encryption is provided by keys generated during first-boot or during installation. Your browser may give a warning (net::ERR_CERT_AUTHORITY_INVALID) about the self-signed encryption certificate. This is normal. In Chromium (Chrome, Edge) click \"Advanced\" and \"Continue to femtofox.local (unsafe)\"" # software description - OPTIONAL (but strongly recommended!)
URL="https://github.com/tsl0922/ttyd" # software URL. Can contain multiple URLs - OPTIONAL
options="hxiugedsrNADUOSELCIk" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
options="hxiugedsrNADUOSELGCIk" # script options in use by software package. For example, for a package with no service, exclude `edsrS`
launch="" # command to launch software, if applicable
service_name="ttyd" # the name of the service/s, such as `chrony`. REQUIRED if service options are in use. If multiple services, separate by spaces "service1 service2"
package_name="" # apt package name, if applicable. Can be multiple packages separated by spaces, but if at least one is installed the package will show as "installed" even if the others aren't
location="/opt/ttyd" # install location REQUIRED if not apt installed. Generally, we use `/opt/software-name`
license="$location/LICENSE" # file to cat to display license
conflicts="" # 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"
# install script
@ -120,6 +122,11 @@ check() {
fi
}
# display license
license() {
echo -e "Contents of $license:\n $([[ -f "$license" ]] && awk -v max=2000 -v file="$license" '{ len += length($0) + 1; if (len <= max) print; else if (!cut) { cut=1; printf "%s...\n\nFile truncated, see %s for complete license.", substr($0, 1, max - len + length($0)), file; exit } }' "$license")"
}
# custom for this package
generate_keys() {
openssl req -new -newkey rsa:4096 -days 3650 -nodes -x509 -keyout /etc/ssl/private/ttyd.key -out /etc/ssl/certs/ttyd.crt -subj "/CN=$(hostname)" -addext "subjectAltName=DNS:$(hostname)"
@ -179,6 +186,9 @@ while getopts ":$options" opt; do
echo $service_name
;;
L) echo -e $location ;;
G) # Option -G (Get license)
license
;;
P) echo -e $package_name ;;
C) echo -e $conflicts ;;
I) # Option -I (Check if already installed)