Skip to content

Instantly share code, notes, and snippets.

@philpicton
Last active January 7, 2026 12:36
Show Gist options
  • Select an option

  • Save philpicton/42b59508af9646955ade22d28da1325d to your computer and use it in GitHub Desktop.

Select an option

Save philpicton/42b59508af9646955ade22d28da1325d to your computer and use it in GitHub Desktop.
dev env setup script
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
ORANGE='\033[0;33m'
NC='\033[0m'
LOGO=$(
cat <<'EOF'
↑↑↑↑↑↑
↑↑↑↑↑↑
↑↑↑↑↑↑
↑↑↑↑↑↑
↑↑↑↑↑↑
↑↑↑↑↑↑
↑↑↑↑↑↑↑↑
↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑
↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
↑↑↑↑↑↑↑ ↑↑↑↑↑↑ ↑↑↑↑↑↑
EOF
)
echo -e "${ORANGE}${LOGO}${NC}"
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo " Haysto V2 Dev env setup script "
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo ""
echo "MacOS only. Uses GitHub CLI & you need to be logged in"
echo ""
echo "Needs node v22+ for shared lib installation."
echo ""
echo "Will clone the repos in the current folder."
echo ""
echo "Checking..."
echo ""
if [[ "$OSTYPE" != "darwin"* ]]; then
echo -e "${RED}✗ Sorry! macOS only.${NC}"
exit 1
fi
if ! command -v gh &>/dev/null; then
echo -e "${RED}✗ GitHub CLI (gh) is not installed.${NC}"
echo ""
echo "To install GitHub CLI, run:"
echo " brew install gh"
echo ""
exit 1
else
echo -e "${GREEN}✓ GitHub CLI (gh) is installed.${NC}"
GH_VERSION=$(gh --version | head -n 1)
echo " $GH_VERSION"
fi
echo ""
if ! gh auth status &>/dev/null; then
echo -e "${RED}✗ You are not authenticated with GitHub.${NC}"
echo ""
echo "To authenticate, run:"
echo " gh auth login"
echo ""
exit 1
else
echo -e "${GREEN}✓ You are authenticated with GitHub.${NC}"
gh auth status 2>&1 | grep -E "Logged in|account" | sed 's/^/ /'
fi
echo ""
echo -e "${GREEN}✓ All checks passed!${NC}"
echo ""
read -p "Would you like to check out the repos to this folder? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Lets goooo..."
gh repo clone Haysto/haysto-v2 &&
cd haysto-v2 &&
gh repo clone Haysto/haysto-v2-lib_shared lib/js/haysto-v2-lib_shared &&
gh repo clone Haysto/haysto-v2-api &&
gh repo clone Haysto/haysto-v2-dev &&
gh repo clone Haysto/haysto-v2-collect &&
gh repo clone Haysto/haysto-v2-create &&
gh repo clone Haysto/haysto-v2-collaborate
echo ""
echo -e "${GREEN}✓ Checkout complete!${NC}"
else
echo "Skipping initialization. Attempting to CD into haysto-v2 directory..."
if [ -d "haysto-v2" ]; then
cd haysto-v2 || {
echo -e "${RED}✗ Failed to change directory to haysto-v2.${NC}"
exit 1
}
echo -e "${GREEN}✓ Changed directory to haysto-v2.${NC}"
else
echo -e "${RED}✗ haysto-v2 directory does not exist. Please clone the repository first.${NC}"
exit 1
fi
fi
echo ""
read -p "Would you like to add entries to your hosts (needs sudo)? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Adding entries to /etc/hosts..."
HOSTS_ENTRIES=$(
cat <<EOF
# Haysto Local Development
127.0.0.1 haysto-v2.test
127.0.0.1 api.haysto-v2.test auth.haysto-v2.test
127.0.0.1 dashboard.haysto-v2.test app.haysto-v2.test
127.0.0.1 partner.haysto-v2.test
127.0.0.1 admin.haysto-v2.test
127.0.0.1 dev.haysto-v2.test
127.0.0.1 reporting.haysto-v2.test
127.0.0.1 mock.haysto-v2.test
127.0.0.1 mail.haysto-v2.test
127.0.0.1 logs.haysto-v2.test
EOF
)
echo "$HOSTS_ENTRIES" | sudo tee -a /etc/hosts >/dev/null
echo -e "${GREEN}✓ Entries added to /etc/hosts successfully!${NC}"
else
echo "Skipping hosts file modification."
fi
echo ""
read -p "Copy .env.example to .env in all directories? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Copying .env.example to .env in haysto-v2 directory..."
cp .env.example .env
echo -e "${GREEN}Copied .env.example to .env in haysto-v2 directory.${NC}"
echo ""
cd haysto-v2-api
if [ -f ".env.example" ]; then
cp .env.example .env
echo -e "${GREEN}✓ Copied .env.example to .env in haysto-v2-api directory.${NC}"
else
echo -e "${YELLOW}Warning: .env.example not found in haysto-v2-api directory.${NC}"
fi
cd ../
cd haysto-v2-dev
if [ -f ".env.example" ]; then
cp .env.example .env
echo -e "${GREEN}✓ Copied .env.example to .env in haysto-v2-dev directory.${NC}"
else
echo -e "${YELLOW}Warning: .env.example not found in haysto-v2-dev directory.${NC}"
fi
cd ../
cd haysto-v2-collect
if [ -f ".env.example" ]; then
cp .env.example .env
echo -e "${GREEN}✓ Copied .env.example to .env in haysto-v2-collect directory.${NC}"
else
echo -e "${YELLOW}Warning: .env.example not found in haysto-v2-collect directory.${NC}"
fi
cd ../
cd haysto-v2-create
if [ -f ".env.example" ]; then
cp .env.example .env
echo -e "${GREEN}✓ Copied .env.example to .env in haysto-v2-create directory.${NC}"
else
echo -e "${YELLOW}Warning: .env.example not found in haysto-v2-create directory.${NC}"
fi
cd ../
cd haysto-v2-collaborate
if [ -f ".env.example" ]; then
cp .env.example .env
echo -e "${GREEN}✓ Copied .env.example to .env in haysto-v2-collaborate directory.${NC}"
else
echo -e "${YELLOW}Warning: .env.example not found in haysto-v2-collaborate directory.${NC}"
fi
cd ../
else
echo "Skipping .env copy"
echo ""
fi
read -p "Would you like to install shared dependencies using npm install? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Checking Node.js version..."
if ! command -v node &>/dev/null; then
echo -e "${RED}✗ Node.js is not installed.${NC}"
echo ""
exit 1
fi
NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1)
if [ "$NODE_VERSION" -lt 22 ]; then
echo -e "${RED}✗ Node.js version 22 (or maybe higher) is required.${NC}"
echo " Current version: $(node -v)"
echo ""
exit 1
fi
echo -e "${GREEN}✓ Node.js version $(node -v) detected.${NC}"
echo ""
cd ./lib/js/haysto-v2-lib_shared
npm install
cd ../../../
echo -e "${GREEN}✓ npm install completed successfully!${NC}"
else
echo "Skipping npm install."
fi
read -p "Grafana permissions? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
sudo chmod -R 777 ./docker/logs ./docker/grafana/storage ./docker/grafana/loki-storage
echo -e "${GREEN}Grafana permissions set successfully!${NC}"
else
echo "Skipping Grafana permissions."
fi
read -p "Generate certificates for local development? (y/n): " -n 1 -r
echo ""
if [[ $REPLY =~ ^[Yy]$ ]]; then
echo ""
echo "Generating self-signed certificates..."
make generate-certs
echo -e "${GREEN}✓ Certificates generated successfully!${NC}"
else
echo "Skipping certificate generation."
fi
USER_NAME=$(git config user.name 2>/dev/null)
if [ -z "$USER_NAME" ]; then
USER_NAME=$(gh api user --jq '.name' 2>/dev/null)
fi
if [ -z "$USER_NAME" ]; then
USER_NAME=$(whoami)
fi
echo -e "${GREEN}✓ Setup complete!${NC}"
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
echo "TODO:"
echo ""
echo -e "${YELLOW}Fire up this beast with ${NC}cd haysto-v2 && make init${YELLOW}.${NC}"
echo ""
echo -e "${YELLOW}Run migrations and seeders with ${NC}make fresh${YELLOW}.${NC}"
echo ""
echo -e "${YELLOW}You may need to do${NC} docker compose exec -u root haysto-api chmod -R 777 storage ${YELLOW} to fix any permission issues.${NC}"
echo ""
echo -e "${YELLOW}Don't forget to add the certificates to your Keychain for HTTPS support!${NC}"
echo ""
echo -e "${GREEN}Have a great day, ${USER_NAME}!${NC}"
echo ""
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
exit 0
@philpicton
Copy link
Author

to use:

  1. Save locally as install.sh in the folder you want to install the repos to, eg ~/code
  2. chmod +x install.sh
  3. sh install.sh to run it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment