#!/bin/bash # Environment Check Script for Production Server # Run this to verify server requirements echo "🔍 Checking Production Environment..." # Colors RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' NC='\033[0m' # Check PHP version echo -e "\n${YELLOW}📋 PHP Version:${NC}" php_version=$(php -v | head -n 1) echo "$php_version" # Check PHP extensions echo -e "\n${YELLOW}📦 Required PHP Extensions:${NC}" extensions=("curl" "json" "mbstring" "openssl" "pdo" "tokenizer" "xml" "zip") for ext in "${extensions[@]}"; do if php -m | grep -q "$ext"; then echo -e "${GREEN}✅ $ext${NC}" else echo -e "${RED}❌ $ext (missing)${NC}" fi done # Check Composer echo -e "\n${YELLOW}🎵 Composer:${NC}" if command -v composer &> /dev/null; then composer_version=$(composer --version) echo -e "${GREEN}✅ $composer_version${NC}" else echo -e "${RED}❌ Composer not found${NC}" fi # Check cron service echo -e "\n${YELLOW}⏰ Cron Service:${NC}" if systemctl is-active --quiet cron; then echo -e "${GREEN}✅ Cron service is running${NC}" else echo -e "${RED}❌ Cron service is not running${NC}" fi # Check disk space echo -e "\n${YELLOW}💾 Disk Space:${NC}" df -h | head -n 1 df -h | grep -E '^/dev/' # Check memory echo -e "\n${YELLOW}🧠 Memory:${NC}" free -h # Check network connectivity to API echo -e "\n${YELLOW}🌐 API Connectivity:${NC}" if curl -s --connect-timeout 5 https://wsdev.jakarta.go.id > /dev/null; then echo -e "${GREEN}✅ Can reach Jakarta API${NC}" else echo -e "${RED}❌ Cannot reach Jakarta API${NC}" fi # Check write permissions echo -e "\n${YELLOW}🔐 Directory Permissions:${NC}" dirs=("storage" "storage/logs" "bootstrap/cache") for dir in "${dirs[@]}"; do if [ -w "$dir" ]; then echo -e "${GREEN}✅ $dir is writable${NC}" else echo -e "${RED}❌ $dir is not writable${NC}" fi done echo -e "\n${GREEN}🏁 Environment check completed!${NC}"