I'm not exactly sure how to word the title, but what I am trying to do is to set username to $DEV_ENVIRONMENT, $STAGE_ENVIRONMENT, or $PROD_ENVIRONMENT respectively, each of which is defined in my properties file.
My function would take in one argument (DEV, STAGE, or PROD) and check the hostname against the edges defined in $_ENVIRONMENT.
while IFS=',' read -ra line
do
for i in "${line[@]}"
do
if [ $(hostname) = $i ]
then
username="$1"_USERNAME
break
fi
done
done <<< "${1}_ENVIRONMENT"
So for instance, if I pass in DEV, then I would like username set to $DEV_USERNAME and I'd like the while loop to search through the nodes defined in $DEV_ENVIRONMENT, both of which would be values read in from my properties file.