4
0
Эх сурвалжийг харах

install-step-ra.sh: Properly quote the RA DNS names in ca.json

Carl Tashian 5 жил өмнө
parent
commit
655d7f59fd

+ 22 - 1
scripts/install-step-ra.sh

@@ -154,6 +154,27 @@ if [ -z "$RA_DNS_NAMES" ]; then
   done
   done
 fi
 fi
 
 
+
+count=0
+ra_dns_names_quoted=""
+
+for i in ${RA_DNS_NAMES//,/ }
+do
+  if [ "$count" = "0" ]; then
+    ra_dns_names_quoted="\"$i\""
+  else 
+    ra_dns_names_quoted="${ra_dns_names_quoted}, \"$i\""
+  fi
+  count=$((count+1))
+done
+
+if [ "$count" = "0" ]; then
+  echo "You must supply at least one RA DNS name"
+  exit 1
+fi
+
+echo "Got here"
+
 if [ -z "$RA_ADDRESS" ]; then
 if [ -z "$RA_ADDRESS" ]; then
   RA_ADDRESS=""
   RA_ADDRESS=""
   while [[ $RA_ADDRESS = "" ]] ; do
   while [[ $RA_ADDRESS = "" ]] ; do
@@ -189,7 +210,7 @@ mkdir -p $(step path)/config
 cat <<EOF > $(step path)/config/ca.json
 cat <<EOF > $(step path)/config/ca.json
 {
 {
   "address": "$RA_ADDRESS",
   "address": "$RA_ADDRESS",
-  "dnsNames": ["$RA_DNS_NAMES"],
+  "dnsNames": [$ra_dns_names_quoted],
   "db": {
   "db": {
     "type": "badgerV2",
     "type": "badgerV2",
     "dataSource": "/etc/step-ca/db"
     "dataSource": "/etc/step-ca/db"