mirror of
https://github.com/freedbygrace/SQL.git
synced 2026-07-26 19:38:16 +00:00
Add automatic dependency installer and package checks
DEPENDENCY MANAGEMENT: - Created scripts/install-dependencies.sh - automatic installer for all required packages - Detects OS (Ubuntu, Debian, CentOS, RHEL, Fedora, Arch, macOS) - Installs PostgreSQL client (psql) automatically - Installs Docker & Docker Compose if missing - Installs utility packages (curl, wget, git) SCRIPT ENHANCEMENTS: - Updated setup-database.sh with dependency checking - Updated generate_data.sh with dependency checking - Updated verify-setup.sh with dependency checking - All scripts now prompt to run installer if dependencies are missing - Interactive prompts guide users through installation DOCUMENTATION: - Updated README.md with dependency installation instructions - Updated QUICKSTART.md with Step 0: Install Dependencies - Added supported OS list - Added automatic dependency check notes USER EXPERIENCE: - No more manual package installation required - Scripts fail gracefully with helpful error messages - One-command installation: ./scripts/install-dependencies.sh - Automatic detection and installation on Linux/macOS - Clear instructions for Windows users This ensures users can get started immediately without hunting for package installation commands.
This commit is contained in:
@@ -36,6 +36,61 @@ echo -e "User: ${GREEN}$DB_USER${NC}"
|
||||
echo -e "${BLUE}============================================================================${NC}"
|
||||
echo ""
|
||||
|
||||
# Check for required dependencies
|
||||
check_dependencies() {
|
||||
local missing_deps=()
|
||||
|
||||
# Check for psql
|
||||
if ! command -v psql >/dev/null 2>&1; then
|
||||
missing_deps+=("psql (PostgreSQL client)")
|
||||
fi
|
||||
|
||||
# Check for docker
|
||||
if ! command -v docker >/dev/null 2>&1; then
|
||||
missing_deps+=("docker")
|
||||
fi
|
||||
|
||||
# Check for docker-compose or docker compose
|
||||
if ! command -v docker-compose >/dev/null 2>&1 && ! docker compose version >/dev/null 2>&1; then
|
||||
missing_deps+=("docker-compose")
|
||||
fi
|
||||
|
||||
if [ ${#missing_deps[@]} -gt 0 ]; then
|
||||
echo -e "${RED}✗ Missing required dependencies:${NC}"
|
||||
for dep in "${missing_deps[@]}"; do
|
||||
echo -e " - ${YELLOW}$dep${NC}"
|
||||
done
|
||||
echo ""
|
||||
echo -e "${YELLOW}Would you like to run the dependency installer? (y/n)${NC}"
|
||||
read -r response
|
||||
if [[ "$response" =~ ^[Yy]$ ]]; then
|
||||
if [ -f "$SCRIPT_DIR/install-dependencies.sh" ]; then
|
||||
chmod +x "$SCRIPT_DIR/install-dependencies.sh"
|
||||
"$SCRIPT_DIR/install-dependencies.sh"
|
||||
echo ""
|
||||
echo -e "${GREEN}Dependencies installed. Please re-run this script.${NC}"
|
||||
exit 0
|
||||
else
|
||||
echo -e "${RED}✗ install-dependencies.sh not found${NC}"
|
||||
echo -e "${YELLOW}Please install the following manually:${NC}"
|
||||
for dep in "${missing_deps[@]}"; do
|
||||
echo -e " - $dep"
|
||||
done
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
echo -e "${RED}✗ Cannot proceed without required dependencies${NC}"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}✓ All required dependencies are installed${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Run dependency check
|
||||
check_dependencies
|
||||
|
||||
# Function to execute SQL command
|
||||
execute_sql() {
|
||||
PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -p $DB_PORT -U $DB_USER -d $DB_NAME -c "$1" 2>&1
|
||||
|
||||
Reference in New Issue
Block a user