I have a while loop in a for loop to create user accounts in drupal using drush and it's not iterating through the sequence properly. It creates the accounts or all the domains fine, but the while loop does not create the user roles after the first account. Anyone see my mistake?
#add the user
USERLIST=(
"$USER,page_creator"
#"$USER,layout_manager"
"$USER,page_reviewer"
"$USER,landing_page_creator"
"$USER,landing_page_reviewer"
"$USER,media_manager"
"$USER,block_creator"
#"$USER,site_builder"
"$USER,block_manager"
)
count=0
DOMAINLIST=("lmn" "pdq" "xyz")
for SITE in "${DOMAINLIST[@]}"
do
echo "Creating account for $USER"
drush "@company-acsf."$SITE ucrt $USER --password="$PW" --mail="$USER"
while [ "x${USERLIST[count]}" != "x" ]
do
count=$(( $count + 1 ))
IFS=',' read -ra LINE <<< "${USERLIST[count]}"
USERNAME=${LINE[0]}
USERROLE=${LINE[1]}
USERLIST=(
"$USER,page_creator"
#"$USER,layout_manager"
"$USER,page_reviewer"
"$USER,landing_page_creator"
"$USER,landing_page_reviewer"
"$USER,media_manager"
"$USER,block_creator"
#"$USER,site_builder"
"$USER,block_manager"
)
count=0
DOMAINLIST=("lmn" "pdq" "xyz")
for SITE in "${DOMAINLIST[@]}"
do
echo "Creating account for $USER"
drush "@company-acsf."$SITE ucrt $USER --password="$PW" --mail="$USER"
while [ "x${USERLIST[count]}" != "x" ]
do
count=$(( $count + 1 ))
IFS=',' read -ra LINE <<< "${USERLIST[count]}"
USERNAME=${LINE[0]}
USERROLE=${LINE[1]}
if [[ -n "$USERNAME" && -n "$USERROLE" ]] ; then
echo "Updating account for $USERNAME with role \"$USERROLE\""
drush "@newell-acsf."$SITE urol "${USERROLE}" $USERNAME
fi
done
done
exit 0
done
exit 0