Skip to content

Commit 92bd749

Browse files
committed
Fix --host-create long command
1 parent d058de2 commit 92bd749

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

npm-api.sh

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2507,10 +2507,9 @@ cert_generate() {
25072507
echo -e "\n ⛔ ${COLOR_RED}ERROR: Certificate not found after generation${CoR}"
25082508
exit 1
25092509
fi
2510-
2511-
host_ssl_enable
2510+
25122511
fi
2513-
return 0
2512+
#return 0
25142513
else
25152514
echo -e "\n ❌ ${COLOR_RED}Certificate generation failed!${CoR}"
25162515
ERROR_MSG=$(echo "$HTTP_BODY" | jq -r '.error.message // "Unknown error"')
@@ -2613,6 +2612,7 @@ host_ssl_enable() {
26132612
if [ "$HTTP_STATUS" -eq 200 ]; then
26142613
echo -e "\n ✅ ${COLOR_GREEN}SSL enabled successfully for${CoR} ${COLOR_YELLOW}$HOST_DOMAIN${CoR} (ID: ${COLOR_CYAN}$HOST_ID${CoR}) (Cert ID: ${COLOR_CYAN}$CERT_ID${CoR})\n"
26152614
return 0
2615+
#exit 0
26162616
else
26172617
echo -e "\n ⛔ ${COLOR_RED}Failed to enable SSL. HTTP status: $HTTP_STATUS${CoR}\n"
26182618
echo -e " 📋 Error details: $HTTP_BODY \n"
@@ -3788,16 +3788,19 @@ while [[ "$#" -gt 0 ]]; do
37883788
--cert-generate)
37893789
CERT_GENERATE=true
37903790
shift
3791-
if [ -n "$1" ] && [[ "$1" != --* ]]; then
3791+
if [ $# -gt 0 ] && [[ "$1" != --* ]]; then
37923792
CERT_DOMAIN="$1"
37933793
shift
3794+
else
3795+
# Si pas d'argument spécifique pour --cert-generate, utiliser le domaine du host
3796+
CERT_DOMAIN="$DOMAIN_NAMES"
37943797
fi
37953798
;;
37963799
--cert-email) shift; CERT_EMAIL="$1"; shift ;;
37973800
--dns-provider) shift; CERT_DNS_PROVIDER="$1"; shift ;;
37983801
--dns-credentials) shift; CERT_DNS_CREDENTIALS="$1"; shift ;;
3799-
--host-ssl-enable) HOST_SSL_ENABLE=true ;;
3800-
-y) AUTO_YES=true ;;
3802+
--host-ssl-enable) HOST_SSL_ENABLE=true; shift ;;
3803+
-y) AUTO_YES=true; shift ;;
38013804
esac
38023805
;;
38033806
*)
@@ -4116,21 +4119,29 @@ elif [ "$HOST_CREATE" = true ]; then
41164119
if [ "$CERT_GENERATE" = true ]; then
41174120
cert_generate "$DOMAIN_NAMES" "$CERT_EMAIL" "$CERT_DNS_PROVIDER" "$CERT_DNS_CREDENTIALS"
41184121
if [ "$HOST_SSL_ENABLE" = true ]; then
4119-
host_ssl_enable "$HOST_ID"
4122+
echo "DEBUG: HOST_ID=$HOST_ID"
4123+
echo "DEBUG: GENERATED_CERT_ID=$GENERATED_CERT_ID"
4124+
host_ssl_enable "$HOST_ID" "$GENERATED_CERT_ID"
41204125
fi
41214126
fi
4122-
exit 0
4123-
4127+
exit 0
41244128

41254129
# Actions SSL
4126-
elif [ "$CERT_GENERATE" = true ]; then
4130+
elif [ "$CERT_GENERATE" = true ] && [ "$HOST_CREATE" != true ]; then # ✅ Ajout de la condition
41274131
cert_generate "$CERT_DOMAIN" "$CERT_EMAIL" "$CERT_DNS_PROVIDER" "$CERT_DNS_CREDENTIALS"
4128-
# If --host-ssl-enable
41294132
if [ "$HOST_SSL_ENABLE" = true ]; then
41304133
host_ssl_enable "$HOST_ID"
41314134
exit 0
41324135
fi
41334136

4137+
#elif [ "$CERT_GENERATE" = true ]; then
4138+
# cert_generate "$CERT_DOMAIN" "$CERT_EMAIL" "$CERT_DNS_PROVIDER" "$CERT_DNS_CREDENTIALS"
4139+
# If --host-ssl-enable
4140+
# if [ "$HOST_SSL_ENABLE" = true ]; then
4141+
# host_ssl_enable "$HOST_ID"
4142+
# exit 0
4143+
# fi
4144+
41344145

41354146
elif [ "$HOST_DELETE" = true ]; then
41364147
host_delete "$HOST_ID"

0 commit comments

Comments
 (0)