Skip to content

Commit 2799d2e

Browse files
committed
Modification --host-ssl-enable id , chekc for empty argument
1 parent f6f622c commit 2799d2e

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

nginx_proxy_manager_cli.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Github [ https://github.com/Erreur32/nginx-proxy-manager-Bash-API ]
55
# Erreur32 July 2024
66

7-
VERSION="2.5.0"
7+
VERSION="2.5.1"
88

99
#
1010
# This script allows you to manage Nginx Proxy Manager via the API. It provides
@@ -89,7 +89,6 @@ API_PASS="pass nginx"
8989
# Path to store .txt files and Backups
9090
BASE_DIR="/path/nginx_proxy_script/data"
9191

92-
9392
#################################
9493
# Variables to Edit (optional) #
9594
#################################
@@ -233,7 +232,7 @@ usage() {
233232
echo -e " --generate-cert domain email 🌀 ${COLOR_GREEN}Generate${COLOR_RESET} Certificate for the given '${COLOR_YELLOW}domain${COLOR_RESET}' and '${COLOR_YELLOW}email${COLOR_RESET}'"
234233
echo -e " --delete-cert domain 💣 ${COLOR_ORANGE}Delete${COLOR_RESET} Certificate for the given '${COLOR_YELLOW}domain${COLOR_RESET}' "
235234

236-
echo -e " --examples 🔖 Examples commands, more explicits"
235+
echo -e " --examples 🔖 Examples commands, more explicits"
237236
echo -e " --help"
238237
echo ""
239238
exit 0
@@ -478,6 +477,12 @@ while getopts "d:i:p:f:c:b:w:a:l:-:" opt; do
478477
host-ssl-enable)
479478
ENABLE_SSL=true
480479
HOST_ID="${!OPTIND}"; shift
480+
# Check if HOST_ID is provided
481+
if [ -z "$HOST_ID" ]; then
482+
echo -e " \n⛔ ${COLOR_RED}Error: Missing host ID for --host-ssl-enable.${COLOR_RESET}"
483+
echo -e " To find ID Check with ${COLOR_ORANGE}$0 --host-list${COLOR_RESET}\n"
484+
exit 1
485+
fi
481486
;;
482487
host-ssl-disable)
483488
DISABLE_SSL=true
@@ -1393,9 +1398,12 @@ enable_ssl_old() {
13931398
enable_ssl() {
13941399
if [ -z "$HOST_ID" ]; then
13951400
echo -e "\n 🛡️ The --host-ssl-enable option requires a host ID."
1396-
usage
1401+
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)"
1402+
#usage # Call usage function to show correct usage
1403+
exit 1 # Exit if no HOST_ID is provided
13971404
fi
13981405

1406+
13991407
# Validate that HOST_ID is a number
14001408
if ! [[ "$HOST_ID" =~ ^[0-9]+$ ]]; then
14011409
echo -e "${COLOR_RED}Invalid host ID: $HOST_ID. It must be a numeric value.${COLOR_RESET}\n"

0 commit comments

Comments
 (0)