Modification --host-ssl-enable id , chekc for empty argument

This commit is contained in:
Erreur32 2024-09-28 15:36:21 +02:00
parent f6f622cf5a
commit 2799d2e3c9

View File

@ -4,7 +4,7 @@
# Github [ https://github.com/Erreur32/nginx-proxy-manager-Bash-API ]
# Erreur32 July 2024
VERSION="2.5.0"
VERSION="2.5.1"
#
# This script allows you to manage Nginx Proxy Manager via the API. It provides
@ -89,7 +89,6 @@ API_PASS="pass nginx"
# Path to store .txt files and Backups
BASE_DIR="/path/nginx_proxy_script/data"
#################################
# Variables to Edit (optional) #
#################################
@ -478,6 +477,12 @@ while getopts "d:i:p:f:c:b:w:a:l:-:" opt; do
host-ssl-enable)
ENABLE_SSL=true
HOST_ID="${!OPTIND}"; shift
# Check if HOST_ID is provided
if [ -z "$HOST_ID" ]; then
echo -e " \n⛔ ${COLOR_RED}Error: Missing host ID for --host-ssl-enable.${COLOR_RESET}"
echo -e " To find ID Check with ${COLOR_ORANGE}$0 --host-list${COLOR_RESET}\n"
exit 1
fi
;;
host-ssl-disable)
DISABLE_SSL=true
@ -1393,9 +1398,12 @@ enable_ssl_old() {
enable_ssl() {
if [ -z "$HOST_ID" ]; then
echo -e "\n 🛡️ The --host-ssl-enable option requires a host ID."
usage
echo -e " --host-ssl-enable id 🔒 ${COLOR_GREEN}Enable${COLOR_RESET} SSL, HTTP/2, and HSTS for a proxy host (Enabled only if exist, check ${COLOR_ORANGE}--generate-cert${COLOR_RESET} to create one)"
#usage # Call usage function to show correct usage
exit 1 # Exit if no HOST_ID is provided
fi
# Validate that HOST_ID is a number
if ! [[ "$HOST_ID" =~ ^[0-9]+$ ]]; then
echo -e "${COLOR_RED}Invalid host ID: $HOST_ID. It must be a numeric value.${COLOR_RESET}\n"