#!/bin/bash # Sky Art Shop Deployment Verification Script # This script verifies that the website is running correctly echo "============================================" echo "Sky Art Shop - Deployment Verification" echo "============================================" echo "" # Colors for output GREEN='\033[0;32m' RED='\033[0;31m' YELLOW='\033[1;33m' NC='\033[0m' # No Color # Function to check service status check_service() { local service=$1 if systemctl is-active --quiet $service; then echo -e "${GREEN}✓${NC} $service is running" return 0 else echo -e "${RED}✗${NC} $service is NOT running" return 1 fi } # Function to check port check_port() { local port=$1 local service=$2 if ss -tlnp | grep -q ":$port "; then echo -e "${GREEN}✓${NC} Port $port is listening ($service)" return 0 else echo -e "${RED}✗${NC} Port $port is NOT listening ($service)" return 1 fi } # 1. Check Services echo "1. Checking Services Status..." echo "-----------------------------------" check_service mongod check_service nginx check_service skyartshop.service echo "" # 2. Check Ports echo "2. Checking Ports..." echo "-----------------------------------" check_port 27017 "MongoDB" check_port 80 "Nginx" check_port 5000 "SkyArtShop App" echo "" # 3. Check MongoDB Connection echo "3. Checking MongoDB Connection..." echo "-----------------------------------" if mongosh --eval "db.adminCommand('ping')" --quiet > /dev/null 2>&1; then echo -e "${GREEN}✓${NC} MongoDB is accessible" # Check SkyArtShopDB if mongosh --eval "use SkyArtShopDB; db.stats()" --quiet > /dev/null 2>&1; then echo -e "${GREEN}✓${NC} SkyArtShopDB database exists" # Count collections COLLECTIONS=$(mongosh SkyArtShopDB --eval "db.getCollectionNames().length" --quiet) echo -e "${GREEN}✓${NC} Found $COLLECTIONS collections in database" # Show collection counts echo "" echo " Collection Data:" mongosh SkyArtShopDB --eval " print(' - Products: ' + db.Products.countDocuments()); print(' - Pages: ' + db.Pages.countDocuments()); print(' - MenuItems: ' + db.MenuItems.countDocuments()); print(' - Users: ' + db.Users.countDocuments()); print(' - SiteSettings: ' + db.SiteSettings.countDocuments()); print(' - HomepageSections: ' + db.HomepageSections.countDocuments()); print(' - PortfolioCategories: ' + db.PortfolioCategories.countDocuments()); " --quiet 2>/dev/null else echo -e "${RED}✗${NC} SkyArtShopDB database not found" fi else echo -e "${RED}✗${NC} Cannot connect to MongoDB" fi echo "" # 4. Check Web Application echo "4. Checking Web Application..." echo "-----------------------------------" HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost) if [ "$HTTP_CODE" = "200" ]; then echo -e "${GREEN}✓${NC} Website is responding (HTTP $HTTP_CODE)" else echo -e "${RED}✗${NC} Website returned HTTP $HTTP_CODE" fi # Test admin login page ADMIN_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost/admin) if [ "$ADMIN_CODE" = "200" ] || [ "$ADMIN_CODE" = "302" ]; then echo -e "${GREEN}✓${NC} Admin panel is accessible" else echo -e "${YELLOW}!${NC} Admin panel returned HTTP $ADMIN_CODE" fi echo "" # 5. Check Network Configuration echo "5. Network Configuration..." echo "-----------------------------------" IP_ADDRESS=$(hostname -I | awk '{print $1}') echo -e "${GREEN}✓${NC} Server IP: $IP_ADDRESS" # Check nginx configuration NGINX_SERVER_NAME=$(grep -E "^\s*server_name" /etc/nginx/sites-enabled/skyartshop 2>/dev/null | awk '{print $2}' | tr -d ';') if [ -z "$NGINX_SERVER_NAME" ] || [ "$NGINX_SERVER_NAME" = "_" ]; then echo -e "${YELLOW}!${NC} Nginx is configured for ANY domain (server_name _)" echo " Access via: http://$IP_ADDRESS" else echo -e "${GREEN}✓${NC} Nginx configured for: $NGINX_SERVER_NAME" echo " Access via: http://$NGINX_SERVER_NAME" fi echo "" # 6. Check Application Files echo "6. Application Files..." echo "-----------------------------------" if [ -f "/var/www/SkyArtShop/publish/SkyArtShop.dll" ]; then echo -e "${GREEN}✓${NC} Application binary exists" else echo -e "${RED}✗${NC} Application binary NOT found" fi if [ -f "/var/www/SkyArtShop/appsettings.Production.json" ]; then echo -e "${GREEN}✓${NC} Production settings exist" else echo -e "${RED}✗${NC} Production settings NOT found" fi UPLOAD_DIR="/var/www/SkyArtShop/wwwroot/uploads" if [ -d "$UPLOAD_DIR" ]; then UPLOAD_COUNT=$(find $UPLOAD_DIR -type f 2>/dev/null | wc -l) echo -e "${GREEN}✓${NC} Uploads directory exists ($UPLOAD_COUNT files)" else echo -e "${YELLOW}!${NC} Uploads directory not found" fi echo "" # 7. Recent Application Logs echo "7. Recent Application Logs..." echo "-----------------------------------" if journalctl -u skyartshop.service -n 5 --no-pager 2>/dev/null | tail -5; then echo "" else echo -e "${YELLOW}!${NC} Unable to read application logs" fi # Summary echo "" echo "============================================" echo "Verification Complete!" echo "============================================" echo "" echo "Access your website at:" echo " - http://$IP_ADDRESS" if [ ! -z "$NGINX_SERVER_NAME" ] && [ "$NGINX_SERVER_NAME" != "_" ]; then echo " - http://$NGINX_SERVER_NAME" fi echo "" echo "Admin Panel:" echo " - http://$IP_ADDRESS/admin" echo ""