Skip to content

Commit

Permalink
build: fix install script find .env for non-root usr
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed Nov 5, 2023
1 parent d6801cb commit 824d7ee
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/frontend/public/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,8 @@ check_if_test() {
get_repo() {
heading_echo "Getting Necessary Files"

current_dir="${PWD}"

if ! command -v git &>/dev/null; then
yellow_echo "Downloading GIT."
echo
Expand All @@ -459,22 +461,22 @@ get_repo() {

echo "Cloning repo $repo_url to dir: /tmp/${RANDOM_DIR}"
echo
git clone --branch "${BRANCH_NAME}" --depth 1 "$repo_url"
git clone --branch "build/nginx-certbot" --depth 1 "$repo_url"

# Check for existing .env files
existing_dotenv=""
if [ ${RUN_AS_ROOT} == true ] && sudo test -f "/root/fmtm/${DOTENV_NAME}"; then
if [ "${RUN_AS_ROOT}" == true ] && sudo test -f "/root/fmtm/${DOTENV_NAME}"; then
existing_dotenv="/root/fmtm/${DOTENV_NAME}"
elif [ -f "${PWD}/${DOTENV_NAME}" ]; then
existing_dotenv="${PWD}/${DOTENV_NAME}"
elif [ -f "${current_dir}/${DOTENV_NAME}" ]; then
existing_dotenv="${current_dir}/${DOTENV_NAME}"
fi

if [ -n "$existing_dotenv" ]; then
echo
echo "Found existing dotenv file."
echo
echo "Copying $existing_dotenv --> /tmp/${RANDOM_DIR}/fmtm/${DOTENV_NAME}"
if [ ${RUN_AS_ROOT} == true ]; then
if [ "${RUN_AS_ROOT}" == true ]; then
sudo cp "$existing_dotenv" "/tmp/${RANDOM_DIR}/fmtm/"
else
cp "$existing_dotenv" "/tmp/${RANDOM_DIR}/fmtm/"
Expand Down

0 comments on commit 824d7ee

Please sign in to comment.