Anyone who can help me fix the following ssh command to run it remotely instead of locally? It already works partly.
What I'm trying to achieve is to read all variables set in a .env file and see if a variable exists.
RELEASE_PATH=path/to/file
ssh "${USER}@${HOST}" bash -c "'
export $(grep -E -v '^#' "${RELEASE_PATH}/.env" | xargs)
if [ -z ${PROJECT_NAME+x} ]; then
echo -e \"\nPROJECT_NAME=${CONTAINER_NAME}\" >> ${RELEASE_PATH}/.env
else
sed -i 's/PROJECT_NAME=.*/PROJECT_NAME=${CONTAINER_NAME}/g' ${RELEASE_PATH}/.env
fi
'"
The error I'm getting at the moment is "grep: /path/to/file/.env: No such file or directory"