diff --git a/boot-drm.sh b/boot-drm.sh index 7928afc..77cad49 100755 --- a/boot-drm.sh +++ b/boot-drm.sh @@ -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" @@ -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} diff --git a/boot.sh b/boot.sh index 01932e2..90f02e7 100755 --- a/boot.sh +++ b/boot.sh @@ -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" @@ -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 diff --git a/clone.sh b/clone.sh index ee3f681..29696db 100644 --- a/clone.sh +++ b/clone.sh @@ -1,6 +1,6 @@ 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" @@ -8,13 +8,13 @@ clone() { 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 } diff --git a/env.sh b/env.sh new file mode 100755 index 0000000..eb4597e --- /dev/null +++ b/env.sh @@ -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 +} \ No newline at end of file