Skip to content

Commit

Permalink
build: Improve error handling in env.sh #653 (#672)
Browse files Browse the repository at this point in the history
Signed-off-by: FestHesten <[email protected]>
Signed-off-by: Chris Lo <[email protected]>
Co-authored-by: Chris Lo <[email protected]>
  • Loading branch information
FestHesten and topher-lo authored Dec 27, 2024
1 parent 8f3a127 commit 18c1b92
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ dotenv_replace() {

echo -e "${YELLOW}Creating .env...${NC}"

# Check that docker and ngrok exist
if ! command -v docker &> /dev/null
# Check that docker exists and is running
if ! docker ps &> /dev/null
then
echo -e "${RED}Docker could not be found. Please install Docker and try again.${NC}"
echo -e "${RED}Docker could not be found. Please check if installed and running.${NC}"
exit
fi



# If .env exists, ask user if they want to overwrite it
if [ -f .env ]; then
read -p "A .env file already exists. Do you want to overwrite it? (y/n) " -n 1 -r
Expand All @@ -54,9 +55,21 @@ if [ -f .env ]; then
fi

# Create .env file

if [ ! -e ".env.example" ] ; then
echo "${RED}No .env.example file found in current directory: $(pwd). Please download .env.example from the Tracecat GitHub repo and rerun the env.sh script."
exit 1
fi
env_file=".env"

if ! openssl &> /dev/null
then
echo -e "${RED}Could not run openssl. Please check if openssl is correctly installed."
exit 1
fi

echo -e "${YELLOW}Generating new service key and signing secret...${NC}"

service_key=$(openssl rand -hex 32)
signing_secret=$(openssl rand -hex 32)

Expand Down

0 comments on commit 18c1b92

Please sign in to comment.