I'm tasked with updating my script with arrays so it will run multiple domains. Thing is, I'm not well versed in loop arrays. I have done some searching online and I'm not fully understanding how to add the arrays to what I already have here. That is what doesn't make sense to me. I understand (I think) how the array works but when I try to implement arrays I get mass errors. Any advice/tips would be helpful.
Currently this code works perfectly. But only with a single domain at at time.
Looking for advice on best options, even if Arrays aren't it.
#distribution.sh
#Gathers info and creates the .json file needed to create distribution information for AWS domain sites
#Gather web-id and assign it to the variable "webid"
echo "Insert the webid for the site you are working with:"
read webid
#Gather sub domain info (www) for the site in question and assign it to the variable "subdomain"
echo "Insert the sub domain name for the site you are working with:"
read subdomain
#Gather domain info (domain.com) for the site in question and assign it to the variable "domain"
echo "Insert the domain name for the site you are working with:"
read domain
#Check spelling with the user
printf "Your WebID is: $webid\nYour sub domain is: $subdomain\nYour domain
is: $domain\n"
read -p "Is this correct? y/n " -n 1 -r
echo #
if [[ ! $REPLY =~ ^[Yy]$ ]]
then
exit 1
else
printf "{\n \"web_ids\": [\n {\n \"web_id\": \"$webid\",\n
\"domains\": {\n \"$domain\": {\n \"vhosts\": [\n
\"$domain\",\n \"$subdomain.$domain\"\n ]\n }\n
}\n }\n ]\n}\n\n" > $domain.json
#Run create-distribution on our newly created .json file
create-distribution $domain.json
#Display the arn line from the .json file after the fact so we can copy it into case notes per process
cat $domain.json | grep dist
fi