Skip to content

Commit

Permalink
moved .env handling to file and applied to boot-drm too
Browse files Browse the repository at this point in the history
  • Loading branch information
mktcode committed Jan 13, 2023
1 parent 76a30de commit a21e254
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
15 changes: 3 additions & 12 deletions boot-drm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
. ./colors.sh
chmod u+x asciiart.sh
./asciiart.sh
chmod u+x env.sh
. ./env.sh

declare -a repos=(
"OpenQ-CoinAPI"
Expand Down Expand Up @@ -30,20 +32,9 @@ for repo in "${repos[@]}"
do
echo -e "\n${BBlue}$repo${Color_Off}"
clone "$repo"
generate_dot_env "$repo"
done

echo -e "${Red}NOTE:${Color_Off} ${Blue}You will need .env files in the root of the following repositories: ${Color_Off}"
echo -e ${Cyan}"- OpenQ-DRM-Frontend"${Color_Off}
echo -e ${Cyan}"- OpenQ-Oracle"${Color_Off}
echo -e ${Cyan}"- OpenQ-Contracts"${Color_Off}
echo -e ${Cyan}"- OpenQ-Github-OAuth-Server"${Color_Off}
echo -e ${Cyan}"- OpenQ-OZ-Claim-Autotask"${Color_Off}
echo -e ${Cyan}"- OpenQ-CoinAPI"${Color_Off}
echo -e ${Cyan}"- OpenQ-Event-Lsitener"${Color_Off}
echo -e ${Cyan}"- OpenQ-Bounty-Actions-Autotask\n"${Color_Off}

echo -e ${Blue}"No worries! See the README for instructions\n"${Color_Off}

# Save a local file of the openq launched containers for later deletion and removal

echo -e ${Cyan}"Starting all OpenQ containers from scratch..."${Color_Off}
Expand Down
15 changes: 3 additions & 12 deletions boot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
. ./colors.sh
chmod u+x asciiart.sh
./asciiart.sh

if [[ -z "$PAT" ]]; then
echo -e "${Yellow}You need to set your GitHub PAT as an environment variable and run boot.sh again:${Color_Off}\n"
echo -e "export PAT=..."
exit 1
fi
chmod u+x env.sh
. ./env.sh

declare -a repos=(
"OpenQ-CoinAPI"
Expand Down Expand Up @@ -37,12 +33,7 @@ declare -a repos=(
for repo in "${repos[@]}"; do
echo -e "\n${BBlue}$repo${Color_Off}"
clone "$repo"

if [ -f "./$repo/.env.sample" ]; then
cp "./$repo/.env.sample" "./$repo/.env"
sed -i 's/PAT=.*/PAT='"$PAT"'/' "./$repo/.env"
sed -i 's/PATS=.*/PATS='"$PAT"'/' "./$repo/.env"
fi
generate_dot_env "$repo"
done

# Save a local file of the openq launched containers for later deletion and removal
Expand Down
6 changes: 3 additions & 3 deletions clone.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
clone() {
if [ -d "./$1" ]; then
echo -e "${Blue}$1 directory found${Color_Off}\n"
echo -e "${Blue}$1 directory found${Color_Off}"
else
if [ -n "$OPENQ_FORKS" ]; then
IFS=',' read -r -a forks <<< "$OPENQ_FORKS"
for fork in "${forks[@]}"; do
repo_name=$(echo "$fork" | awk -F '/' '{print $2}')
if [ "$repo_name" = "$1" ]; then
username=$(echo "$fork" | awk -F '/' '{print $1}')
echo -e "${UCyan}No $1 directory found. Cloning $1 from $username...${Color_Off}\n"
echo -e "${UCyan}No $1 directory found. Cloning $1 from $username...${Color_Off}"
git clone "https://github.com/$username/$1.git"
return
fi
done
fi
echo -e "${UCyan}No $1 directory found. Cloning $1 from OpenQDev...${Color_Off}\n"
echo -e "${UCyan}No $1 directory found. Cloning $1 from OpenQDev...${Color_Off}"
git clone https://github.com/OpenQDev/$1.git
fi
}
18 changes: 18 additions & 0 deletions env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
if [[ -z "$PAT" ]]; then
echo -e "${Yellow}You need to set your GitHub PAT as an environment variable and run boot.sh again:${Color_Off}\n"
echo -e "export PAT=..."
exit 1
fi

generate_dot_env() {
if [ -f "./$1/.env.sample" ]; then
if [ ! -f "./$1/.env" ]; then
echo -e "${UCyan}Generating $1/.env${Color_Off}\n"
cp "./$1/.env.sample" "./$1/.env"
sed -i 's/PAT=.*/PAT='"$PAT"'/' "./$1/.env"
sed -i 's/PATS=.*/PATS='"$PAT"'/' "./$1/.env"
else
echo -e "${Blue}$1/.env already exists${Color_Off}\n"
fi
fi
}

0 comments on commit a21e254

Please sign in to comment.